support optional-argument extension to getopt via double-colon
this extension is not incompatible with the standard behavior of the function, not expensive, and avoids requiring a replacement getopt with full GNU extensions for a few important apps including busybox's sed with the -i option.
This commit is contained in:
parent
d79b27785f
commit
66fcde4ae4
1 changed files with 5 additions and 2 deletions
|
|
@ -65,8 +65,11 @@ int getopt(int argc, char * const argv[], const char *optstring)
|
||||||
}
|
}
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
optarg = argv[optind++] + optpos;
|
if (optstring[i+2] == ':') optarg = 0;
|
||||||
optpos = 0;
|
if (optstring[i+2] != ':' || optpos) {
|
||||||
|
optarg = argv[optind++] + optpos;
|
||||||
|
optpos = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue