diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index d70bcabb6..c6de1ef6d 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -1150,6 +1150,12 @@ std::string Preprocessor::expandMacros(std::string code, const std::string &file ++pos2; while (pos2 < code.length() && code[pos2] != ch) { + if (code[pos2] == '\\') + { + par += code[pos2]; + ++pos2; + } + par += code[pos2]; ++pos2; } diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 7d2776c32..aa55ee7f5 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -103,6 +103,7 @@ private: TEST_CASE(macro_simple6); TEST_CASE(macro_simple7); TEST_CASE(macro_simple8); + TEST_CASE(macro_simple9); TEST_CASE(macro_mismatch); TEST_CASE(macro_linenumbers); TEST_CASE(string1); @@ -665,6 +666,14 @@ private: ASSERT_EQUALS("\n\n123 1234", OurPreprocessor::expandMacros(filedata)); } + void macro_simple9() + { + const char filedata[] = "#define ABC(a) f(a)\n" + "ABC( \"\\\"\" );\n" + "ABC( \"g\" );"; + ASSERT_EQUALS("\nf(\"\\\"\");\nf(\"g\");", OurPreprocessor::expandMacros(filedata)); + } + void macro_mismatch() { const char filedata[] = "#define AAA(aa,bb) f(aa)\n"