Handle getopt reinitialization

This commit is contained in:
Tibor Nagy
2018-10-28 19:59:08 +01:00
parent 740f57738c
commit f97f93c48d
+6
View File
@@ -30,6 +30,12 @@ pub unsafe extern "C" fn getopt_long(
// if optarg is not set, we still don't want the previous value leaking
optarg = ptr::null_mut();
// handle reinitialization request
if optind == 0 {
optind = 1;
CURRENT_OPT = ptr::null_mut();
}
if CURRENT_OPT.is_null() || *CURRENT_OPT == 0 {
if optind >= argc {
-1