]> Shamusworld >> Repos - rmac/commitdiff
Fixed bug when expanding macros with comments that have @, \, etc.
authorggn <ggn.dbug@gmail.com>
Tue, 13 Sep 2016 08:59:38 +0000 (11:59 +0300)
committerShamus Hammons <jlhamm@acm.org>
Thu, 22 Sep 2016 15:50:50 +0000 (10:50 -0500)
Signed-off-by: Shamus Hammons <jlhamm@acm.org>
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;