diff options
| author | wiz <wiz@NetBSD.org> | 2002-06-13 21:18:50 +0000 |
|---|---|---|
| committer | wiz <wiz@NetBSD.org> | 2002-06-13 21:18:50 +0000 |
| commit | ec1956ee4e12a9e8d2d0c216e5d8ddef70a270bf (patch) | |
| tree | 31d7918d0c88538be196f9fe30d9cedb4580e196 /lib/libc/stdlib | |
| parent | e097b1af53ab759079951b823d50620df7326091 (diff) | |
According to POSIX, "-" (the string) is an exception and should not
be parsed as option. Restore behaviour broken by previous commit.
Mirrors second part of patch from lib/17248.
Diffstat (limited to 'lib/libc/stdlib')
| -rw-r--r-- | lib/libc/stdlib/getopt.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index cde6aec65c8..598647e66d3 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -1,4 +1,4 @@ -/* $NetBSD: getopt.c,v 1.22 2002/06/13 20:49:00 wiz Exp $ */ +/* $NetBSD: getopt.c,v 1.23 2002/06/13 21:18:50 wiz Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: getopt.c,v 1.22 2002/06/13 20:49:00 wiz Exp $"); +__RCSID("$NetBSD: getopt.c,v 1.23 2002/06/13 21:18:50 wiz Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -83,12 +83,12 @@ getopt(nargc, nargv, ostr) if (optreset || !*place) { /* update scanning pointer */ optreset = 0; - if (optind >= nargc || *(place = nargv[optind]) != '-') { + if (optind >= nargc || *(place = nargv[optind]) != '-' + || place[1] == '\0') { place = EMSG; return (-1); } - if (place[1] && *++place == '-' /* found "--" */ - && place[1] == '\0') { + if (*++place == '-' && place[1] == '\0') { /* found "--" */ ++optind; place = EMSG; return (-1); |
