Skip to content
Snippets Groups Projects
Commit 51b2e630 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'optind-reset' into 'master'

Handle getopt reinitialization

See merge request !174
parents 740f5773 f97f93c4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment