From owner-freebsd-current@FreeBSD.ORG Fri Apr 15 00:58:35 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 C9ADF16A4CE for ; Fri, 15 Apr 2005 00:58:35 +0000 (GMT) Received: from mail.codefusionis.com (ns.codefusionis.com [208.33.29.188]) by mx1.FreeBSD.org (Postfix) with SMTP id 06FBF43D31 for ; Fri, 15 Apr 2005 00:58:35 +0000 (GMT) (envelope-from tedu@zeitbombe.org) Received: (qmail 24059 invoked by uid 1049); 15 Apr 2005 01:01:26 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 15 Apr 2005 01:01:26 -0000 Date: Thu, 14 Apr 2005 21:01:26 -0400 (EDT) From: Ted Unangst X-X-Sender: tedu@ns.codefusionis.com To: Peter Jeremy In-Reply-To: <20050414210840.GT89047@cirb503493.alcatel.com.au> Message-ID: References: <20050414210840.GT89047@cirb503493.alcatel.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Mailman-Approved-At: Fri, 15 Apr 2005 12:07:22 +0000 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 00:58:35 -0000 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