Keep it sync with OpenBSD:

An optional argument cannot start with '-', even if permutation is
disabled.

Obtained from: OpenBSD getopt_long.c v1.17
This commit is contained in:
Andrey A. Chernov 2004-07-06 13:58:45 +00:00
parent cef9241945
commit 42aeacc4d4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131710

View file

@ -1,4 +1,4 @@
/* $OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $ */
/* $OpenBSD: getopt_long.c,v 1.17 2004/06/03 18:46:52 millert Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
@ -571,9 +571,10 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
} else if (!(flags & FLAG_PERMUTE)) {
/*
* If permutation is disabled, we can accept an
* optional arg separated by whitespace.
* optional arg separated by whitespace so long
* as it does not start with a dash (-).
*/
if (optind + 1 < nargc)
if (optind + 1 < nargc && *nargv[optind + 1] != '-')
optarg = nargv[++optind];
}
place = EMSG;