diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/getopt.c | 5 | ||||
| -rw-r--r-- | src/lib/libc/stdlib/getopt_long.c | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/getopt.c b/src/lib/libc/stdlib/getopt.c index b7f6163662..218887dd32 100644 --- a/src/lib/libc/stdlib/getopt.c +++ b/src/lib/libc/stdlib/getopt.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $"; | 35 | static char *rcsid = "$OpenBSD: getopt.c,v 1.3 2002/12/08 17:52:26 millert Exp $"; |
| 36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
| 37 | 37 | ||
| 38 | #include <stdio.h> | 38 | #include <stdio.h> |
| @@ -63,6 +63,9 @@ getopt(nargc, nargv, ostr) | |||
| 63 | static char *place = EMSG; /* option letter processing */ | 63 | static char *place = EMSG; /* option letter processing */ |
| 64 | char *oli; /* option letter list index */ | 64 | char *oli; /* option letter list index */ |
| 65 | 65 | ||
| 66 | if (options == NULL) | ||
| 67 | return (-1); | ||
| 68 | |||
| 66 | if (optreset || !*place) { /* update scanning pointer */ | 69 | if (optreset || !*place) { /* update scanning pointer */ |
| 67 | optreset = 0; | 70 | optreset = 0; |
| 68 | if (optind >= nargc || *(place = nargv[optind]) != '-') { | 71 | if (optind >= nargc || *(place = nargv[optind]) != '-') { |
diff --git a/src/lib/libc/stdlib/getopt_long.c b/src/lib/libc/stdlib/getopt_long.c index 176ba25bb7..413ec24f4e 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.9 2002/12/08 17:07:46 millert Exp $ */ | 1 | /* $OpenBSD: getopt_long.c,v 1.10 2002/12/08 17:52:26 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.9 2002/12/08 17:07:46 millert Exp $"; | 67 | static char *rcsid = "$OpenBSD: getopt_long.c,v 1.10 2002/12/08 17:52:26 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> |
| @@ -301,7 +301,8 @@ getopt_internal(int nargc, char * const *nargv, const char *options, | |||
| 301 | int optchar, short_too; | 301 | int optchar, short_too; |
| 302 | static int posixly_correct = -1; | 302 | static int posixly_correct = -1; |
| 303 | 303 | ||
| 304 | optarg = NULL; | 304 | if (options == NULL) |
| 305 | return (-1); | ||
| 305 | 306 | ||
| 306 | /* | 307 | /* |
| 307 | * Disable GNU extensions if POSIXLY_CORRECT is set or options | 308 | * Disable GNU extensions if POSIXLY_CORRECT is set or options |
| @@ -323,6 +324,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options, | |||
| 323 | if (optind == 0) | 324 | if (optind == 0) |
| 324 | optind = optreset = 1; | 325 | optind = optreset = 1; |
| 325 | 326 | ||
| 327 | optarg = NULL; | ||
| 326 | if (optreset) | 328 | if (optreset) |
| 327 | nonopt_start = nonopt_end = -1; | 329 | nonopt_start = nonopt_end = -1; |
| 328 | start: | 330 | start: |
