diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-05 22:26:05 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-05 22:26:05 +0000 |
commit | 6fd2982083205224df22d701142208c69cfffcaf (patch) | |
tree | 115eb971865c75abf361840a8d3d4f35083b87bf /lib/libc | |
parent | 4d5a44907aac4575e14651ef0f82b8413d323b9d (diff) |
Correctly handle -Wlong_arg (no space between -W and long_arg) when "W;"
is in optstring.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdlib/getopt_long.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c index 130c1d8bfae..bcbd53cf441 100644 --- a/lib/libc/stdlib/getopt_long.c +++ b/lib/libc/stdlib/getopt_long.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getopt_long.c,v 1.3 2002/12/05 21:45:01 millert Exp $ */ +/* $OpenBSD: getopt_long.c,v 1.4 2002/12/05 22:26:04 millert Exp $ */ /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ /*- @@ -38,7 +38,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getopt_long.c,v 1.3 2002/12/05 21:45:01 millert Exp $"; +static char *rcsid = "$OpenBSD: getopt_long.c,v 1.4 2002/12/05 22:26:04 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <err.h> @@ -62,11 +62,11 @@ char *optarg; /* argument associated with option */ #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ /* return values */ -#define BADCH (int)'?' +#define BADCH (int)'?' #define BADARG ((*options == ':') ? (int)':' : (int)'?') -#define INORDER (int)1 +#define INORDER (int)1 -#define EMSG "" +#define EMSG "" static int getopt_internal(int, char * const *, const char *, const struct option *, int *, int); @@ -403,7 +403,9 @@ start: } if (long_options != NULL && optchar == 'W' && oli[1] == ';') { /* -W long-option */ - if (++optind >= nargc) { /* no arg */ + if (*place) /* no space */ + /* NOTHING */; + else if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) warnx(recargchar, optchar); |