From: Ulrich Drepper Date: Thu, 7 Jul 2011 01:27:14 +0000 (-0400) Subject: Handle W; without long options in getopt X-Git-Tag: glibc-2.14.1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77b2540f78e4c97ffded2c0600012cc48c4670fd;p=thirdparty%2Fglibc.git Handle W; without long options in getopt (cherry picked from commit 01636b2140cd1281202b89f7103249ed598065c4) --- diff --git a/ChangeLog b/ChangeLog index b11f5ee012e..4d7e1ba669b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-07-06 Ulrich Drepper + + [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 [BZ #9696] diff --git a/posix/getopt.c b/posix/getopt.c index db89abf6a74..3fa5a4d6d1f 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] == ':') {