fix getopt handling of initial '+' in optstring
authorRich Felker <dalias@aerifal.cx>
Thu, 11 Dec 2014 02:29:01 +0000 (21:29 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 11 Dec 2014 02:29:01 +0000 (21:29 -0500)
in the case where an initial '+' was passed in optstring (a
getopt_long feature to suppress argv permutation), getopt would fail
to see a possible subsequent ':', resulting in incorrect handling of
missing arguments.

src/misc/getopt.c

index 52aa7a3..e77e460 100644 (file)
@@ -55,7 +55,7 @@ int getopt(int argc, char * const argv[], const char *optstring)
                optpos = 0;
        }
 
-       if (optstring[0] == '-')
+       if (optstring[0] == '-' || optstring[0] == '+')
                optstring++;
 
        i = 0;