Преглед на файлове

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.
Rich Felker преди 10 години
родител
ревизия
d4f7d9c46f
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      src/misc/getopt.c

+ 1 - 1
src/misc/getopt.c

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