maint.mk: avoid sc_prohibit_always-defined_macros failure in coreutils
[gnulib.git] / lib / getopt.c
index ee96d97..7c9f704 100644 (file)
@@ -488,7 +488,6 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
         struct option_list *next;
       } *ambig_list = NULL;
       int exact = 0;
-      int ambig = 0;
       int indfound = -1;
       int option_index;
 
@@ -840,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')
           {
@@ -1047,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] == ':')
       {