From owner-cvs-all@FreeBSD.ORG Wed Jun 4 22:30:17 2008 Return-Path: Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4BDC106567E; Wed, 4 Jun 2008 22:30:17 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.freebsd.org (Postfix) with ESMTP id 80BE28FC32; Wed, 4 Jun 2008 22:30:17 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.2/8.14.2) with ESMTP id m54MTVvB050184; Wed, 4 Jun 2008 15:29:31 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.2/8.14.2/Submit) id m54MTVwR050183; Wed, 4 Jun 2008 15:29:31 -0700 (PDT) (envelope-from sgk) Date: Wed, 4 Jun 2008 15:29:31 -0700 From: Steve Kargl To: Coleman Kane Message-ID: <20080604222931.GA50114@troutmask.apl.washington.edu> References: <20080604041815.GA84027@FreeBSD.org> <20080604043955.GA38627@troutmask.apl.washington.edu> <20080604063631.GA28351@freebie.xs4all.nl> <20080604150013.GA44358@troutmask.apl.washington.edu> <20080604191339.GA31570@freebie.xs4all.nl> <20080604192955.GA46284@troutmask.apl.washington.edu> <1212608575.15220.109.camel@localhost> <4846F520.6040400@FreeBSD.org> <1212614663.15220.136.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1212614663.15220.136.camel@localhost> User-Agent: Mutt/1.4.2.3i Cc: Maxim Sobolev , Alexey Dokuchaev , src-committers@FreeBSD.org, Florent Thoumie , cvs-src@FreeBSD.org, cvs-all@FreeBSD.org, Wilko Bulte Subject: Re: cvs commit: src/usr.sbin/pkg_install/add main.c pkg_add.1 src/usr.sbin/pkg_install/create main.c pkg_create.1 src/usr.sbin/pkg_install/delete main.c pkg_delete.1 src/usr.sbin/pkg_install/info main.c pkg_info.1 ... X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2008 22:30:18 -0000 On Wed, Jun 04, 2008 at 05:24:23PM -0400, Coleman Kane wrote: > It's probably premature to begin shooting that down. I merely picked > "cp" as the first tool that came to mind which lives in /bin. Maybe I > should have picked on /bin/pax or /usr/bin/lex instead, or something > else with 20+ getopt args :P. > > My point was that it was pretty absurd to start treating this like it > will turn into a giant mad party of getopt_long conversions. I don't > really have the inclination to go out and add long options to any tool > myself, because I have better things to do with my time. As I said > earlier, I think it's a better policy to discuss this when the > patch/commit comes along, and see what people's feelings are on the > matter then. I don't think it is anybody's place at the moment (except > maybe core@) to try and deter a committer from making what some feel is > a beneficial change to software. > Please commit. The patch gives conformance to Posix (ie., IEEE Std 1003.1, 2004 Edition). As a bonus, I've included long options for compatibility with GNU wc. Index: wc.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/wc/wc.1,v retrieving revision 1.25 diff -u -p -r1.25 wc.1 --- wc.1 21 Dec 2006 22:59:07 -0000 1.25 +++ wc.1 4 Jun 2008 22:27:15 -0000 @@ -71,25 +71,19 @@ the last file. .Pp The following options are available: .Bl -tag -width indent -.It Fl c +.It Fl c , -bytes The number of bytes in each input file is written to the standard output. -This will cancel out any prior usage of the -.Fl m -option. -.It Fl l +.It Fl l , -lines The number of lines in each input file is written to the standard output. -.It Fl m +.It Fl m , -chars The number of characters in each input file is written to the standard output. If the current locale does not support multibyte characters, this is equivalent to the .Fl c option. -This will cancel out any prior usage of the -.Fl c -option. -.It Fl w +.It Fl w , -words The number of words in each input file is written to the standard output. .El Index: wc.c =================================================================== RCS file: /home/ncvs/src/usr.bin/wc/wc.c,v retrieving revision 1.21 diff -u -p -r1.21 wc.c --- wc.c 27 Dec 2004 22:27:56 -0000 1.21 +++ wc.c 4 Jun 2008 22:27:15 -0000 @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD: src/usr.bin/wc/wc.c, #include #include #include +#include #include #include #include @@ -68,6 +69,15 @@ int doline, doword, dochar, domulti; static int cnt(const char *); static void usage(void); +static char opts[] = "clmw"; +static struct option longopts[] = { + { "bytes", no_argument, NULL, 'c' }, + { "lines", no_argument, NULL, 'l' }, + { "chars", no_argument, NULL, 'm' }, + { "words", no_argument, NULL, 'w' }, + { NULL, 0, NULL, 0 }, +}; + int main(int argc, char *argv[]) { @@ -75,7 +85,7 @@ main(int argc, char *argv[]) (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc, argv, "clmw")) != -1) + while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch((char)ch) { case 'l': doline = 1; @@ -85,11 +95,13 @@ main(int argc, char *argv[]) break; case 'c': dochar = 1; - domulti = 0; + if (domulti) + errx(1, "-c conflicts with -m"); break; case 'm': domulti = 1; - dochar = 0; + if (dochar) + errx(1, "-m conflicts with -c"); break; case '?': default: @@ -263,6 +275,6 @@ word: gotsp = 1; static void usage() { - (void)fprintf(stderr, "usage: wc [-clmw] [file ...]\n"); + (void)fprintf(stderr, "usage: wc [-c|-m][-lw] [file ...]\n"); exit(1); }