From 4274c44de7dfb99a1058a5af515e9865cc9d2ff9 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 18 Apr 2012 18:32:37 +0200 Subject: tcc.c: fix previous commit "Use CString to concat linker options" - remove redunant else branch - zero-terminate linker_arg - declare cstr_xxx as PUB_FUNC (which are functions used in tcc.c but not in the libtcc API. Useful for a tcc(.exe) that uses the libtcc.(so/dll)) - while at it, export PUB_FUNCs from dll --- tcc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tcc.c') diff --git a/tcc.c b/tcc.c index 9f1f7c0..06c6155 100644 --- a/tcc.c +++ b/tcc.c @@ -283,9 +283,9 @@ 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; cstr_new(&linker_arg); + while (optind < argc) { r = argv[optind++]; @@ -444,12 +444,10 @@ static int parse_args(TCCState *s, int argc, char **argv) s->rdynamic = 1; break; case TCC_OPTION_Wl: - if (!linker_arg.data_allocated) - cstr_cat(&linker_arg, optarg); - else { - cstr_ccat(&linker_arg, ','); - cstr_cat(&linker_arg, optarg); - } + if (linker_arg.size) + --linker_arg.size, cstr_ccat(&linker_arg, ','); + cstr_cat(&linker_arg, optarg); + cstr_ccat(&linker_arg, '\0'); break; case TCC_OPTION_E: output_type = TCC_OUTPUT_PREPROCESS; @@ -471,8 +469,8 @@ static int parse_args(TCCState *s, int argc, char **argv) } } } - if ((r = (char *) tcc_set_linker(s, (char *) linker_arg.data, TRUE))) - tcc_error("unsupported linker option '%s'", r); + if (NULL != (r1 = tcc_set_linker(s, (char *) linker_arg.data, TRUE))) + tcc_error("unsupported linker option '%s'", r1); /* fixme: these options could be different on your platform */ if (was_pthread && output_type != TCC_OUTPUT_OBJ) { dynarray_add((void ***)&files, &nb_files, "-lpthread"); -- cgit v1.3.1