Questionable behavior of strtoi(3bsd) / strtou(3bsd)

Thorsten Glaser tg at mirbsd.de
Sun Jan 7 23:38:55 UTC 2024


Alejandro Colomar dixit:

>would break existing code.  I'd say it's because strtonum(3) is...
>special.  It's not something you'd use for writing a parser.  It's
>more like a very specialized tool for parsing a command line argument
>that should only be a number, or things like that, and unsuitable for
>anything else.

I think the OpenBSD people would disagree.

Yes, it’s not a parser tool. It *is*, however, a replacement
for strto{i,{,u}{l{,l},imax}} and atoi in the general case,
i.e. almost everywhere, and *especially* in numeric option
parsing.

(strtonum doesn’t need to be implemented in terms of the
NetBSD-specific strtoi, though; it certainly isn’t in the
OpenBSD original.)

bye,
//mirabilos
-- 
“It is inappropriate to require that a time represented as
 seconds since the Epoch precisely represent the number of
 seconds between the referenced time and the Epoch.”
	-- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2


More information about the libbsd mailing list