fix getopt handling of initial '+' in optstring

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.
This commit is contained in:
Rich Felker 2014-12-10 21:29:01 -05:00
parent cfd7b4acd5
commit d4f7d9c46f

View 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;