tcc -run file.c : pass original exit code from file.c again
when there are no other errors then exit tcc with the exit cude
from tcc_run() (messed up in dd2e5f8b06
)
Also in tccrun.c, use a more exotic random value to replace zero
with 'exit(0)' in user code (because lonhjmp(jb, c) needs c != 0)
This commit is contained in:
parent
b776bfaa53
commit
8620a312b2
2 changed files with 14 additions and 7 deletions
15
tcc.c
15
tcc.c
|
@ -378,8 +378,9 @@ redo:
|
||||||
first_file = f->name;
|
first_file = f->name;
|
||||||
ret = tcc_add_file(s, f->name);
|
ret = tcc_add_file(s, f->name);
|
||||||
}
|
}
|
||||||
done = ret || ++n >= s->nb_files;
|
} while (++n < s->nb_files
|
||||||
} while (!done && (s->output_type != TCC_OUTPUT_OBJ || s->option_r));
|
&& 0 == ret
|
||||||
|
&& (s->output_type != TCC_OUTPUT_OBJ || s->option_r));
|
||||||
|
|
||||||
if (s->do_bench)
|
if (s->do_bench)
|
||||||
end_time = getclock_ms();
|
end_time = getclock_ms();
|
||||||
|
@ -406,13 +407,17 @@ redo:
|
||||||
done = 1;
|
done = 1;
|
||||||
if (t)
|
if (t)
|
||||||
done = 0; /* run more tests with -dt -run */
|
done = 0; /* run more tests with -dt -run */
|
||||||
else if (ret)
|
else if (ret) {
|
||||||
ret = 1;
|
if (s->nb_errors)
|
||||||
else if (n < s->nb_files)
|
ret = 1;
|
||||||
|
/* else keep the original exit code from tcc_run() */
|
||||||
|
} else if (n < s->nb_files)
|
||||||
done = 0; /* compile more files with -c */
|
done = 0; /* compile more files with -c */
|
||||||
else if (s->do_bench)
|
else if (s->do_bench)
|
||||||
tcc_print_stats(s, end_time - start_time);
|
tcc_print_stats(s, end_time - start_time);
|
||||||
|
|
||||||
tcc_delete(s);
|
tcc_delete(s);
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
goto redo;
|
goto redo;
|
||||||
if (ppfp && ppfp != stdout)
|
if (ppfp && ppfp != stdout)
|
||||||
|
|
6
tccrun.c
6
tccrun.c
|
@ -197,6 +197,8 @@ ST_FUNC void tcc_run_free(TCCState *s1)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RT_EXIT_ZERO 0xE0E00E0E /* passed from longjmp instead of '0' */
|
||||||
|
|
||||||
/* launch the compiled program with the given arguments */
|
/* launch the compiled program with the given arguments */
|
||||||
LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
|
LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -238,7 +240,7 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
|
||||||
ret = tcc_setjmp(s1, main_jb, tcc_get_symbol(s1, top_sym));
|
ret = tcc_setjmp(s1, main_jb, tcc_get_symbol(s1, top_sym));
|
||||||
if (0 == ret)
|
if (0 == ret)
|
||||||
ret = prog_main(argc, argv, envp);
|
ret = prog_main(argc, argv, envp);
|
||||||
else if (256 == ret)
|
else if (RT_EXIT_ZERO == ret)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if (s1->dflag & 16 && ret) /* tcc -dt -run ... */
|
if (s1->dflag & 16 && ret) /* tcc -dt -run ... */
|
||||||
|
@ -596,7 +598,7 @@ static void rt_exit(rt_frame *f, int code)
|
||||||
rt_post_sem();
|
rt_post_sem();
|
||||||
if (s && s->run_lj) {
|
if (s && s->run_lj) {
|
||||||
if (code == 0)
|
if (code == 0)
|
||||||
code = 256;
|
code = RT_EXIT_ZERO;
|
||||||
((void(*)(void*,int))s->run_lj)(s->run_jb, code);
|
((void(*)(void*,int))s->run_lj)(s->run_jb, code);
|
||||||
}
|
}
|
||||||
exit(code);
|
exit(code);
|
||||||
|
|
Loading…
Add table
Reference in a new issue