Fix ticket #353 (No pair for character (').)

http://apps.sourceforge.net/trac/cppcheck/ticket/353
This commit is contained in:
Reijo Tomperi 2009-06-05 23:45:31 +03:00
parent 5193a36a6a
commit 90b786b09c
2 changed files with 15 additions and 0 deletions

View File

@ -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;
}

View File

@ -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"