Re: strtonum(3) in FreeBSD?

From: Peter Jeremy <PeterJeremy_at_optushome.com.au>
Date: Wed, 13 Apr 2005 05:57:01 +1000
On Tue, 2005-Apr-12 14:06:02 -0500, R. Tyler Ballance wrote:
>Quick, sort of, question. Is it worth it to bring strtonum(3) from
>OpenBSD into FreeBSD-CURRENT.

Based on the manpage, I'd suggest not.

>In theory, it should be a better implementation of what atoi(3) and
>strtol(3) do, but as tg_at_(mirbsd.org) pointed out to the OpenBSD fellows
>and myself, it doesn't take hexadecimal values well...

Based on the man page, I see the following deficiencies:
1) No support for bases other than 10
2) No provision to return the end of the converted string
3) No simple way to distinguish errors from a valid zero.

Based on the behaviour documented in the manpage, it's just as
difficult to use safely as atoi() or strtol().  The example given in
the man page relies on behaviour which is not documented in the man
page - namely that errstr is set to NULL on a successful conversion.
If this behaviour was documented then that would remove the third
point above and make it useful as a replacement for atoi() in some
cases.

-- 
Peter Jeremy
Received on Tue Apr 12 2005 - 17:57:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:32 UTC