handle #if (0) after removing parentheses

This commit is contained in:
Greg Hewgill 2011-03-01 19:50:17 +13:00
parent 31c56d7353
commit a331516735
2 changed files with 10 additions and 4 deletions

View File

@ -183,15 +183,15 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename,
// Clean up all preprocessor statements
result = preprocessCleanupDirectives(result);
// Remove '#if 0' blocks
if (result.find("#if 0\n") != std::string::npos)
result = removeIf0(result);
// ------------------------------------------------------------------------------------------
//
// Clean up preprocessor #if statements with Parantheses
result = removeParantheses(result);
// Remove '#if 0' blocks
if (result.find("#if 0\n") != std::string::npos)
result = removeIf0(result);
return result;
}

View File

@ -654,6 +654,12 @@ private:
"#endif\n"
"B\n");
ASSERT_EQUALS("\n\n\nB\n", preprocessor.read(code,"",NULL));
std::istringstream code2("#if (0)\n"
"A\n"
"#endif\n"
"B\n");
ASSERT_EQUALS("\n\n\nB\n", preprocessor.read(code2,"",NULL));
}
void if0_whitespace()