History

Re-enable "Use CString to concat linker options"

This reverts commit 16202e054f0385499ec16463b87e23c97dc02328. Changed win32 build to use ONE_SOURCE just like libtcc.dll Therefore CString can be used again...

Gabriel Corneanu committed 14 years ago

Commit 214564b1 parent 176876e2 files · +9 −14Browse files

Unified · Split

2 files
  1. tcc.c +8 −13
  2. win32/build-tcc.bat +1 −1
tcc.c+8−13
@@ -35,7 +35,7 @@ static int do_bench = 0; · 34 unmodified lines
3535 static int gen_deps;
3636 static const char *deps_outfile;
3737 static const char *m_option;
38−static char *linker_arg;
38+static CString linker_arg;
3939
4040 #define TCC_OPTION_HAS_ARG 0x0001
4141 #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) · 239 unmodified lines
281281 const char *optarg, *p1, *r1;
282282 char *r;
283283 int was_pthread;
284− unsigned long linker_argsize = 0;
285284
286285 was_pthread = 0; /* is set if commandline contains -pthread key */
287286
288287 optind = 1;
288+ cstr_new(&linker_arg);
289289 while (optind < argc) {
290290
291291 r = argv[optind++];
@@ -444,16 +444,11 @@ static int parse_args(TCCState *s, int argc, char **argv) · 152 unmodified lines
444444 s->rdynamic = 1;
445445 break;
446446 case TCC_OPTION_Wl:
447− if (!linker_arg) {
448− linker_argsize = strlen(optarg) + 1;
449− linker_arg = tcc_malloc(linker_argsize);
450− pstrcpy(linker_arg, linker_argsize, optarg);
451− }
447+ if (!linker_arg.data_allocated)
448+ cstr_cat(&linker_arg, optarg);
452449 else {
453− linker_argsize += strlen(optarg) + 1;
454− linker_arg = tcc_realloc(linker_arg, linker_argsize);
455− pstrcat(linker_arg, linker_argsize, ",");
456− pstrcat(linker_arg, linker_argsize, optarg);
450+ cstr_ccat(&linker_arg, ',');
451+ cstr_cat(&linker_arg, optarg);
457452 }
458453 break;
459454 case TCC_OPTION_E:
@@ -476,7 +471,7 @@ static int parse_args(TCCState *s, int argc, char **argv) · 16 unmodified lines
476471 }
477472 }
478473 }
479− if ((r = (char *) tcc_set_linker(s, (char *)linker_arg, TRUE)))
474+ if ((r = (char *) tcc_set_linker(s, (char *) linker_arg.data, TRUE)))
480475 tcc_error("unsupported linker option '%s'", r);
481476 /* fixme: these options could be different on your platform */
482477 if (was_pthread && output_type != TCC_OUTPUT_OBJ) {
@@ -610,7 +605,7 @@ int main(int argc, char **argv) · 127 unmodified lines
610605 }
611606
612607 tcc_delete(s);
613− tcc_free(linker_arg);
608+ cstr_free(&linker_arg);
614609 tcc_free(outfile);
615610
616611 #ifdef MEM_DEBUG
win32/build-tcc.bat+1−1
@@ -34,7 +34,7 @@ copy ..\libtcc.h libtcc\libtcc.h · 33 unmodified lines
3434 tiny_impdef libtcc.dll -o lib/libtcc.def
3535
3636 :tcc
37−%CC% %target% ../tcc.c -o tcc.exe -ltcc -Llibtcc
37+%CC% %target% -DONE_SOURCE ../tcc.c -o tcc.exe -ltcc -Llibtcc
3838
3939 :copy_std_includes
4040 copy ..\include\*.h include

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t