From owner-svn-src-all@freebsd.org Wed Jul 15 03:25:59 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE1E099B09D for ; Wed, 15 Jul 2015 03:25:59 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery4.ore.mailhop.org (pmta2.delivery4.ore.mailhop.org [54.200.247.200]) by mx1.freebsd.org (Postfix) with SMTP id B451A29AB for ; Wed, 15 Jul 2015 03:25:59 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from ilsoft.org (unknown [73.34.117.227]) by outbound1.ore.mailhop.org (Halon Mail Gateway) with ESMTPSA; Wed, 15 Jul 2015 03:25:38 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id t6F3Pp75050765; Tue, 14 Jul 2015 21:25:51 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1436930751.1334.325.camel@freebsd.org> Subject: Re: svn commit: r285552 - head/usr.bin/xargs From: Ian Lepore To: d@delphij.net Cc: Garrett Cooper , Baptiste Daroussin , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Tue, 14 Jul 2015 21:25:51 -0600 In-Reply-To: <55A5A30F.4070005@delphij.net> References: <201507141916.t6EJGEG1083928@repo.freebsd.org> <48222CD1-7087-4C9A-A586-71F6A37A601C@gmail.com> <55A574BA.4090700@delphij.net> <1436912270.1334.309.camel@freebsd.org> <55A5A30F.4070005@delphij.net> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.12.10 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2015 03:26:00 -0000 On Tue, 2015-07-14 at 17:02 -0700, Xin Li wrote: > On 07/14/15 15:17, Ian Lepore wrote: > > On Tue, 2015-07-14 at 13:44 -0700, Xin Li wrote: > >> On 07/14/15 13:29, Garrett Cooper wrote: > >>> On Jul 14, 2015, at 12:16, Baptiste Daroussin > >>> wrote: > >>> > >>>> Author: bapt Date: Tue Jul 14 19:16:14 2015 New Revision: > >>>> 285552 URL: https://svnweb.freebsd.org/changeset/base/285552 > >>>> > >>>> Log: Convert atoi(3) to stronum(3) which allows to arguments > >>>> and report proper errors to the users > >>> > >>> Is strtonum preferred over strtoll, etc? > >> > >> strtonum(3) is a wrapper of strtoll() and provides more > >> functionality like range checking, so I think the answer would be > >> yes. > >> > >> Cheers, > >> > > > > Except if we convert all our tools that take numbers on the command > > line to use strtonum() then peoples' existing scripts and other > > automation that passes 0xWhatever numbers suddenly stop working. > > strtonum() seems to be about 2/3 of a good idea. > > I think the caller has to be calling with 0 or 16 as base to request > that behavior? If we are converting from atoi, the base number is a > fixed value of 10. > > My only concern with strtonum() is that it's English only. > > Cheers, revolution > cd src /bsdstg/head/src revolution > gs . 'strto.*l.*\(.*0\)' | wc -l 2176 revolution > gs . 'strto.*l.*\(.*10\)' | wc -l 1097 Looks like about half our strtol-ish calls specify 10 instead of 0. Many of those are in the compilers and other places where it really has to be 10. Probably a good number of them are places that really should just be 0. I know over the years I've been pleasantly surprised and occasionally disappointed about being able to use 0x numbers on command lines and config files where it felt more natural. -- Ian