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

Bruno Haible <[email protected]> Thu, 20 Mar 2025 13:44:49 +0100
Newsgroups dev.linux.lists.liba2i
Organization GNU
Message-ID <20998621.Yz81rIOvuz@nimes>
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