提交 b4ef1830 编写于 作者: R Rich Felker

accept null longopts pointer in getopt_long

this is an undocumented feature of GNU getopt_long that the BSD
version also mimics, and is reportedly needed by some programs.
上级 d4f7d9c4
......@@ -52,7 +52,7 @@ static int __getopt_long(int argc, char *const *argv, const char *optstring, con
static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly)
{
if (argv[optind][0] == '-' &&
if (longopts && argv[optind][0] == '-' &&
((longonly && argv[optind][1]) ||
(argv[optind][1] == '-' && argv[optind][2])))
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册