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

Bruno Haible bruno at clisp.org
Thu Mar 20 12:44:49 UTC 2025


Alejandro Colomar 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'.

Bruno





More information about the libbsd mailing list