diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/getopt_long.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/getopt_long.c b/src/lib/libc/stdlib/getopt_long.c index 2eec98530a..176ba25bb7 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.8 2002/12/08 07:23:09 millert Exp $ */ | 1 | /* $OpenBSD: getopt_long.c,v 1.9 2002/12/08 17:07:46 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 | /* |
| @@ -64,7 +64,7 @@ | |||
| 64 | */ | 64 | */ |
| 65 | 65 | ||
| 66 | #if defined(LIBC_SCCS) && !defined(lint) | 66 | #if defined(LIBC_SCCS) && !defined(lint) |
| 67 | static char *rcsid = "$OpenBSD: getopt_long.c,v 1.8 2002/12/08 07:23:09 millert Exp $"; | 67 | static char *rcsid = "$OpenBSD: getopt_long.c,v 1.9 2002/12/08 17:07:46 millert Exp $"; |
| 68 | #endif /* LIBC_SCCS and not lint */ | 68 | #endif /* LIBC_SCCS and not lint */ |
| 69 | 69 | ||
| 70 | #include <err.h> | 70 | #include <err.h> |
| @@ -320,10 +320,8 @@ getopt_internal(int nargc, char * const *nargv, const char *options, | |||
| 320 | * XXX Some GNU programs (like cvs) set optind to 0 instead of | 320 | * XXX Some GNU programs (like cvs) set optind to 0 instead of |
| 321 | * XXX using optreset. Work around this braindamage. | 321 | * XXX using optreset. Work around this braindamage. |
| 322 | */ | 322 | */ |
| 323 | if (optind == 0) { | 323 | if (optind == 0) |
| 324 | optind = 1; | 324 | optind = optreset = 1; |
| 325 | optreset = 1; | ||
| 326 | } | ||
| 327 | 325 | ||
| 328 | if (optreset) | 326 | if (optreset) |
| 329 | nonopt_start = nonopt_end = -1; | 327 | nonopt_start = nonopt_end = -1; |
| @@ -428,6 +426,12 @@ start: | |||
| 428 | 426 | ||
| 429 | if ((optchar = (int)*place++) == (int)':' || | 427 | if ((optchar = (int)*place++) == (int)':' || |
| 430 | (oli = strchr(options, optchar)) == NULL) { | 428 | (oli = strchr(options, optchar)) == NULL) { |
| 429 | /* | ||
| 430 | * If the user didn't specify '-' as an option, | ||
| 431 | * assume it means -1 as POSIX specifies. | ||
| 432 | */ | ||
| 433 | if (optchar == (int)'-') | ||
| 434 | return (-1); | ||
| 431 | /* option letter unknown or ':' */ | 435 | /* option letter unknown or ':' */ |
| 432 | if (!*place) | 436 | if (!*place) |
| 433 | ++optind; | 437 | ++optind; |
