Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD

Alejandro Colomar <[email protected]> Thu, 20 Mar 2025 13:55:01 +0100
Newsgroups gmane.os.netbsd.devel.general
Message-ID <cvlwvnk2l4rmhife7z7emeibxjxifutr2txtyqwrw6yt5um2pp@v2v3dtobmowi>
--7wszqvn3pa6eofqk
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
From: Alejandro Colomar <[email protected]>
To: Bruno Haible <[email protected]>
Cc: [email protected], [email protected], 
	[email protected], [email protected], christos <[email protected]>, 
	=?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh <[email protected]>, Paul Eggert <[email protected]>, 
	Eli Schwartz <[email protected]>, Guillem Jover <[email protected]>, 
	Iker Pedrosa <[email protected]>, Michael Vetter <[email protected]>, Robert Elz <[email protected]>, 
	[email protected], Sam James <[email protected]>, "Serge E. Hallyn" <[email protected]>
Subject: Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
References: <mgcfwxfmv3kpfnkkf6uj63kx5tdzl64p2zg2us4ntsu6q5xkwj@k52z5yyiywoo>
 <4085563.2iPT33SAM4@nimes>
 <x34jdlyb6gf6asojjhzwpol5schyz4llk2ebrtzpb7ryje52u6@smbvzpoqcf6v>
 <20998621.Yz81rIOvuz@nimes>
MIME-Version: 1.0
In-Reply-To: <20998621.Yz81rIOvuz@nimes>

Hi Bruno,

On Thu, Mar 20, 2025 at 01:44:49PM +0100, Bruno Haible wrote:
> > > At the same time, disallowing a leading '-' sign
> > > is a benefit as well. I consider it a misfeature that strtoul() parses
> > > "-3" successfully and returns ULONG_MAX-2, which was most certainly
> > > not intended by the user.
> >=20
> > Agree; it is a misfeature.  ...
> >=20
> > I wonder if there's any legitimate user of that misfeature.
>=20
> I don't think there is. Callers who wish to accept a leading '-' sign
> can call strtol() and cast the result to 'unsigned long'.

Yeah.  The only issue with that is not having the full range of
uintmax_t.  But I still think it's a misfeature.


Have a lovely day!
Alex

--=20
<https://www.alejandro-colomar.es/>

--7wszqvn3pa6eofqk
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmfcEB4ACgkQ64mZXMKQ
wqnuvBAAlxnr5qW5WmcRgEQkDXBeLqcWGVY9Gf2bz6jny0/X+fEZaqaIwABNlN3o
WKNhC6QxFDV6WIriLbDBrVUVTJlQNB598vTaRSclhu2lDDwMQVIHrmJ12/B6ZE7X
wkpbdMRLababIx3WLX4/S2SgbR9857gnICtKHhmeXNcuWITI0Wpyprln5oSmolVC
8XheOmCjOHPsrSaBAeLAKXovoDI6jsWyPumtkHfOSDYBqkoXdsporjiF4HSfpS05
rlRTKMCwn7KjZe+NCOyNAg7W3w0tggrRtCEOCO/8Ho0FSedg3NFvJiv87rlS93Ym
AgQ5/CwPWEgSJTVp9wPitOPHKfAXG22vP44hM5A2fBwGvDhu7tEGiGf3K8NLbv9p
wrTH924HU8UDlaETvU8mdR7fFC3CQ+QsF7Sq91hZyBIa+eTxgvX+gkuxwAjriD8F
pZbZ7uZqF1fJGSs++4mFogUmcSOSjRyJt3Hlz/mCj2kvsgfTiRS9hCd78LC547Xo
fsKyRZpekZ9KQLraENf8v5sqreBNh2u8plBzp5jTpyrTcrLDnslaWIe0Qw6rEPL8
lFv08avenSwKWAyhOl9m5Ds1uKQ5F5F9hE/j9vxQ6pB2wH4cFYjhqNfBTxCZKCtf
ZEphQAnRIQ1K95gTMVlSlIQrtXjZPtgzOsemvdV0jcDmpHlzmi8=
=9uyg
-----END PGP SIGNATURE-----

--7wszqvn3pa6eofqk--