History

fix push_macro, asked Tom to help me testfix push_macro

jiang committed 12 years ago

Commit 52891b61 parent 5a514103 files · +10 −3Browse files

Unified · Split

3 files
  1. tcc.h +1 −1
  2. tccpp.c +2 −2
  3. tests/tcctest.c +7 −0
tcc.h+1−1
@@ -303,7 +303,7 @@ · 302 unmodified lines
303303 #define VSTACK_SIZE 256
304304 #define STRING_MAX_SIZE 1024
305305 #define PACK_STACK_SIZE 8
306−#define MACRO_STACK_SIZE 4
306+#define MACRO_STACK_SIZE 8
307307
308308 #define TOK_HASH_SIZE 8192 /* must be a power of two */
309309 #define TOK_ALLOC_INCR 512 /* must be a power of two */
tccpp.c+2−2
@@ -234,7 +234,7 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len) · 233 unmodified lines
234234 ts = tcc_malloc(sizeof(TokenSym) + len);
235235 table_ident[i] = ts;
236236 ts->tok = tok_ident++;
237− ts->sym_define.data = tcc_malloc(sizeof(Sym**));
237+ ts->sym_define.data = tcc_malloc(sizeof(Sym*));
238238 ts->sym_define.off = 0;
239239 ts->sym_define.data[0] = NULL;
240240 ts->sym_define.size = 1;
@@ -1743,7 +1743,7 @@ pack_error: · 1502 unmodified lines
17431743 size *= 2;
17441744 if (size >= MACRO_STACK_SIZE)
17451745 tcc_error("stack full");
1746− def->data = tcc_realloc(def->data, size*sizeof(Sym**));
1746+ def->data = tcc_realloc(def->data, size*sizeof(Sym*));
17471747 def->size = size;
17481748 }
17491749 def->data[def->off] = tmp;
tests/tcctest.c+7−0
@@ -383,7 +383,14 @@ comment · 382 unmodified lines
383383 #define MACRO_TEST "macro_test1\n"
384384 #pragma push_macro("MACRO_TEST")
385385 #undef MACRO_TEST
386+
386387 #define MACRO_TEST "macro_test2\n"
388+ #pragma push_macro("MACRO_TEST")
389+ #undef MACRO_TEST
390+
391+ #define MACRO_TEST "macro_test3\n"
392+ printf(MACRO_TEST);
393+ #pragma pop_macro("MACRO_TEST")
387394 printf(MACRO_TEST);
388395 #pragma pop_macro("MACRO_TEST")
389396 printf(MACRO_TEST);