diff mc-macro.c @ 917:60451f9e0c6e

stringfy and concat bad interaction fix.
author kono
date Thu, 10 Apr 2014 19:27:04 +0900
parents f7803d618f36
children 9b2a0f9aedf1
line wrap: on
line diff
--- a/mc-macro.c	Thu Apr 10 12:04:39 2014 +0900
+++ b/mc-macro.c	Thu Apr 10 19:27:04 2014 +0900
@@ -107,10 +107,10 @@
     // remove \s**##\s*
     //  it is difficult to remove former space on the fly,
     //  so multi path loop is required
-
+    int before=0;
     while (mconcat) {
         // ## re-eval macro
-        if (lsrc) printf("## before %s",macropp);
+        if (lsrc) { printf("## before %s\n",macropp); before=1; }
         mconcat = 0;
         macrop = 0;
         for(s=t=macropp;*s;) {
@@ -144,6 +144,7 @@
     }
     cheap = reset_cheap(&scheap);
     // genrated macro will be overwrited by cheap, but it's OK, again
+    if (before && lsrc) printf("## after %s\n",macropp);
     mconcat = 0;
     set_lfree(slfree);
 #if 0
@@ -778,7 +779,7 @@
     int args = glist3s(STRING,0,cheap->ptr);
     body = (char **)&scaddr(args);
     for(;;) {
-        *cheap->ptr = c = *chptr++;
+	*cheap->ptr = c = *chptr++;
         cheap = increment_cheap(cheap,body);
         if (c=='\\') {
             if (*chptr=='\n') {
@@ -991,7 +992,7 @@
             prev_concat = 1;
             // name concatenation. flag only. remove and re-evaluate
             // in the top level. (and skip space)
-        } else if (!mconcat && c=='#' && alpha(*body)) {
+        } else if (!prev_concat && c=='#' && alpha(*body)) {
             // turn into string next macro literal
             string_flag = 1;
             string_mark(expand);
@@ -1046,11 +1047,9 @@
             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])