mirror of
git://git.musl-libc.org/musl
synced 2025-01-27 09:03:59 +00:00
simplify part of getopt_long
as a result of commit e8e4e56a8c
,
the later code path for setting optarg to a null pointer is no longer
necessary, and removing it eliminates an indention level and arguably
makes the code more readable.
This commit is contained in:
parent
e8e4e56a8c
commit
63cac4e29a
@ -87,19 +87,17 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
|
||||
return '?';
|
||||
}
|
||||
optarg = opt+1;
|
||||
} else {
|
||||
if (longopts[i].has_arg == required_argument) {
|
||||
if (!(optarg = argv[optind])) {
|
||||
if (colon) return ':';
|
||||
if (!opterr) return '?';
|
||||
__getopt_msg(argv[0],
|
||||
": option requires an argument: ",
|
||||
longopts[i].name,
|
||||
strlen(longopts[i].name));
|
||||
return '?';
|
||||
}
|
||||
optind++;
|
||||
} else optarg = NULL;
|
||||
} else if (longopts[i].has_arg == required_argument) {
|
||||
if (!(optarg = argv[optind])) {
|
||||
if (colon) return ':';
|
||||
if (!opterr) return '?';
|
||||
__getopt_msg(argv[0],
|
||||
": option requires an argument: ",
|
||||
longopts[i].name,
|
||||
strlen(longopts[i].name));
|
||||
return '?';
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
if (idx) *idx = i;
|
||||
if (longopts[i].flag) {
|
||||
|
Loading…
Reference in New Issue
Block a user