summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/getopt_long.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/getopt_long.c')
-rw-r--r--src/lib/libc/stdlib/getopt_long.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/libc/stdlib/getopt_long.c b/src/lib/libc/stdlib/getopt_long.c
index eb1e3ef4be..e149fe0ace 100644
--- a/src/lib/libc/stdlib/getopt_long.c
+++ b/src/lib/libc/stdlib/getopt_long.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getopt_long.c,v 1.24 2010/07/22 19:31:53 blambert Exp $ */ 1/* $OpenBSD: getopt_long.c,v 1.25 2011/03/05 22:10:11 guenther Exp $ */
2/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ 2/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
3 3
4/* 4/*
@@ -285,25 +285,25 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
285 return (-1); 285 return (-1);
286 286
287 /* 287 /*
288 * XXX Some GNU programs (like cvs) set optind to 0 instead of
289 * XXX using optreset. Work around this braindamage.
290 */
291 if (optind == 0)
292 optind = optreset = 1;
293
294 /*
288 * Disable GNU extensions if POSIXLY_CORRECT is set or options 295 * Disable GNU extensions if POSIXLY_CORRECT is set or options
289 * string begins with a '+'. 296 * string begins with a '+'.
290 */ 297 */
291 if (posixly_correct == -1) 298 if (posixly_correct == -1 || optreset)
292 posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); 299 posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
293 if (posixly_correct || *options == '+') 300 if (*options == '-')
294 flags &= ~FLAG_PERMUTE;
295 else if (*options == '-')
296 flags |= FLAG_ALLARGS; 301 flags |= FLAG_ALLARGS;
302 else if (posixly_correct || *options == '+')
303 flags &= ~FLAG_PERMUTE;
297 if (*options == '+' || *options == '-') 304 if (*options == '+' || *options == '-')
298 options++; 305 options++;
299 306
300 /*
301 * XXX Some GNU programs (like cvs) set optind to 0 instead of
302 * XXX using optreset. Work around this braindamage.
303 */
304 if (optind == 0)
305 optind = optreset = 1;
306
307 optarg = NULL; 307 optarg = NULL;
308 if (optreset) 308 if (optreset)
309 nonopt_start = nonopt_end = -1; 309 nonopt_start = nonopt_end = -1;