From 624ec3e1b7dd8908b37ee86bce6f60423c915bc5 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 25 Apr 2017 07:09:18 +0100 Subject: [PATCH] Fix bug with comments inline in macros - commit fixes #974 --- Source/Preprocessor/cpp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 12d27c316..491eb8a96 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -607,6 +607,23 @@ static List *find_args(String *s, int ismacro, String *macro_name) { skip_tochar(s, '\'', str); c = Getc(s); continue; + } else if (c == '/') { + /* Ensure comments are ignored by eating up the characters */ + c = Getc(s); + if (c == '*') { + while ((c = Getc(s)) != EOF) { + if (c == '*') { + c = Getc(s); + if (c == '/' || c == EOF) + break; + } + } + c = Getc(s); + continue; + } + /* ensure char is available in the stream as this was not a comment*/ + Ungetc(c, s); + c = '/'; } if ((c == ',') && (level == 0)) break;