aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2012-04-10 16:33:39 +0200
committerThomas Preud'homme <robotux@celest.fr>2012-04-10 16:33:39 +0200
commit16202e054f0385499ec16463b87e23c97dc02328 (patch)
treea2cebb39739a66ea704183bc56fa84732a078528
parent1c11b857fe87a73d7047701dacdbe8394967b1d1 (diff)
downloadtinycc-16202e054f0385499ec16463b87e23c97dc02328.tar.gz
tinycc-16202e054f0385499ec16463b87e23c97dc02328.tar.bz2
Revert "Use CString to concat linker options"
This reverts commit 1c11b857fe87a73d7047701dacdbe8394967b1d1. On windows, libtcc.c is compiled with ONE_SOURCE and then tcc.c is linked to it. Thus tcc.c can only use public functions which cstr_* are not.
-rw-r--r--tcc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/tcc.c b/tcc.c
index 9f1f7c0..467ef88 100644
--- a/tcc.c
+++ b/tcc.c
@@ -35,7 +35,7 @@ static int do_bench = 0;
static int gen_deps;
static const char *deps_outfile;
static const char *m_option;
-static CString linker_arg;
+static char *linker_arg;
#define TCC_OPTION_HAS_ARG 0x0001
#define TCC_OPTION_NOSEP 0x0002 /* cannot have space before option and arg */
@@ -281,11 +281,11 @@ static int parse_args(TCCState *s, int argc, char **argv)
const char *optarg, *p1, *r1;
char *r;
int was_pthread;
+ unsigned long linker_argsize = 0;
was_pthread = 0; /* is set if commandline contains -pthread key */
optind = 1;
- cstr_new(&linker_arg);
while (optind < argc) {
r = argv[optind++];
@@ -444,11 +444,16 @@ 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);
+ if (!linker_arg) {
+ linker_argsize = strlen(optarg) + 1;
+ linker_arg = tcc_malloc(linker_argsize);
+ pstrcpy(linker_arg, linker_argsize, optarg);
+ }
else {
- cstr_ccat(&linker_arg, ',');
- cstr_cat(&linker_arg, optarg);
+ linker_argsize += strlen(optarg) + 1;
+ linker_arg = tcc_realloc(linker_arg, linker_argsize);
+ pstrcat(linker_arg, linker_argsize, ",");
+ pstrcat(linker_arg, linker_argsize, optarg);
}
break;
case TCC_OPTION_E:
@@ -471,7 +476,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
}
}
}
- if ((r = (char *) tcc_set_linker(s, (char *) linker_arg.data, TRUE)))
+ if ((r = (char *) tcc_set_linker(s, (char *)linker_arg, TRUE)))
tcc_error("unsupported linker option '%s'", r);
/* fixme: these options could be different on your platform */
if (was_pthread && output_type != TCC_OUTPUT_OBJ) {
@@ -605,7 +610,7 @@ int main(int argc, char **argv)
}
tcc_delete(s);
- cstr_free(&linker_arg);
+ tcc_free(linker_arg);
tcc_free(outfile);
#ifdef MEM_DEBUG