浏览代码

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;