# HG changeset patch # User Shinji KONO # Date 1397351678 -32400 # Node ID bd9bd4ba2f1c856a64d57a9a25c0a36eb8d5bd43 # Parent 080d87432ff39fe8513bd4670bce7632966a0602 ignore global non function macro in function and do replace eager diff -r 080d87432ff3 -r bd9bd4ba2f1c mc-macro.c --- a/mc-macro.c Fri Apr 11 20:02:17 2014 +0900 +++ b/mc-macro.c Sun Apr 13 10:14:38 2014 +0900 @@ -131,6 +131,10 @@ if (t[-2]!='\n') putchar('\n'); } #endif + while (macro_history!=0) { + int i = cadr(macro_history); free_glist2(macro_history); macro_history = i; + } + macro_history = car(macro_history_save); // evaluate generated result again macrop=macro_eval(macrop,macropp,macro_history,0); cheap = reset_cheap(&scheap); @@ -142,6 +146,7 @@ cheap->ptr[0] =0; cheap = increment_cheap(cheap,¯opp); } + cheap = reset_cheap(&scheap); // genrated macro will be overwrited by cheap, but it's OK, again if (before && lsrc) printf("## after %s\n",macropp); @@ -1087,16 +1092,16 @@ default: if (prev_concat) { prev_concat = 0; - macro = nptrm->u.nm; + macro = nptrm->nm; } else if (next_concat(c,body)) { prev_concat = 1; - macro = nptrm->u.nm; + macro = nptrm->nm; } if (macro==0 || !macro[0]) macro = nptrm->nm; goto skip; case MACRO: - if (neqname(nptrm->nm,macro)) { + if (!local_only && neqname(nptrm->nm,macro)) { if (macro[0]==0) { if (string_flag) { string_flag = 0; @@ -1111,6 +1116,7 @@ expand = (char **)&(scaddr(macrop)); break; } + if (local_only) mconcat = 1; macro = nptrm->nm; skip: case LMACRO: diff -r 080d87432ff3 -r bd9bd4ba2f1c test/macro.c --- a/test/macro.c Fri Apr 11 20:02:17 2014 +0900 +++ b/test/macro.c Sun Apr 13 10:14:38 2014 +0900 @@ -139,6 +139,7 @@ printf("#0107:%s\n",stringify(aho)); printf("#0108:%s\n",init_str); printf("#0109:%d\n",names2(4)); + printf("#0110:%d\n",name_hoge(names(4,hoge))); /* printf("#0103:%d\n",(3 +a)); printf("#0104:%d\n",(3 +a));