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
303#define VSTACK_SIZE 256303#define VSTACK_SIZE 256
304#define STRING_MAX_SIZE 1024304#define STRING_MAX_SIZE 1024
305#define PACK_STACK_SIZE 8305#define PACK_STACK_SIZE 8
306#define MACRO_STACK_SIZE 4306#define MACRO_STACK_SIZE 8
307 307
308#define TOK_HASH_SIZE 8192 /* must be a power of two */308#define TOK_HASH_SIZE 8192 /* must be a power of two */
309#define TOK_ALLOC_INCR 512 /* must be a power of two */309#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
234 ts = tcc_malloc(sizeof(TokenSym) + len);234 ts = tcc_malloc(sizeof(TokenSym) + len);
235 table_ident[i] = ts;235 table_ident[i] = ts;
236 ts->tok = tok_ident++;236 ts->tok = tok_ident++;
237 ts->sym_define.data = tcc_malloc(sizeof(Sym**));237 ts->sym_define.data = tcc_malloc(sizeof(Sym*));
238 ts->sym_define.off = 0;238 ts->sym_define.off = 0;
239 ts->sym_define.data[0] = NULL;239 ts->sym_define.data[0] = NULL;
240 ts->sym_define.size = 1;240 ts->sym_define.size = 1;
@@ -1743,7 +1743,7 @@ pack_error: · 1502 unmodified lines
1743 size *= 2;1743 size *= 2;
1744 if (size >= MACRO_STACK_SIZE)1744 if (size >= MACRO_STACK_SIZE)
1745 tcc_error("stack full");1745 tcc_error("stack full");
1746 def->data = tcc_realloc(def->data, size*sizeof(Sym**));1746 def->data = tcc_realloc(def->data, size*sizeof(Sym*));
1747 def->size = size;1747 def->size = size;
1748 }1748 }
1749 def->data[def->off] = tmp;1749 def->data[def->off] = tmp;
tests/tcctest.c+7−0
@@ -383,7 +383,14 @@ comment · 382 unmodified lines
383 #define MACRO_TEST "macro_test1\n"383 #define MACRO_TEST "macro_test1\n"
384 #pragma push_macro("MACRO_TEST")384 #pragma push_macro("MACRO_TEST")
385 #undef MACRO_TEST385 #undef MACRO_TEST
386
386 #define MACRO_TEST "macro_test2\n"387 #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")
387 printf(MACRO_TEST);394 printf(MACRO_TEST);
388 #pragma pop_macro("MACRO_TEST")395 #pragma pop_macro("MACRO_TEST")
389 printf(MACRO_TEST);396 printf(MACRO_TEST);