diff options
author | Luca Longinotti <l@longi.li> | 2017-11-30 11:10:44 +0100 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2018-03-07 14:49:08 +1300 |
commit | 30719feaf955135586fc96f61c067c9ccf09d507 (patch) | |
tree | c8bbad836b70a1c8fbc2e62e614c2a471a026a6b /Source/Preprocessor | |
parent | d4badb3e1dc32a5f60ceb8a2ed454d6694e57951 (diff) | |
download | swig-30719feaf955135586fc96f61c067c9ccf09d507.tar.gz |
Fix handling of // comments inside macro arguments
/* */ are already handled correctly.
This completes the fix from commit
624ec3e1b7dd8908b37ee86bce6f60423c915bc5 related to swig/swig#974.
Diffstat (limited to 'Source/Preprocessor')
-rw-r--r-- | Source/Preprocessor/cpp.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 10018a787..af1775007 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -610,6 +610,7 @@ static List *find_args(String *s, int ismacro, String *macro_name) { } else if (c == '/') { /* Ensure comments are ignored by eating up the characters */ c = Getc(s); + /* Handle / * ... * / type comments (multi-line) */ if (c == '*') { while ((c = Getc(s)) != EOF) { if (c == '*') { @@ -621,6 +622,16 @@ static List *find_args(String *s, int ismacro, String *macro_name) { c = Getc(s); continue; } + /* Handle // ... type comments (single-line) */ + if (c == '/') { + while ((c = Getc(s)) != EOF) { + if (c == '\n') { + break; + } + } + c = Getc(s); + continue; + } /* ensure char is available in the stream as this was not a comment*/ Ungetc(c, s); c = '/'; |