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