From 01636b2140cd1281202b89f7103249ed598065c4 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 6 Jul 2011 21:27:14 -0400 Subject: Handle W; without long options in getopt --- posix/getopt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'posix') 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] == ':') { -- cgit 1.4.1