about summary refs log tree commit diff
path: root/posix/getopt.c
diff options
context:
space:
mode:
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 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] == ':')
       {