alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
Alejandro Colomar
alx at kernel.org
Thu Mar 20 00:36:29 UTC 2025
Hi Thorsten,
On Thu, Mar 20, 2025 at 01:31:37AM +0100, Thorsten Glaser wrote:
> >Can you clarify how this is useful as a programmer? I have replaced
> >*all* calls to strtoul(3) et al. in shadow-utils by my strtou_noneg(),
> >and never ever saw a valid use case of that feature.
>
> I said useful for users (and no bother to programmers).
>
> This way, users can do things like './a.out -x $((something))'
> and have it work even if that something ends up negative in
> the shell (not all shells have a way for unsigned arithmetic
> output).
Ahh, I understand now. Hmmm, I think I prefer keeping my sanity, and
let the user do the hard work. :)
> >> The other user’s PoV thing would be to allow 0x prefixing,
>
> >I don't understand what you mean. strtou(3) supports 0x strings as
>
> Oh, right, it’s one of those where you specify the base.
> I might have been confused by too many things at talk at
> the same time.
Ahhh, probably with OpenBSD's strtonum(3).
long long
strtonum(const char *nptr, long long minval, long long maxval,
const char **errstr);
It seems it doesn't have a base.
> Or just need sleep. Good night to you as well,
> //mirabilos
Cheers,
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/490994d5/attachment.sig>
More information about the libbsd
mailing list