diff options
Diffstat (limited to 'contrib/libpcap/missing/getopt.c')
-rw-r--r-- | contrib/libpcap/missing/getopt.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/contrib/libpcap/missing/getopt.c b/contrib/libpcap/missing/getopt.c index 7c897c6f5936..c535776d849c 100644 --- a/contrib/libpcap/missing/getopt.c +++ b/contrib/libpcap/missing/getopt.c @@ -80,9 +80,18 @@ getopt(int nargc, char * const *nargv, const char *ostr) place = EMSG; return (-1); } - } /* option letter okay? */ - if ((optopt = (int)*place++) == (int)':' || - !(oli = strchr(ostr, optopt))) { + } + optopt = (int)*place++; + if (optopt == (int)':') { /* option letter okay? */ + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname, optopt); + return (BADCH); + } + oli = strchr(ostr, optopt); + if (!oli) { /* * if the user didn't specify '-' as an option, * assume it means -1. @@ -114,7 +123,7 @@ getopt(int nargc, char * const *nargv, const char *ostr) __progname, optopt); return (BADCH); } - else /* white space */ + else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; |