From 27d38bf23f74d342a2b2c2065a72727c0d0d5e0d Mon Sep 17 00:00:00 2001 From: grischka Date: Sun, 13 May 2012 10:21:39 +0200 Subject: [PATCH] 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" --- tcc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcc.c b/tcc.c index 06c61558..5dd5725c 100644 --- a/tcc.c +++ b/tcc.c @@ -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 -- 2.11.4.GIT