Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline comment within macro definition terminates it #24

Open
ayourtch opened this issue Aug 17, 2016 · 1 comment
Open

Multiline comment within macro definition terminates it #24

ayourtch opened this issue Aug 17, 2016 · 1 comment

Comments

@ayourtch
Copy link

Processing this chunk with lcpp:

#define foo \
   /* Comment here  \
        which spans lines */ \
   this should never appear in the output \
   but it does

causes string "this should never appear in the output but it does" to appear in the final output - whereas with cpp this does not happen.

@ayourtch
Copy link
Author

The following diff takes care of the problem:

diff --git a/lcpp.lua b/lcpp.lua
index 4450dcd..e60f225 100755
--- a/lcpp.lua
+++ b/lcpp.lua
@@ -418,7 +418,7 @@ local function removeComments(input)
        for k, v, start, end_ in tokenizer(input, LCPP_TOKENIZE_COMMENT) do
                if k == "MLCOMMENT" then
                        local newlineCount = findn(input:sub(start, end_), "\n")
-                       local newlines = string.rep("\n", newlineCount)
+                       local newlines = string.rep("\\\n", newlineCount)^M
                        table.insert(out, newlines)
                elseif k == "SLCOMMENT" then
                        table.insert(out, "\n")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant