summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/getopt.c')
-rw-r--r--src/lib/libc/stdlib/getopt.c5
1 files changed, 4 insertions, 1 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)
35static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $"; 35static 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]) != '-') {