Return-Path: Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Delivered-To: mailing list dev@apr.apache.org Received: (qmail 89584 invoked from network); 25 Nov 2000 22:38:13 -0000 Received: from test.webdav.org (HELO kurgan.lyra.org) (198.144.203.199) by locus.apache.org with SMTP; 25 Nov 2000 22:38:13 -0000 Received: (from gstein@localhost) by kurgan.lyra.org (8.9.3/8.9.3) id OAA32246 for dev@apr.apache.org; Sat, 25 Nov 2000 14:40:06 -0800 X-Authentication-Warning: kurgan.lyra.org: gstein set sender to gstein@lyra.org using -f Date: Sat, 25 Nov 2000 14:40:06 -0800 From: Greg Stein To: dev@apr.apache.org Subject: Re: cvs commit: apr/test testargs.c Message-ID: <20001125144005.W21426@lyra.org> References: <20001125223404.89038.qmail@locus.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20001125223404.89038.qmail@locus.apache.org>; from gstein@locus.apache.org on Sat, Nov 25, 2000 at 10:34:04PM -0000 X-URL: http://www.lyra.org/greg/ X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N Speaking of testargs.c ... the "d::" part means that the argument for -d is *optional*. Currently, getopt() requires an argument (read: it doesn't understand double-colons). Q: should it understand a double-colon? [ the man page for getopt() describes the double-colon ] Cheers, -g On Sat, Nov 25, 2000 at 10:34:04PM -0000, gstein@locus.apache.org wrote: > gstein 00/11/25 14:34:04 > > Modified: test testargs.c > Log: > add a "default:" case, just to be sure. > print out any additional arguments. > factor out the maybe_arg() functionality. > > Revision Changes Path > 1.16 +20 -7 apr/test/testargs.c > > Index: testargs.c > =================================================================== > RCS file: /home/cvs/apr/test/testargs.c,v > retrieving revision 1.15 > retrieving revision 1.16 > diff -u -u -r1.15 -r1.16 > --- testargs.c 2000/08/09 14:55:44 1.15 > +++ testargs.c 2000/11/25 22:34:04 1.16 > @@ -63,6 +63,16 @@ > #include > #endif > > +static void maybe_arg(const char *arg) > +{ > + if (arg) { > + printf(" with %s\n", arg); > + } > + else { > + printf("\n"); > + } > +} > + > int main(int argc, char * const argv[]) > { > apr_pool_t *context; > @@ -80,7 +90,7 @@ > exit(1); > } > while (apr_getopt(opt, "abc:d::", &data, &optarg) == APR_SUCCESS) { > - switch(data) { > + switch (data) { > case 'a': > case 'b': > printf("option %c\n", data); > @@ -90,14 +100,17 @@ > break; > case 'd': > printf("option %c", data); > - if (optarg) { > - printf(" with %s\n", optarg); > - } > - else { > - printf("\n"); > - } > + maybe_arg(optarg); > break; > + default: > + printf("unknown option: %c", data); > + maybe_arg(optarg); > + break; > } > } > + > + while (opt->ind < opt->argc) > + printf("extra arg: %s\n", opt->argv[opt->ind++]); > + > return 1; > } > > > -- Greg Stein, http://www.lyra.org/