strtonum(3) in FreeBSD?
Tobias Weingartner
weingart at tepid.org
Fri Apr 15 12:08:15 PDT 2005
On Friday, April 15, Peter Jeremy wrote:
>
> 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.
10k is 10 * 1024, not 10000. And yes, dd(1) interprets it that way.
My pet peave... K, M, G, T are the 2^whatever versions when we're
talking about computer quantities. Why do we have to introduce Ki-
whatever?
If you need the power that strtol() can provide, then yes, you need
strtol() and/or it's cousins. Most of the time you do not need that
sort of power (or their extensions). The strtonum() function will do
what you want just fine.
So, pick your poison. Make your choice. Live with them.
--Toby.
More information about the freebsd-current
mailing list