about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-06 21:27:14 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-06 21:27:14 -0400
commit01636b2140cd1281202b89f7103249ed598065c4 (patch)
treee375999db321c26fc21346185e3a152f87332d4a
parent9895c8bc62759a2d7abf95654fb2aefe5677a930 (diff)
downloadglibc-01636b2140cd1281202b89f7103249ed598065c4.tar.gz
glibc-01636b2140cd1281202b89f7103249ed598065c4.tar.xz
glibc-01636b2140cd1281202b89f7103249ed598065c4.zip
Handle W; without long options in getopt
-rw-r--r--ChangeLog6
-rw-r--r--NEWS2
-rw-r--r--posix/getopt.c9
3 files changed, 14 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 547cd4edcf..6ac3ae0b89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-07-06  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12922]
+	* posix/getopt.c (_getopt_internal_r): When "W;" is in short options
+	but no long options are defined, just return 'W'.
+
 2011-06-22  Marek Polacek  <mpolacek@redhat.com>
 
 	[BZ #9696]
diff --git a/NEWS b/NEWS
index 1e1e220ab6..dd5565fd54 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Version 2.15
 
 * The following bugs are resolved with this release:
 
-  9696, 12874, 12885, 12907, 12935
+  9696, 12874, 12885, 12907, 12922, 12935
 
 * New program pldd to list loaded object of a process
   Implemented by Ulrich Drepper.
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] == ':')
       {