diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-07-08 03:00:52 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-07-08 03:00:52 -0700 |
commit | 4a621aae149e694c8a53bebcc593d51811f69444 (patch) | |
tree | 98f8469d3d5a2daff773ca7431f93c59061dc440 /lib/getopt.c | |
parent | 354cf0ba0b20108c9776be1d868458893bc2cd54 (diff) | |
download | emacs-4a621aae149e694c8a53bebcc593d51811f69444.tar.gz |
* lib/getopt.c, lib/unistd.in.h, m4/getopt.m4: Merge from gnulib.
Diffstat (limited to 'lib/getopt.c')
-rw-r--r-- | lib/getopt.c | 11 |
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, return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';' && longopts) + if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; @@ -839,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int indfound = 0; int option_index; + if (longopts == NULL) + goto no_longs; + /* This is an option that requires an argument. */ if (*d->__nextchar != '\0') { @@ -1046,8 +1049,10 @@ _getopt_internal_r (int argc, char **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] == ':') { |