From owner-freebsd-current@FreeBSD.ORG Tue Apr 12 19:57:04 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 AA5C416A4CE for ; Tue, 12 Apr 2005 19:57:04 +0000 (GMT) Received: from mail16.syd.optusnet.com.au (mail16.syd.optusnet.com.au [211.29.132.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E36743D1D for ; Tue, 12 Apr 2005 19:57:04 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) j3CJv15F031224 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Wed, 13 Apr 2005 05:57:02 +1000 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1])j3CJv17l000372; Wed, 13 Apr 2005 05:57:01 +1000 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost)j3CJv1k0000371; Wed, 13 Apr 2005 05:57:01 +1000 (EST) (envelope-from pjeremy) Date: Wed, 13 Apr 2005 05:57:01 +1000 From: Peter Jeremy To: "R. Tyler Ballance" Message-ID: <20050412195700.GN89047@cirb503493.alcatel.com.au> References: <1113332762.27362.29.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1113332762.27362.29.camel@localhost.localdomain> User-Agent: Mutt/1.4.2i cc: FreeBSD Current 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: Tue, 12 Apr 2005 19:57:04 -0000 On Tue, 2005-Apr-12 14:06:02 -0500, R. Tyler Ballance wrote: >Quick, sort of, question. Is it worth it to bring strtonum(3) from >OpenBSD into FreeBSD-CURRENT. Based on the manpage, I'd suggest not. >In theory, it should be a better implementation of what atoi(3) and >strtol(3) do, but as tg@(mirbsd.org) pointed out to the OpenBSD fellows >and myself, it doesn't take hexadecimal values well... Based on the man page, I see the following deficiencies: 1) No support for bases other than 10 2) No provision to return the end of the converted string 3) No simple way to distinguish errors from a valid zero. Based on the behaviour documented in the manpage, it's just as difficult to use safely as atoi() or strtol(). The example given in the man page relies on behaviour which is not documented in the man page - namely that errstr is set to NULL on a successful conversion. If this behaviour was documented then that would remove the third point above and make it useful as a replacement for atoi() in some cases. -- Peter Jeremy