From owner-freebsd-current@FreeBSD.ORG Fri Apr 15 19:08:15 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8388A16A4CE for ; Fri, 15 Apr 2005 19:08:15 +0000 (GMT) Received: from natasha.tepid.org (natasha.tepid.org [68.148.0.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A4F743D3F for ; Fri, 15 Apr 2005 19:08:15 +0000 (GMT) (envelope-from weingart@tepid.org) Received: from natasha.tepid.org (localhost [127.0.0.1]) by natasha.tepid.org (Postfix) with ESMTP id BAC543F3C; Fri, 15 Apr 2005 13:08:14 -0600 (MDT) To: Peter Jeremy In-Reply-To: Message from Peter Jeremy <20050414210840.GT89047@cirb503493.alcatel.com.au> Date: Fri, 15 Apr 2005 13:08:14 -0600 Message-ID: <163.1113592094@natasha.tepid.org> From: Tobias Weingartner X-Mailman-Approved-At: Sat, 16 Apr 2005 12:00:03 +0000 cc: Ted Unangst cc: tech@openbsd.org cc: freebsd-current@freebsd.org Subject: Re: strtonum(3) in FreeBSD? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2005 19:08:15 -0000 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.