Re: strtonum(3) in FreeBSD?

From: Ted Unangst <tedu_at_zeitbombe.org>
Date: Thu, 14 Apr 2005 21:01:26 -0400 (EDT)
On Fri, 15 Apr 2005, Peter Jeremy wrote:

> The manpage states:
>   "The strtonum function was designed to facilitate safe, robust
>    programming and overcome the shortcomings of the atoi(3) and
>    strtol(3) family of interfaces."
> This implies (to me anyway) that it is a replacement for strtol(),
> though it only implements a subset of strtol() functionality.

yes, to make it simpler.

> This means you can't use it in a simple parser to handle the user
> entering "10k" to mean 10000 or "128m" to mean 128000000.  dd(1) needs
> this and I've used it on occasion.  Again, it's being sold as a
> replacement for strtol() but isn't.

pop quiz!  quick, how big is the file created by running "dd if=/dev/zero 
of=foo count=0x013b0x013b"?  no credit if you have to run the command to 
find out. :)

that's the kind of weirdness strtonum is designed to prevent.  of course, 
if you want the weirdness, strtonum is not for you.


-- 
we don't run washington and no one really does
Received on Thu Apr 14 2005 - 22:58:35 UTC

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