about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-06 21:27:14 -0400
committerAndreas Schwab <schwab@redhat.com>2011-07-21 12:17:04 +0200
commit77b2540f78e4c97ffded2c0600012cc48c4670fd (patch)
tree717bf5fdb7efbbea2c9cee806745ab805aef0a22 /posix
parentaf6207d5391d434d6f2951da4c8f57d1f3a2a762 (diff)
downloadglibc-77b2540f78e4c97ffded2c0600012cc48c4670fd.tar.gz
glibc-77b2540f78e4c97ffded2c0600012cc48c4670fd.tar.xz
glibc-77b2540f78e4c97ffded2c0600012cc48c4670fd.zip
Handle W; without long options in getopt
(cherry picked from commit 01636b2140cd1281202b89f7103249ed598065c4)
Diffstat (limited to 'posix')
-rw-r--r--posix/getopt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/posix/getopt.c b/posix/getopt.c
index db89abf6a7..3fa5a4d6d1 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -871,6 +871,9 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
     /* Convenience. Treat POSIX -W foo same as long option --foo */
     if (temp[0] == 'W' && temp[1] == ';')
       {
+	if (longopts == NULL)
+	  goto no_longs;
+
 	char *nameend;
 	const struct option *p;
 	const struct option *pfound = NULL;
@@ -1086,8 +1089,10 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
 	      }
 	    return pfound->val;
 	  }
-	  d->__nextchar = NULL;
-	  return 'W';	/* Let the application handle it.   */
+
+      no_longs:
+	d->__nextchar = NULL;
+	return 'W';	/* Let the application handle it.   */
       }
     if (temp[1] == ':')
       {