Browse Source

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.
master
Rich Felker 11 years ago
parent
commit
63cac4e29a
  1. 4
      src/misc/getopt_long.c

4
src/misc/getopt_long.c

@ -87,8 +87,7 @@ 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) {
} else if (longopts[i].has_arg == required_argument) {
if (!(optarg = argv[optind])) {
if (colon) return ':';
if (!opterr) return '?';
@ -99,7 +98,6 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
return '?';
}
optind++;
} else optarg = NULL;
}
if (idx) *idx = i;
if (longopts[i].flag) {

Loading…
Cancel
Save