History

tcc.c: fix previous commit "Use CString to concat linker options"

- 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

grischka committed 14 years ago

Commit 4274c441 parent 214564b4 files · +20 −22Browse files

Unified · Split

4 files
  1. tcc.c +7 −9
  2. tcc.h +6 −6
  3. tccpp.c +6 −6
  4. win32/build-tcc.bat +1 −1
tcc.c+7−9
@@ -283,9 +283,9 @@ static int parse_args(TCCState *s, int argc, char **argv) · 282 unmodified lines
283283 int was_pthread;
284284
285285 was_pthread = 0; /* is set if commandline contains -pthread key */
286−
287286 optind = 1;
288287 cstr_new(&linker_arg);
288+
289289 while (optind < argc) {
290290
291291 r = argv[optind++];
@@ -444,12 +444,10 @@ 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.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');
453451 break;
454452 case TCC_OPTION_E:
455453 output_type = TCC_OUTPUT_PREPROCESS;
@@ -471,8 +469,8 @@ static int parse_args(TCCState *s, int argc, char **argv) · 15 unmodified lines
471469 }
472470 }
473471 }
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);
476474 /* fixme: these options could be different on your platform */
477475 if (was_pthread && output_type != TCC_OUTPUT_OBJ) {
478476 dynarray_add((void ***)&files, &nb_files, "-lpthread");
tcc.h+6−6
@@ -51,6 +51,7 @@ · 50 unmodified lines
5151 #define inp next_inp
5252 #ifdef LIBTCC_AS_DLL
5353 # define LIBTCCAPI __declspec(dllexport)
54+# define PUB_FUNC LIBTCCAPI
5455 #endif
5556 #endif
5657
@@ -989,12 +990,11 @@ PUB_FUNC void tcc_error(const char *fmt, ...); · 932 unmodified lines
989990 PUB_FUNC void tcc_warning(const char *fmt, ...);
990991
991992 /* 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);
998998 #define cstr_reset(cstr) cstr_free(cstr)
999999
10001000 ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags);
tccpp.c+6−6
@@ -120,7 +120,7 @@ static void cstr_realloc(CString *cstr, int new_size) · 119 unmodified lines
120120 }
121121
122122 /* add a byte */
123−ST_INLN void cstr_ccat(CString *cstr, int ch)
123+PUB_FUNC void cstr_ccat(CString *cstr, int ch)
124124 {
125125 int size;
126126 size = cstr->size + 1;
@@ -130,7 +130,7 @@ ST_INLN void cstr_ccat(CString *cstr, int ch) · 3 unmodified lines
130130 cstr->size = size;
131131 }
132132
133−ST_FUNC void cstr_cat(CString *cstr, const char *str)
133+PUB_FUNC void cstr_cat(CString *cstr, const char *str)
134134 {
135135 int c;
136136 for(;;) {
@@ -143,7 +143,7 @@ ST_FUNC void cstr_cat(CString *cstr, const char *str) · 6 unmodified lines
143143 }
144144
145145 /* add a wide char */
146−ST_FUNC void cstr_wccat(CString *cstr, int ch)
146+PUB_FUNC void cstr_wccat(CString *cstr, int ch)
147147 {
148148 int size;
149149 size = cstr->size + sizeof(nwchar_t);
@@ -153,20 +153,20 @@ ST_FUNC void cstr_wccat(CString *cstr, int ch) · 3 unmodified lines
153153 cstr->size = size;
154154 }
155155
156−ST_FUNC void cstr_new(CString *cstr)
156+PUB_FUNC void cstr_new(CString *cstr)
157157 {
158158 memset(cstr, 0, sizeof(CString));
159159 }
160160
161161 /* free string and reset it to NULL */
162−ST_FUNC void cstr_free(CString *cstr)
162+PUB_FUNC void cstr_free(CString *cstr)
163163 {
164164 tcc_free(cstr->data_allocated);
165165 cstr_new(cstr);
166166 }
167167
168168 /* XXX: unicode ? */
169−ST_FUNC void add_char(CString *cstr, int c)
169+static void add_char(CString *cstr, int c)
170170 {
171171 if (c == '\'' || c == '\"' || c == '\\') {
172172 /* XXX: could be more precise if char or string */
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% -DONE_SOURCE ../tcc.c -o tcc.exe -ltcc -Llibtcc
37+%CC% %target% ../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