summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/getopt_long.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-12-10 17:51:42 +0000
committermillert <millert@openbsd.org>2002-12-10 17:51:42 +0000
commitddcd292385a00e0cc2d9818c2ae4ae3209101833 (patch)
tree53e554763fb64ad76d0efd73875cc25b3a918206 /lib/libc/stdlib/getopt_long.c
parentpower plant day moves back to the 22 from sun+3; from form@ the powermaker (diff)
downloadwireguard-openbsd-ddcd292385a00e0cc2d9818c2ae4ae3209101833.tar.xz
wireguard-openbsd-ddcd292385a00e0cc2d9818c2ae4ae3209101833.zip
When doing permutation, only treat "-" as an option if it was specified
in optstring. Problem noticed by Theo.
Diffstat (limited to 'lib/libc/stdlib/getopt_long.c')
-rw-r--r--lib/libc/stdlib/getopt_long.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c
index 413ec24f4e4..0cdc4d652f0 100644
--- a/lib/libc/stdlib/getopt_long.c
+++ b/lib/libc/stdlib/getopt_long.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getopt_long.c,v 1.10 2002/12/08 17:52:26 millert Exp $ */
+/* $OpenBSD: getopt_long.c,v 1.11 2002/12/10 17:51:42 millert Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
@@ -64,7 +64,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: getopt_long.c,v 1.10 2002/12/08 17:52:26 millert Exp $";
+static char *rcsid = "$OpenBSD: getopt_long.c,v 1.11 2002/12/10 17:51:42 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <err.h>
@@ -348,8 +348,9 @@ start:
nonopt_start = nonopt_end = -1;
return (-1);
}
- if (*(place = nargv[optind]) != '-') { /* found non-option */
- place = EMSG;
+ if (*(place = nargv[optind]) != '-' ||
+ (place[1] == '\0' && strchr(options, '-') == NULL)) {
+ place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
* GNU extension: