Fixed #2570 (Preprocessor: #define parsing when there is no whitespace between a macro symbol and its double-quoted string expansion)
This commit is contained in:
parent
b8c5426bb8
commit
751f8d46e5
|
@ -2124,12 +2124,14 @@ public:
|
||||||
|
|
||||||
else if (_params.empty())
|
else if (_params.empty())
|
||||||
{
|
{
|
||||||
std::string::size_type pos = _macro.find(" ");
|
std::string::size_type pos = _macro.find_first_of(" \"");
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
macrocode = "";
|
macrocode = "";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
macrocode = _macro.substr(pos + 1);
|
if (_macro[pos] == ' ')
|
||||||
|
pos++;
|
||||||
|
macrocode = _macro.substr(pos);
|
||||||
if ((pos = macrocode.find_first_of("\r\n")) != std::string::npos)
|
if ((pos = macrocode.find_first_of("\r\n")) != std::string::npos)
|
||||||
macrocode.erase(pos);
|
macrocode.erase(pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,7 @@ private:
|
||||||
TEST_CASE(macro_simple12);
|
TEST_CASE(macro_simple12);
|
||||||
TEST_CASE(macro_simple13);
|
TEST_CASE(macro_simple13);
|
||||||
TEST_CASE(macro_simple14);
|
TEST_CASE(macro_simple14);
|
||||||
|
TEST_CASE(macro_simple15);
|
||||||
TEST_CASE(macroInMacro);
|
TEST_CASE(macroInMacro);
|
||||||
TEST_CASE(macro_mismatch);
|
TEST_CASE(macro_mismatch);
|
||||||
TEST_CASE(macro_linenumbers);
|
TEST_CASE(macro_linenumbers);
|
||||||
|
@ -1589,6 +1590,13 @@ private:
|
||||||
ASSERT_EQUALS("\nprintf(\" a \");\n", OurPreprocessor::expandMacros(filedata));
|
ASSERT_EQUALS("\nprintf(\" a \");\n", OurPreprocessor::expandMacros(filedata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void macro_simple15()
|
||||||
|
{
|
||||||
|
const char filedata[] = "#define FOO\"foo\"\n"
|
||||||
|
"FOO\n";
|
||||||
|
ASSERT_EQUALS("\n\"foo\"\n", OurPreprocessor::expandMacros(filedata));
|
||||||
|
}
|
||||||
|
|
||||||
void macroInMacro()
|
void macroInMacro()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue