options/glibc: Impl. long opts with optional args
This commit is contained in:
parent
bbd2ca1e91
commit
ddf5d1c2a2
|
@ -76,6 +76,16 @@ int getopt_long(int argc, char * const argv[], const char *optstring,
|
|||
fprintf(stderr, "--%s requires an argument.\n", arg);
|
||||
return '?';
|
||||
}
|
||||
}else if(longopts[k].has_arg == optional_argument) {
|
||||
if(s) {
|
||||
// Consume the long option and its argument.
|
||||
optarg = s + 1;
|
||||
optind++;
|
||||
}else{
|
||||
// Consume the long option.
|
||||
optarg = nullptr;
|
||||
optind++;
|
||||
}
|
||||
}else{
|
||||
__ensure(longopts[k].has_arg == no_argument);
|
||||
|
||||
|
|
Loading…
Reference in a new issue