Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jun 2014 21:54:57 +0000 (UTC)
From:      "Andrey A. Chernov" <ache@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267756 - head/lib/libc/stdlib
Message-ID:  <201406222154.s5MLsvkt093218@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ache
Date: Sun Jun 22 21:54:57 2014
New Revision: 267756
URL: http://svnweb.freebsd.org/changeset/base/267756

Log:
  Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
  to reduce diff and bump OpenBSD patch level to v1.26.
  
  MFC after:      2 weeks

Modified:
  head/lib/libc/stdlib/getopt_long.c

Modified: head/lib/libc/stdlib/getopt_long.c
==============================================================================
--- head/lib/libc/stdlib/getopt_long.c	Sun Jun 22 21:37:27 2014	(r267755)
+++ head/lib/libc/stdlib/getopt_long.c	Sun Jun 22 21:54:57 2014	(r267756)
@@ -1,4 +1,4 @@
-/*	$OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $	*/
+/*	$OpenBSD: getopt_long.c,v 1.26 2013/06/08 22:47:56 millert Exp $	*/
 /*	$NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $	*/
 
 /*
@@ -248,7 +248,7 @@ parse_long_options(char * const *nargv, 
 		if (short_too && current_argv_len == 1)
 			continue;
 
-		if (match == -1)        /* first partial match */
+		if (match == -1)	/* first partial match */
 			match = i;
 		else if ((flags & FLAG_LONGONLY) ||
 			 long_options[i].has_arg !=
@@ -359,37 +359,31 @@ getopt_internal(int nargc, char * const 
 {
 	char *oli;				/* option letter list index */
 	int optchar, short_too;
-	int posixly_correct;	/* no static, can be changed on the fly */
+	static int posixly_correct = -1;
 
 	if (options == NULL)
 		return (-1);
 
 	/*
+	 * XXX Some GNU programs (like cvs) set optind to 0 instead of
+	 * XXX using optreset.  Work around this braindamage.
+	 */
+	if (optind == 0)
+		optind = optreset = 1;
+
+	/*
 	 * Disable GNU extensions if POSIXLY_CORRECT is set or options
 	 * string begins with a '+'.
 	 */
-	posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
-#ifdef GNU_COMPATIBLE
+	if (posixly_correct == -1 || optreset)
+		posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
 	if (*options == '-')
 		flags |= FLAG_ALLARGS;
 	else if (posixly_correct || *options == '+')
 		flags &= ~FLAG_PERMUTE;
-#else
-	if (posixly_correct || *options == '+')
-		flags &= ~FLAG_PERMUTE;
-	else if (*options == '-')
-		flags |= FLAG_ALLARGS;
-#endif
 	if (*options == '+' || *options == '-')
 		options++;
 
-	/*
-	 * XXX Some GNU programs (like cvs) set optind to 0 instead of
-	 * XXX using optreset.  Work around this braindamage.
-	 */
-	if (optind == 0)
-		optind = optreset = 1;
-
 	optarg = NULL;
 	if (optreset)
 		nonopt_start = nonopt_end = -1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406222154.s5MLsvkt093218>