diff options
author | millert <> | 2002-12-05 22:26:04 +0000 |
---|---|---|
committer | millert <> | 2002-12-05 22:26:04 +0000 |
commit | 84112301cf2c1f2f91782ff7f25e87d7436333e7 (patch) | |
tree | c464dcb1d6850e9e1597cd8f23bd2cc7ad67e0ba /src/lib | |
parent | 134d36e1be4bd10ccec3bfba3d10a9b959891c36 (diff) | |
download | openbsd-84112301cf2c1f2f91782ff7f25e87d7436333e7.tar.gz openbsd-84112301cf2c1f2f91782ff7f25e87d7436333e7.tar.bz2 openbsd-84112301cf2c1f2f91782ff7f25e87d7436333e7.zip |
Correctly handle -Wlong_arg (no space between -W and long_arg) when "W;"
is in optstring.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/stdlib/getopt_long.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/getopt_long.c b/src/lib/libc/stdlib/getopt_long.c index 130c1d8bfa..bcbd53cf44 100644 --- a/src/lib/libc/stdlib/getopt_long.c +++ b/src/lib/libc/stdlib/getopt_long.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: getopt_long.c,v 1.3 2002/12/05 21:45:01 millert Exp $ */ | 1 | /* $OpenBSD: getopt_long.c,v 1.4 2002/12/05 22:26:04 millert Exp $ */ |
2 | /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ | 2 | /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ |
3 | 3 | ||
4 | /*- | 4 | /*- |
@@ -38,7 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | 39 | ||
40 | #if defined(LIBC_SCCS) && !defined(lint) | 40 | #if defined(LIBC_SCCS) && !defined(lint) |
41 | static char *rcsid = "$OpenBSD: getopt_long.c,v 1.3 2002/12/05 21:45:01 millert Exp $"; | 41 | static char *rcsid = "$OpenBSD: getopt_long.c,v 1.4 2002/12/05 22:26:04 millert Exp $"; |
42 | #endif /* LIBC_SCCS and not lint */ | 42 | #endif /* LIBC_SCCS and not lint */ |
43 | 43 | ||
44 | #include <err.h> | 44 | #include <err.h> |
@@ -62,11 +62,11 @@ char *optarg; /* argument associated with option */ | |||
62 | #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ | 62 | #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ |
63 | 63 | ||
64 | /* return values */ | 64 | /* return values */ |
65 | #define BADCH (int)'?' | 65 | #define BADCH (int)'?' |
66 | #define BADARG ((*options == ':') ? (int)':' : (int)'?') | 66 | #define BADARG ((*options == ':') ? (int)':' : (int)'?') |
67 | #define INORDER (int)1 | 67 | #define INORDER (int)1 |
68 | 68 | ||
69 | #define EMSG "" | 69 | #define EMSG "" |
70 | 70 | ||
71 | static int getopt_internal(int, char * const *, const char *, | 71 | static int getopt_internal(int, char * const *, const char *, |
72 | const struct option *, int *, int); | 72 | const struct option *, int *, int); |
@@ -403,7 +403,9 @@ start: | |||
403 | } | 403 | } |
404 | if (long_options != NULL && optchar == 'W' && oli[1] == ';') { | 404 | if (long_options != NULL && optchar == 'W' && oli[1] == ';') { |
405 | /* -W long-option */ | 405 | /* -W long-option */ |
406 | if (++optind >= nargc) { /* no arg */ | 406 | if (*place) /* no space */ |
407 | /* NOTHING */; | ||
408 | else if (++optind >= nargc) { /* no arg */ | ||
407 | place = EMSG; | 409 | place = EMSG; |
408 | if (PRINT_ERROR) | 410 | if (PRINT_ERROR) |
409 | warnx(recargchar, optchar); | 411 | warnx(recargchar, optchar); |