This reverts commit 16202e054f0385499ec16463b87e23c97dc02328. Changed win32 build to use ONE_SOURCE just like libtcc.dll Therefore CString can be used again...
Unified · Split
| @@ -35,7 +35,7 @@ static int do_bench = 0; · 34 unmodified lines | ||
| 35 | 35 | static int gen_deps; |
| 36 | 36 | static const char *deps_outfile; |
| 37 | 37 | static const char *m_option; |
| 38 | −static char *linker_arg; | |
| 38 | +static CString linker_arg; | |
| 39 | 39 | |
| 40 | 40 | #define TCC_OPTION_HAS_ARG 0x0001 |
| 41 | 41 | #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 | ||
| 281 | 281 | const char *optarg, *p1, *r1; |
| 282 | 282 | char *r; |
| 283 | 283 | int was_pthread; |
| 284 | − unsigned long linker_argsize = 0; | |
| 285 | 284 | |
| 286 | 285 | was_pthread = 0; /* is set if commandline contains -pthread key */ |
| 287 | 286 | |
| 288 | 287 | optind = 1; |
| 288 | + cstr_new(&linker_arg); | |
| 289 | 289 | while (optind < argc) { |
| 290 | 290 | |
| 291 | 291 | r = argv[optind++]; |
| @@ -444,16 +444,11 @@ static int parse_args(TCCState *s, int argc, char **argv) · 152 unmodified lines | ||
| 444 | 444 | s->rdynamic = 1; |
| 445 | 445 | break; |
| 446 | 446 | 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); | |
| 452 | 449 | 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); | |
| 457 | 452 | } |
| 458 | 453 | break; |
| 459 | 454 | case TCC_OPTION_E: |
| @@ -476,7 +471,7 @@ static int parse_args(TCCState *s, int argc, char **argv) · 16 unmodified lines | ||
| 476 | 471 | } |
| 477 | 472 | } |
| 478 | 473 | } |
| 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))) | |
| 480 | 475 | tcc_error("unsupported linker option '%s'", r); |
| 481 | 476 | /* fixme: these options could be different on your platform */ |
| 482 | 477 | if (was_pthread && output_type != TCC_OUTPUT_OBJ) { |
| @@ -610,7 +605,7 @@ int main(int argc, char **argv) · 127 unmodified lines | ||
| 610 | 605 | } |
| 611 | 606 | |
| 612 | 607 | tcc_delete(s); |
| 613 | − tcc_free(linker_arg); | |
| 608 | + cstr_free(&linker_arg); | |
| 614 | 609 | tcc_free(outfile); |
| 615 | 610 | |
| 616 | 611 | #ifdef MEM_DEBUG |
| @@ -34,7 +34,7 @@ copy ..\libtcc.h libtcc\libtcc.h · 33 unmodified lines | ||
| 34 | 34 | tiny_impdef libtcc.dll -o lib/libtcc.def |
| 35 | 35 | |
| 36 | 36 | :tcc |
| 37 | −%CC% %target% ../tcc.c -o tcc.exe -ltcc -Llibtcc | |
| 37 | +%CC% %target% -DONE_SOURCE ../tcc.c -o tcc.exe -ltcc -Llibtcc | |
| 38 | 38 | |
| 39 | 39 | :copy_std_includes |
| 40 | 40 | copy ..\include\*.h include |