]> Shamusworld >> Repos - rmac/blobdiff - token.c
Fixed bug when expanding macros with comments that have @, \, etc.
[rmac] / token.c
diff --git a/token.c b/token.c
index 4067711be2ff7ddd1dcd5e4f51fb04cc3cad6795..124179fc8013e38372bc829c7632fb7895dd9180 100644 (file)
--- a/token.c
+++ b/token.c
@@ -314,6 +314,11 @@ int ExpandMacro(char * src, char * dest, int destsiz)
                        if (dst >= edst)
                                goto overflow;
 
+            // Skip comments in case a loose @ or \ is in there
+            // In that case the tokeniser was trying to expand it.
+            if (*s == '*' || *s == ';' || ((*s == '/') && (*(s + 1) == '/')))
+                goto skipcomments;
+
                        *dst++ = *s++;
                }
                // Do macro expansion
@@ -604,6 +609,8 @@ strcopy:
                }
        }
 
+skipcomments:
+
        *dst = EOS;
        DEBUG { printf("ExM: dst=\"%s\"\n", dest); }
        return OK;