diff --git a/src/preprocessor.cpp b/src/preprocessor.cpp index 584eceebe..a53f1f6ce 100644 --- a/src/preprocessor.cpp +++ b/src/preprocessor.cpp @@ -801,6 +801,17 @@ std::string Preprocessor::expandMacros(std::string code, const std::string &file // End of line/file was reached without finding pair if (pos1 >= code.size() || code[pos1] == '\n') { + std::string::size_type lineStart = code.rfind('\n', pos1 - 1); + if (lineStart != std::string::npos) + { + if (code.substr(lineStart + 1, 7) == "#define") + { + // There is nothing wrong #define containing quote without + // a pair. + continue; + } + } + if (errorLogger) { std::string fname(filename); diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 5430c1374..0091c0840 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -849,6 +849,19 @@ private: ASSERT_EQUALS("", actual); ASSERT_EQUALS("[abc.h:2]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout.str()); } + + { + const char filedata[] = "#define A 1\n" + "#define B \"\n" + "int a = A;\n"; + + // expand macros.. + errout.str(""); + const std::string actual(OurPreprocessor::expandMacros(filedata, this)); + + ASSERT_EQUALS("\n\nint a = 1;\n", actual); + ASSERT_EQUALS("", errout.str()); + } } };