Re: strtonum(3) in FreeBSD?

From: Tobias Weingartner <weingart_at_tepid.org>
Date: Fri, 15 Apr 2005 13:08:14 -0600
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.
Received on Fri Apr 15 2005 - 17:08:15 UTC

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