From be5c1cb1a3ca24f29789437675fa8cd22e1edd45 Mon Sep 17 00:00:00 2001 From: ggn Date: Tue, 13 Sep 2016 11:59:38 +0300 Subject: [PATCH] Fixed bug when expanding macros with comments that have @, \, etc. Signed-off-by: Shamus Hammons --- token.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/token.c b/token.c index 4067711..124179f 100644 --- 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; -- 2.37.2