Date: Mon, 10 Jun 2002 02:28:03 +1000 (EST) From: Andrew <andrew@ugh.net.au> To: freebsd-gnats-submit@FreeBSD.org Cc: dima@unixfreak.org, <freebsd-bugs@FreeBSD.org> Subject: Re: bin/25278: bs accepts -s -c but not -sc Message-ID: <20020610022301.Y94582-200000@starbug.ugh.net.au> In-Reply-To: <20020610021320.X94582-200000@starbug.ugh.net.au>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Mon, 10 Jun 2002, Andrew wrote:
> (other patches to follow)
Ok here is a patch to get bs to use getopt. The diff looks messy but it
basically changes the guts of do_options from parsing command line options
itself to calling getopt. If you apply the patch then compare the
functions manually you can see what it happening.
This patch actually fixes the problem I was having.
Thanks,
Andrew
[-- Attachment #2 --]
--- bs.usage/bs.c Mon Jun 10 01:26:20 2002
+++ bs.getopt/bs.c Mon Jun 10 02:08:22 2002
@@ -1121,52 +1121,41 @@
}
-static void do_options(c,op)
-int c;
-char *op[];
+static void do_options(argc,argv)
+int argc;
+char *argv[];
{
- int i;
+ int c;
- if (c > 1)
- {
- for (i=1; i<c; i++)
- {
- switch(op[i][0])
- {
- default:
- case '?':
- usage();
- break;
- case '-':
- switch(op[i][1])
+ while ((c = getopt(argc, argv, "bcs")) != -1) {
+ switch (c) {
+ case 'b':
+ if (salvo == 1)
{
- case 'b':
+ (void) fprintf(stderr,
+ "Bad Arg: -b and -s are mutually exclusive\n");
+ exit(1);
+ }
+ else
blitz = 1;
- if (salvo == 1)
- {
- (void) fprintf(stderr,
- "Bad Arg: -b and -s are mutually exclusive\n");
- exit(1);
- }
- break;
- case 's':
- salvo = 1;
- if (blitz == 1)
- {
- (void) fprintf(stderr,
- "Bad Arg: -s and -b are mutually exclusive\n");
- exit(1);
- }
- break;
- case 'c':
- closepack = 1;
- break;
- default:
+ break;
+ case 's':
+ if (blitz == 1)
+ {
(void) fprintf(stderr,
- "Bad arg: type \"%s ?\" for usage message\n", op[0]);
+ "Bad Arg: -s and -b are mutually exclusive\n");
exit(1);
}
- }
+ else
+ salvo = 1;
+ break;
+ case 'c':
+ closepack = 1;
+ break;
+ case '?':
+ default:
+ usage();
+ break;
}
}
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020610022301.Y94582-200000>
