- 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
Unified · Split
| @@ -283,9 +283,9 @@ static int parse_args(TCCState *s, int argc, char **argv) · 282 unmodified lines | ||
| 283 | 283 | int was_pthread; |
| 284 | 284 | |
| 285 | 285 | was_pthread = 0; /* is set if commandline contains -pthread key */ |
| 286 | − | |
| 287 | 286 | optind = 1; |
| 288 | 287 | cstr_new(&linker_arg); |
| 288 | + | |
| 289 | 289 | while (optind < argc) { |
| 290 | 290 | |
| 291 | 291 | r = argv[optind++]; |
| @@ -444,12 +444,10 @@ 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.data_allocated) | |
| 448 | − cstr_cat(&linker_arg, optarg); | |
| 449 | − else { | |
| 450 | − cstr_ccat(&linker_arg, ','); | |
| 451 | − cstr_cat(&linker_arg, optarg); | |
| 452 | − } | |
| 447 | + if (linker_arg.size) | |
| 448 | + --linker_arg.size, cstr_ccat(&linker_arg, ','); | |
| 449 | + cstr_cat(&linker_arg, optarg); | |
| 450 | + cstr_ccat(&linker_arg, '\0'); | |
| 453 | 451 | break; |
| 454 | 452 | case TCC_OPTION_E: |
| 455 | 453 | output_type = TCC_OUTPUT_PREPROCESS; |
| @@ -471,8 +469,8 @@ static int parse_args(TCCState *s, int argc, char **argv) · 15 unmodified lines | ||
| 471 | 469 | } |
| 472 | 470 | } |
| 473 | 471 | } |
| 474 | − if ((r = (char *) tcc_set_linker(s, (char *) linker_arg.data, TRUE))) | |
| 475 | − tcc_error("unsupported linker option '%s'", r); | |
| 472 | + if (NULL != (r1 = tcc_set_linker(s, (char *) linker_arg.data, TRUE))) | |
| 473 | + tcc_error("unsupported linker option '%s'", r1); | |
| 476 | 474 | /* fixme: these options could be different on your platform */ |
| 477 | 475 | if (was_pthread && output_type != TCC_OUTPUT_OBJ) { |
| 478 | 476 | dynarray_add((void ***)&files, &nb_files, "-lpthread"); |
| @@ -51,6 +51,7 @@ · 50 unmodified lines | ||
| 51 | 51 | #define inp next_inp |
| 52 | 52 | #ifdef LIBTCC_AS_DLL |
| 53 | 53 | # define LIBTCCAPI __declspec(dllexport) |
| 54 | +# define PUB_FUNC LIBTCCAPI | |
| 54 | 55 | #endif |
| 55 | 56 | #endif |
| 56 | 57 | |
| @@ -989,12 +990,11 @@ PUB_FUNC void tcc_error(const char *fmt, ...); · 932 unmodified lines | ||
| 989 | 990 | PUB_FUNC void tcc_warning(const char *fmt, ...); |
| 990 | 991 | |
| 991 | 992 | /* other utilities */ |
| 992 | −ST_INLN void cstr_ccat(CString *cstr, int ch); | |
| 993 | −ST_FUNC void cstr_cat(CString *cstr, const char *str); | |
| 994 | −ST_FUNC void cstr_wccat(CString *cstr, int ch); | |
| 995 | −ST_FUNC void cstr_new(CString *cstr); | |
| 996 | −ST_FUNC void cstr_free(CString *cstr); | |
| 997 | −ST_FUNC void add_char(CString *cstr, int c); | |
| 993 | +PUB_FUNC void cstr_ccat(CString *cstr, int ch); | |
| 994 | +PUB_FUNC void cstr_cat(CString *cstr, const char *str); | |
| 995 | +PUB_FUNC void cstr_wccat(CString *cstr, int ch); | |
| 996 | +PUB_FUNC void cstr_new(CString *cstr); | |
| 997 | +PUB_FUNC void cstr_free(CString *cstr); | |
| 998 | 998 | #define cstr_reset(cstr) cstr_free(cstr) |
| 999 | 999 | |
| 1000 | 1000 | ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags); |
| @@ -120,7 +120,7 @@ static void cstr_realloc(CString *cstr, int new_size) · 119 unmodified lines | ||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /* add a byte */ |
| 123 | −ST_INLN void cstr_ccat(CString *cstr, int ch) | |
| 123 | +PUB_FUNC void cstr_ccat(CString *cstr, int ch) | |
| 124 | 124 | { |
| 125 | 125 | int size; |
| 126 | 126 | size = cstr->size + 1; |
| @@ -130,7 +130,7 @@ ST_INLN void cstr_ccat(CString *cstr, int ch) · 3 unmodified lines | ||
| 130 | 130 | cstr->size = size; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | −ST_FUNC void cstr_cat(CString *cstr, const char *str) | |
| 133 | +PUB_FUNC void cstr_cat(CString *cstr, const char *str) | |
| 134 | 134 | { |
| 135 | 135 | int c; |
| 136 | 136 | for(;;) { |
| @@ -143,7 +143,7 @@ ST_FUNC void cstr_cat(CString *cstr, const char *str) · 6 unmodified lines | ||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /* add a wide char */ |
| 146 | −ST_FUNC void cstr_wccat(CString *cstr, int ch) | |
| 146 | +PUB_FUNC void cstr_wccat(CString *cstr, int ch) | |
| 147 | 147 | { |
| 148 | 148 | int size; |
| 149 | 149 | size = cstr->size + sizeof(nwchar_t); |
| @@ -153,20 +153,20 @@ ST_FUNC void cstr_wccat(CString *cstr, int ch) · 3 unmodified lines | ||
| 153 | 153 | cstr->size = size; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | −ST_FUNC void cstr_new(CString *cstr) | |
| 156 | +PUB_FUNC void cstr_new(CString *cstr) | |
| 157 | 157 | { |
| 158 | 158 | memset(cstr, 0, sizeof(CString)); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /* free string and reset it to NULL */ |
| 162 | −ST_FUNC void cstr_free(CString *cstr) | |
| 162 | +PUB_FUNC void cstr_free(CString *cstr) | |
| 163 | 163 | { |
| 164 | 164 | tcc_free(cstr->data_allocated); |
| 165 | 165 | cstr_new(cstr); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /* XXX: unicode ? */ |
| 169 | −ST_FUNC void add_char(CString *cstr, int c) | |
| 169 | +static void add_char(CString *cstr, int c) | |
| 170 | 170 | { |
| 171 | 171 | if (c == '\'' || c == '\"' || c == '\\') { |
| 172 | 172 | /* XXX: could be more precise if char or string */ |
| @@ -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% -DONE_SOURCE ../tcc.c -o tcc.exe -ltcc -Llibtcc | |
| 37 | +%CC% %target% ../tcc.c -o tcc.exe -ltcc -Llibtcc | |
| 38 | 38 | |
| 39 | 39 | :copy_std_includes |
| 40 | 40 | copy ..\include\*.h include |