Skip to content

Commit

Permalink
Fix optind in getopt on musl libc. On exit optind
Browse files Browse the repository at this point in the history
points to the last non-opt argument of argv, but
in the case where there are only options optind
does not go beyond argc, except on musl libc,
where it becomes argc + 1.
  • Loading branch information
fredrikekre committed May 6, 2019
1 parent 11ce4d1 commit 9de07ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
}
jl_options.code_coverage = codecov;
jl_options.malloc_log = malloclog;
*argvp += optind;
*argcp -= optind;
int proc_args = *argcp < optind ? *argcp : optind;
*argvp += proc_args;
*argcp -= proc_args;
}

JL_DLLEXPORT void jl_set_ARGS(int argc, char **argv)
Expand Down

0 comments on commit 9de07ce

Please sign in to comment.