proj: Add optind to getopt
This commit is contained in:
@@ -1226,7 +1226,7 @@ int sym(getopt)(const int argc, char *const argv[], const char *shortopts) {
|
||||
else if_invalid(getopt)
|
||||
}
|
||||
const int ret = __real_getopt(argc, argv, shortopts);
|
||||
msg("return %i", ret);
|
||||
msg("return %i; optind %i", ret, optind);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -344,6 +344,10 @@ class Parser:
|
||||
other_vals = ret[1].strip() if len(ret) > 1 else ''
|
||||
ret_value, _ = Parser.parse_arg(ret[0][7:])
|
||||
kwargs = {}
|
||||
if other_vals.startswith('optind '):
|
||||
ret = other_vals[7:].split(';', 1)
|
||||
kwargs['optind'] = int(ret[0].strip())
|
||||
other_vals = ret[1].strip() if len(ret) > 1 else ''
|
||||
if other_vals.startswith('errno '):
|
||||
ret = other_vals[6:].split(';', 1)
|
||||
kwargs['errno'] = ret[0].strip()
|
||||
@@ -404,7 +408,7 @@ class Parser:
|
||||
def before_getopt(self, argc: int, argv: PointerTo[list[PointerTo[bytes]]], optstring: PointerTo[bytes]) -> str:
|
||||
raise NotImplementedError()
|
||||
def after_getopt(self, argc: int, argv: PointerTo[list[PointerTo[bytes]]], optstring: PointerTo[bytes],
|
||||
ret_value: int) -> None:
|
||||
ret_value: int, optind: int = None) -> None:
|
||||
raise NotImplementedError()
|
||||
def before_exit(self, status: int) -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
Reference in New Issue
Block a user