From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACE7B202971 for ; Wed, 19 Mar 2025 17:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=85.215.255.54 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742405787; cv=pass; b=kZH5pb2CSb1aNueQzr8kmUvdE4tArQZJEofDFghq2V52+tqMHWgNJ9KHgIuZOUVpjAQlSlG4jwn7R36kH/SH3H49hLP6wvycmYx7MFxMEywGgaKRcwk+2Z9U2mWPQw60VsaLAMpsXTmGy9h37p2D7UbwooPDKGrJcrOwJg2xRPI= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742405787; c=relaxed/simple; bh=6IKwivpeTJItUocVASs3wz0NfG92XIwK+iGo5/u0Fdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k8qNNArh9K+ajk3v13FP47fICIt59VSIKu0NZqriC7qDcMrbcUs+XWTGDdRUR1SwrF2l731wIXAgTG30ixnicuFgT8cFcqu1dxXM5PsUPK87BoD4WEcCvUTCgqo3fjSKmgT4ICI+zZuUimExx2fI0F0YI///pxoFTlLWu88zko8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=clisp.org; spf=none smtp.mailfrom=clisp.org; dkim=pass (2048-bit key) header.d=clisp.org header.i=@clisp.org header.b=OskgiMMH; dkim=permerror (0-bit key) header.d=clisp.org header.i=@clisp.org header.b=WuIYrLO7; arc=pass smtp.client-ip=85.215.255.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=clisp.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=clisp.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=clisp.org header.i=@clisp.org header.b="OskgiMMH"; dkim=permerror (0-bit key) header.d=clisp.org header.i=@clisp.org header.b="WuIYrLO7" ARC-Seal: i=1; a=rsa-sha256; t=1742405731; cv=none; d=strato.com; s=strato-dkim-0002; b=WdlyqwuCjNQK2sd17xglCHk9BVEvIi1OXO0l9Y/lpw799t/AdBgByGK+16AyacUuyu LxkLv0X1+eBfCf+qp/wxzZegJHIqHioIhKN7PBD2g89sCBHYLJMxi5PmhLzp1odTvQzO I8NnYwo+oVxudfMj8iw9wcySE5gjO5NcJhE5J5ysGEwaCr/FrZOXyPkwMGrIwF3oGB6o E3cmjO8m3d25dkLAUz+Wf/u2Zd3MhpmOJypVRQdT9l5KbdoTaXvmVWrXKFmPHXOk0OOY Oh3ioR3H5GMxIefZVkkFjnkXmYBgPlP35KozbOMoa9eHyBjue+9qnMvsaLmAwNXbpOCM vQ3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1742405731; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=dGmEriVALKxZYTE5bz4qgZJdh/g6TVxwMIL3lh1DrGo=; b=jUoSkEdAqJXtcUeJvfANWfV7+0QczrAgDEai/2BvwF9QhQf5gblOCg3+bCjjAipZtg lnOdZNVIFBuhaSDCXUn5SjhbUL715OWA6gM/AQekTG8xxwfvkCRoGrMSoW/fJ6jxtpNS kYQyjCJCYbCQ9L6r+ZVSgaC5wBu33V9kmtqNSbzTzoiaEFlwu67UN+LxdEmBF6uLVkGV aF6qvrN1nV7tAyUvyUBBWy/MjryM59gubx13flfKepb+glxlXDvYXK/zIpH1TJtYHgoa USxapc24tm1EUbzcuMsX6a10ZL1TK07Ja6dCvTubXyCd4pF2achTGcVseNQAwpEW5nUW vIkQ== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1742405731; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=dGmEriVALKxZYTE5bz4qgZJdh/g6TVxwMIL3lh1DrGo=; b=OskgiMMHOPI7B8t+r5mmf4ElAvi/W3dDHYn7wnJ/oLUU0OSdAhViZSAH6WlwzYX/x+ Znx7WYU3te68VpiN6dg6pCpIXTYN31rRAvdolP8jFdUahQm4JuxRtn5ShNG4mR/zcL+v FlqttDPARhPK0hmVubCX/1sNl0y0T9zDcRtkadk0x95W/TSlPUL4jK/DHYYpaqxB/g9y KEzOWuSoIrZcpRavNiV0OPeVlB7wX8PnyiLJY0Q5Pd1hTf7Zo4SEABjylImQ4V6w2CBa tiqlsJxoo9YSNekIbNy3YWD613JFCBmuFL2Ggrosxa9dUo43ppP4D7jRbsTlcFguTXZ1 RBLQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1742405731; s=strato-dkim-0003; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=dGmEriVALKxZYTE5bz4qgZJdh/g6TVxwMIL3lh1DrGo=; b=WuIYrLO7Suk1esyWShhmFDDilqiqDJ70D4LsixqTeLNtwCU8lbsl9saoCM3vYBRUBE pEZhKRItF0N3+IEWoCBg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlLnY4jECd2hdUURIbZgL8PX2QiTuZ3cdB8X/nqjiQEm7gzaGYG3gikYmFw+Yd+lvO" Received: from nimes.localnet by smtp.strato.de (RZmta 51.3.0 AUTH) with ESMTPSA id N7dcf812JHZT7m2 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 19 Mar 2025 18:35:29 +0100 (CET) From: Bruno Haible To: liba2i@lists.linux.dev, Alejandro Colomar Cc: sc22wg14@open-std.org, libbsd@lists.freedesktop.org, tech-misc@netbsd.org, christos , =?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh , Paul Eggert , Eli Schwartz , Guillem Jover , Iker Pedrosa , Michael Vetter , Robert Elz , riastradh@netbsd.org, Sam James , "Serge E. Hallyn" Subject: Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Date: Wed, 19 Mar 2025 18:35:29 +0100 Message-ID: <28568979.gRfpFWEtPU@nimes> Organization: GNU In-Reply-To: <6alwxn5mchma25qxvmzebx5vfheulfvgev7f7xjcjshma3hfok@3qtsvbzoljb2> References: <2add8852-2306-b522-5b59-8aa84aee0e53@mirbsd.org> <6alwxn5mchma25qxvmzebx5vfheulfvgev7f7xjcjshma3hfok@3qtsvbzoljb2> Precedence: bulk X-Mailing-List: liba2i@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Alejandro Colomar wrote: > > >> To address this adoption problem, how about changing these function = to > > >> generic functions (in the sense of )? In such a way that > > >> strtoi (n, &end, base, LONG_MIN, LONG_MAX, &status) > > >> is known to return a 'long' rather than 'intmax_t', and > > >> strtoi (n, &end, base, INT_MIN, INT_MAX, &status) > >=20 > > That, and especially=E2=80=A6 >=20 > Please propose an implementation of the overload-selectinging macro, and > clarify how this should work: >=20 > n =3D strto*(s, NULL, 0, SHRT_MIN, UINT_MAX, &status); Indeed, the "usual arithmetic conversions" (ISO C 23 =C2=A7 6.3.1.8, =C2=A7= 7.27.(7)) would not work well in this case. Instead, one needs to distinguish strtoi and strtou: - For strtoi, the first of the types 'signed char', 'short', 'int', 'long= ', 'long long', 'intmax_t' that contains both the min and the max value. - For strtou, the first of the types 'unsigned char', 'unsigned short', 'unsigned int', 'unsigned long', 'unsigned long long', 'uintmax_t' that contains both the min and the max value. Bruno