strtonum(3) in FreeBSD?
Peter Jeremy
PeterJeremy at optushome.com.au
Tue Apr 12 12:57:04 PDT 2005
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@(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
More information about the freebsd-current
mailing list