alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
Alejandro Colomar
alx at kernel.org
Thu Mar 20 12:55:01 UTC 2025
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.
> >
> > Agree; it is a misfeature. ...
> >
> > I wonder if there's any legitimate user of that misfeature.
>
> 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
--
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/libbsd/attachments/20250320/ad8da4af/attachment.sig>
More information about the libbsd
mailing list