Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib According to POSIX, "-" (the string) is an e...



details:   https://anonhg.NetBSD.org/src/rev/e48c3f491460
branches:  trunk
changeset: 532721:e48c3f491460
user:      wiz <wiz%NetBSD.org@localhost>
date:      Thu Jun 13 21:18:50 2002 +0000

description:
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:

 lib/libc/stdlib/getopt.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r 5b3fcd928cac -r e48c3f491460 lib/libc/stdlib/getopt.c
--- a/lib/libc/stdlib/getopt.c  Thu Jun 13 21:13:03 2002 +0000
+++ b/lib/libc/stdlib/getopt.c  Thu Jun 13 21:18:50 2002 +0000
@@ -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 @@
 
        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);



Home | Main Index | Thread Index | Old Index