diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2001-08-16 03:27:03 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2001-08-16 03:27:03 +0000 |
commit | 033062de2808b7afabf858d790f3344faecefef8 (patch) | |
tree | 9779c5cc62a5818fb6d1cfea162e0498fe0d9c91 | |
parent | cfe0163bbcfef0b8d2c8174b4beb99a4e452a83c (diff) | |
download | FreeBSD-src-033062de2808b7afabf858d790f3344faecefef8.zip FreeBSD-src-033062de2808b7afabf858d790f3344faecefef8.tar.gz |
If the string specifying the allowed options starts with a leading `:',
`getopt(3)' should not print a warning for missing argument values.
PR: bin/29625
Reviewed by: mikeh
MFC after: 1 week
-rw-r--r-- | lib/libc/stdlib/getopt.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index 17059a8..873d443 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -65,7 +65,6 @@ getopt(nargc, nargv, ostr) extern char *__progname; static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ - int ret; if (optreset || !*place) { /* update scanning pointer */ optreset = 0; @@ -105,14 +104,12 @@ getopt(nargc, nargv, ostr) else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (*ostr == ':') - ret = BADARG; - else - ret = BADCH; + return (BADARG); if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", __progname, optopt); - return (ret); + return (BADCH); } else /* white space */ optarg = nargv[optind]; |