Mercurial > hg > CbC > old > device
diff mc-macro.c @ 347:cef4d8eb9a26
name table reconfigure continue...
author | kono |
---|---|
date | Fri, 02 Jul 2004 03:55:11 +0900 |
parents | 969089695850 |
children | e77b3a7002ad |
line wrap: on
line diff
--- a/mc-macro.c Tue Jun 29 23:11:47 2004 +0900 +++ b/mc-macro.c Fri Jul 02 03:55:11 2004 +0900 @@ -45,8 +45,9 @@ } else { macrop=macro_eval(macrop,(char *)car(nptrm->dsp),0); } + cheap = reset_cheap(&scheap); macropp = cheap->ptr; - // we can't reset cheap + // we can reset cheap, no page wrap in this case mappend(reverse0(macrop),¯opp); cheap->ptr[-1] ='\n'; cheap->ptr[0] =0; @@ -56,8 +57,9 @@ mconcat = 0; macrop = 0; macrop=macro_eval(macrop,macropp,0); + cheap = reset_cheap(&scheap); macropp = cheap->ptr; - // will override evaled list + // will not override evaled list mappend(reverse0(macrop),¯opp); cheap->ptr[-1] ='\n'; cheap->ptr[0] =0; @@ -586,7 +588,7 @@ NMTBL *nptr0; while(*macro==' '||*macro=='\t') macro++; nptr0 = msearch0(macro); - /* save nptr previous contents in a list */ + /* save nptr's previous content in a list */ nptr0->ty=list3(nptr0->sc,nptr0->ty,nptr0->dsp); /* set new value */ nptr0->sc=LMACRO; @@ -608,7 +610,7 @@ static int macro_eval(int macrop,char *body0,int history) { - int c; + int c,len; int in_quote = 0; int in_wquote = 0; char *macro; @@ -640,25 +642,13 @@ // name concatenation. skip ## and re-eval macro line. mconcat = 1; body++; continue; } else if (alpha(c)) { - char *schptr; - schptr = chptr; chptr = body; - get_name(); - chptr--; // ungetc - body = chptr; chptr = schptr; - nptrm = msearch0(hptr); + nptrm = get_name(body,&len); + body += len; + body--; // ungetc + nptrm = name_space_search(nptrm,MACRO); macro = (char *)car(nptrm->dsp); - if (nptrm->sc==LMACRO) { - while((*cheap->ptr = *macro++)) - cheap = increment_cheap(cheap,expand); - cheap->ptr--; - } else if (nptrm->sc==MACRO && neqname(nptrm->nm,macro)) { - if (macro[0]==0) continue; - *cheap->ptr = 0; - cheap = increment_cheap(cheap,expand); - macrop=macro_eval(macrop,macro,list2((int)macro,history)); - macrop = list2((int)cheap->ptr,macrop); - expand = (char **)&(car(macrop)); - } else if (nptrm->sc==FMACRO) { + switch(nptrm->sc) { + case FMACRO: if (c==' '||c=='\t') { while (c==' '||c=='\t') c=*body++; body--; @@ -670,8 +660,20 @@ list2((int)macro,history)); macrop = list2((int)cheap->ptr,macrop); expand = (char **)&(car(macrop)); - } else { + break; + case MACRO: + if (neqname(nptrm->nm,macro)) { + if (macro[0]==0) continue; + *cheap->ptr = 0; + cheap = increment_cheap(cheap,expand); + macrop=macro_eval(macrop,macro,list2((int)macro,history)); + macrop = list2((int)cheap->ptr,macrop); + expand = (char **)&(car(macrop)); + break; + } + default: macro = nptrm->nm; + case LMACRO: while((*cheap->ptr = *macro++)); cheap = increment_cheap(cheap,expand); cheap->ptr--; @@ -692,17 +694,14 @@ { char *p; *result = cheap->ptr; - while(lists) { + for(;lists;list= cadr(lists)) { p = (char *)car(lists); - while((*cheap->ptr=*p++)) { + for(;(*cheap->ptr=*p++);cheap = increment_cheap(cheap,0)) { // in_quote + \n case ? should be \n. if (p[-1]=='\n') cheap->ptr[-1]=' '; - cheap = increment_cheap(cheap,result); } - cheap->ptr--; - lists = cadr(lists); } - cheap = increment_cheap(cheap,result); + cheap = increment_cheap(cheap,0); return *result; }