Fix for ticket 291 - preprocessor: better handling of defines
http://apps.sourceforge.net/trac/cppcheck/ticket/291
This commit is contained in:
parent
36cdac1b96
commit
2bd80a7335
|
@ -508,9 +508,15 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg,
|
|||
match &= bool(*it);
|
||||
}
|
||||
|
||||
if (line.find("#file \"") == 0 ||
|
||||
line.find("#endfile") == 0 ||
|
||||
line.find("#define") == 0)
|
||||
|
||||
if (!match && line.find("#define") == 0)
|
||||
{
|
||||
// Remove define that is not part of this configuration
|
||||
line = "";
|
||||
}
|
||||
else if (line.find("#file \"") == 0 ||
|
||||
line.find("#endfile") == 0 ||
|
||||
line.find("#define") == 0)
|
||||
{
|
||||
// We must not remove #file tags or line numbers
|
||||
// are corrupted. File tags are removed by the tokenizer.
|
||||
|
|
|
@ -984,7 +984,7 @@ private:
|
|||
// Compare results..
|
||||
ASSERT_EQUALS(2, static_cast<unsigned int>(actual.size()));
|
||||
ASSERT_EQUALS("\n\n\n\n\n20\n", actual[""]);
|
||||
TODO_ASSERT_EQUALS("\n\n\n\n\n10\n", actual["A"]);
|
||||
ASSERT_EQUALS("\n\n\n\n\n10\n", actual["A"]);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue