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

Alejandro Colomar <[email protected]> Thu, 20 Mar 2025 01:36:29 +0100
Newsgroups gmane.os.netbsd.devel.general
Message-ID <xednwbzvcu6kbb6kdptgh2afp47l4sqoom377wnlpb5rxbyrhc@7edsuvwyegdz>
--dmd3kirzu6f5tpgo
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
From: Alejandro Colomar <[email protected]>
To: Thorsten Glaser <[email protected]>
Cc: Bruno Haible <[email protected]>, [email protected], 
	[email protected], [email protected], [email protected], 
	christos <[email protected]>, 
	=?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh <[email protected]>, Paul Eggert <[email protected]>, 
	Eli Schwartz <[email protected]>, Guillem Jover <[email protected]>, 
	Iker Pedrosa <[email protected]>, Michael Vetter <[email protected]>, Robert Elz <[email protected]>, 
	[email protected], Sam James <[email protected]>, "Serge E. Hallyn" <[email protected]>
Subject: Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
References: <mgcfwxfmv3kpfnkkf6uj63kx5tdzl64p2zg2us4ntsu6q5xkwj@k52z5yyiywoo>
 <3237498.fEcJ0Lxnt5@nimes>
 <jx4664ishtl34eg2npdrv5fkfdiczqnlq3vjuacjrupjvh377x@gddcftzgwmfq>
 <4085563.2iPT33SAM4@nimes>
 <x34jdlyb6gf6asojjhzwpol5schyz4llk2ebrtzpb7ryje52u6@smbvzpoqcf6v>
 <[email protected]>
 <vjwcgdc46zm7a2wp3smlvhjaalsc7pwywpgdktpgzgb7fgz7mz@sgc4rza73aju>
 <[email protected]>
MIME-Version: 1.0
In-Reply-To: <[email protected]>

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.
>=20
> I said useful for users (and no bother to programmers).
>=20
> 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=E2=80=99s PoV thing would be to allow 0x prefixing,
>=20
> >I don't understand what you mean.  strtou(3) supports 0x strings as
>=20
> Oh, right, it=E2=80=99s 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  :)

--=20
<https://www.alejandro-colomar.es/>

--dmd3kirzu6f5tpgo
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmfbYwcACgkQ64mZXMKQ
wqkWixAAovEXT1933Yy4nfIjf/K11AjObTwxYf8qYKtdmrvdId3gD/agR251xCE5
pGgC+DUFSgHuvq3mCHkUtUOJBJUYyh10QkZu5mmEKOaYK7KAqdU+yy1g9IpN6J6f
DKyklPgP8zqPozO2z+CqY2l5TN0nJ2OWAYr/TKcVjs2mvrvidjsfla+VWg6NCIyS
lvJxLnNKMYEOzEQKC7k2skEG3C5RqnbbgHS7OebisqT8wZzgFUnpeyyTytbonSut
deNG4ihHzYF8a4AXRcLzLzl6psYDxhoQdZ9NUWEApPZV53qQ7b3DuruZBrFJmRzh
HGJGm9uNwTlhGLbSNIGsKC5d90LBMJONhgH55rzdrAJZUvrIJx0DILLiHt8gw24f
sp6bYHXq/lIGM4UnbU/qUCGmPyDhHj182Z9TjHjesaiZqtlLWcxDCaRaUaCiiTdD
GUzS6oatH5cW2xSr1HovyRfqnPFY7Z6qgluZnKrA5aVwnwfZK1C2D1fr8/xqKrTF
byFP8N3jA2YbPKbfvGLrLbxBwArUcKNdRzHNCA+WQlUMkbmwyr22yQIAIY7Twr43
9biHBzWlE84hqiwk827FinqLzl219AyDEJvSFB6JLeG1rcxpV4fKZGf30sZU5+0p
gO292UFU4HeEry65kyBZcK3hFSEbEod0OXNSX6flZQ/KO11Kzus=
=9cPO
-----END PGP SIGNATURE-----

--dmd3kirzu6f5tpgo--