tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

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



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/>

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index