aboutsummaryrefslogtreecommitdiffstats
path: root/lib/getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/getopt.c')
-rw-r--r--lib/getopt.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/getopt.c b/lib/getopt.c
index 2af8352ee9c..7c9f7040612 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
829 return '?'; 829 return '?';
830 } 830 }
831 /* Convenience. Treat POSIX -W foo same as long option --foo */ 831 /* Convenience. Treat POSIX -W foo same as long option --foo */
832 if (temp[0] == 'W' && temp[1] == ';' && longopts) 832 if (temp[0] == 'W' && temp[1] == ';')
833 { 833 {
834 char *nameend; 834 char *nameend;
835 const struct option *p; 835 const struct option *p;
@@ -839,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
839 int indfound = 0; 839 int indfound = 0;
840 int option_index; 840 int option_index;
841 841
842 if (longopts == NULL)
843 goto no_longs;
844
842 /* This is an option that requires an argument. */ 845 /* This is an option that requires an argument. */
843 if (*d->__nextchar != '\0') 846 if (*d->__nextchar != '\0')
844 { 847 {
@@ -1046,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
1046 } 1049 }
1047 return pfound->val; 1050 return pfound->val;
1048 } 1051 }
1049 d->__nextchar = NULL; 1052
1050 return 'W'; /* Let the application handle it. */ 1053 no_longs:
1054 d->__nextchar = NULL;
1055 return 'W'; /* Let the application handle it. */
1051 } 1056 }
1052 if (temp[1] == ':') 1057 if (temp[1] == ':')
1053 { 1058 {