Fixed #1112 (cppcheck fails because of accented characters in comments)

This commit is contained in:
Daniel Marjamäki 2009-12-22 20:38:12 +01:00
parent 4dac46b2d7
commit c05aebbc0a
2 changed files with 28 additions and 0 deletions

View File

@ -183,6 +183,19 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
if (ch & 0x80)
throw std::runtime_error("The code contains characters that are unhandled");
if (str.compare(i, 6, "#error") == 0 || str.compare(i, 8, "#warning") == 0)
{
if (str.compare(i, 6, "#error") == 0)
code << "#error";
i = str.find("\n", i);
if (i == std::string::npos)
break;
--i;
continue;
}
// We have finished a line that didn't contain any comment
// (the '\n' is swallowed when a // comment is detected)
if (ch == '\n' && !suppressionIDs.empty())

View File

@ -78,6 +78,9 @@ private:
// #error => don't extract any code
TEST_CASE(error1);
// #error with extended chars
TEST_CASE(error2);
// Handling include guards (don't create extra configuration for it)
TEST_CASE(includeguard);
@ -419,6 +422,18 @@ private:
}
void error2()
{
const char filedata[] = "#error ê\n"
"#warning ê\n"
"123";
// Read string..
std::istringstream istr(filedata);
ASSERT_EQUALS("#error\n\n123", Preprocessor::read(istr));
}
void includeguard()
{
// Handling include guards..