diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 17963f673..c41134a09 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -178,15 +178,15 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename, // Remove all comments.. result = removeComments(result, filename, settings); - // Remove '#if 0' blocks - if (result.find("#if 0\n") != std::string::npos) - result = removeIf0(result); - // ------------------------------------------------------------------------------------------ // // 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 diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index a16eccfd8..1e6ce5c64 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -93,6 +93,7 @@ private: TEST_CASE(error3); TEST_CASE(if0_exclude); + TEST_CASE(if0_whitespace); // Don't handle include in a #if 0 block TEST_CASE(if0_include_1); @@ -655,6 +656,18 @@ private: ASSERT_EQUALS("\n\n\nB\n", preprocessor.read(code,"",NULL)); } + void if0_whitespace() + { + Settings settings; + Preprocessor preprocessor(&settings, this); + + std::istringstream code(" # if 0 \n" + "A\n" + " # endif \n" + "B\n"); + ASSERT_EQUALS("\n\n\nB\n", preprocessor.read(code,"",NULL)); + } + void if0_include_1() { Settings settings;