tcc.c: fix argv index for parse_args

I probably broke that myself earlier.  In any case parse_args
needs to start with index 0 because it is is used also recursively
to expand the shebang command from scripts such as
    #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
which arrives at tcc as only two argv's
    "tcc" "-run -L/usr/X11R6/lib -lX11"
This commit is contained in:
grischka 2012-05-13 10:21:39 +02:00
parent 32cd070c96
commit 27d38bf23f

6
tcc.c
View File

@ -283,7 +283,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
int was_pthread;
was_pthread = 0; /* is set if commandline contains -pthread key */
optind = 1;
optind = 0;
cstr_new(&linker_arg);
while (optind < argc) {
@ -500,7 +500,7 @@ int main(int argc, char **argv)
m_option = NULL;
ret = 0;
optind = parse_args(s, argc, argv);
optind = parse_args(s, argc - 1, argv + 1);
#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386
if (m_option)
@ -585,7 +585,7 @@ int main(int argc, char **argv)
if (s->output_type == TCC_OUTPUT_MEMORY) {
#ifdef TCC_IS_NATIVE
ret = tcc_run(s, argc - optind, argv + optind);
ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);
#else
tcc_error_noabort("-run is not available in a cross compiler");
#endif