Fix ticket #179 (preprocessor issues)

http://apps.sourceforge.net/trac/cppcheck/ticket/179
This commit is contained in:
Reijo Tomperi 2009-03-16 23:20:55 +02:00
parent f9b481ae3a
commit c413c8d4b3
2 changed files with 7 additions and 3 deletions

View File

@ -865,10 +865,14 @@ std::string Preprocessor::expandMacros(std::string code)
{ {
params.push_back(par); params.push_back(par);
par = ""; par = "";
}
else if (code[pos2] == ' ')
{
} }
else if (parlevel >= 1) else if (parlevel >= 1)
{ {
par += std::string(1, code[pos2]); par.append(1, code[pos2]);
} }
} }
} }

View File

@ -108,7 +108,7 @@ private:
TEST_CASE(stringify); TEST_CASE(stringify);
TEST_CASE(stringify2); TEST_CASE(stringify2);
// TODO TEST_CASE(stringify3); TEST_CASE(stringify3);
TEST_CASE(ifdefwithfile); TEST_CASE(ifdefwithfile);
TEST_CASE(pragma); TEST_CASE(pragma);
} }
@ -703,7 +703,7 @@ private:
// Preprocess.. // Preprocess..
std::string actual = OurPreprocessor::expandMacros(filedata); std::string actual = OurPreprocessor::expandMacros(filedata);
ASSERT_EQUALS("\nprintf(\"[0x%lx-0x%lx)\", pstart, pend);", actual); ASSERT_EQUALS("\nprintf(\"[0x%lx-0x%lx)\",pstart,pend);", actual);
} }
void fmt2() void fmt2()