aboutsummaryrefslogtreecommitdiff
path: root/posix/getopt.c
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 /posix/getopt.c
parent9895c8bc62759a2d7abf95654fb2aefe5677a930 (diff)
downloadglibc-01636b2140cd1281202b89f7103249ed598065c4.zip
glibc-01636b2140cd1281202b89f7103249ed598065c4.tar.gz
glibc-01636b2140cd1281202b89f7103249ed598065c4.tar.bz2
Handle W; without long options in getopt
Diffstat (limited to 'posix/getopt.c')
-rw-r--r--posix/getopt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/posix/getopt.c b/posix/getopt.c
index db89abf..3fa5a4d 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] == ':')
{