Getopts bugs again (I'll never get this right).
- make sure that OPTIND is set correctly even in the absence of options. - don't keep stale state between getopts calls.
This commit is contained in:
parent
c5d19fd124
commit
a00e49c200
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: options.c,v 1.20 1996/11/24 20:48:01 christos Exp $ */
|
||||
/* $NetBSD: options.c,v 1.21 1996/12/15 20:37:09 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -40,7 +40,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: options.c,v 1.20 1996/11/24 20:48:01 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: options.c,v 1.21 1996/12/15 20:37:09 christos Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -420,8 +420,9 @@ getopts(optstr, optvar, optfirst, optnext, optptr)
|
|||
p = **optnext;
|
||||
if (p == NULL || *p != '-' || *++p == '\0') {
|
||||
atend:
|
||||
*optnext = NULL;
|
||||
ind = *optnext - optfirst + 1;
|
||||
*optnext = NULL;
|
||||
p = NULL;
|
||||
done = 1;
|
||||
goto out;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue