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

Thorsten Glaser <[email protected]> Thu, 20 Mar 2025 00:52:07 +0100 (CET)
Newsgroups gmane.os.netbsd.devel.general
Message-ID <[email protected]>
On Thu, 20 Mar 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.

What?

From=20a user=E2=80=99s PoV, this is hugely useful, and many other
read-unsigned-integer-value routines handle this similarily
(of course using whatever range they have) and C also defines
this, so from an implementor=E2=80=99s PoV this is no trouble.

The other user=E2=80=99s PoV thing would be to allow 0x prefixing,
but that needs an entire duplication of the inner loop, so
I can see why people would want to exclude that.

bye,
//mirabilos
--=20
22:20=E2=8E=9C<asarch> The crazy that persists in his craziness becomes a m=
aster
22:21=E2=8E=9C<asarch> And the distance between the craziness and geniality=
 is
only measured by the success 18:35=E2=8E=9C<asarch> "Psychotics are consist=
ently
inconsistent. The essence of sanity is to be inconsistently inconsistent