Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ std::string ErrorLogger::toxml(const std::string &str)
case '\0':
xml += "\\0";
break;
case '\n':
xml += "
";
break;
default:
if (c >= ' ' && c <= 0x7f)
xml += c;
Expand Down
16 changes: 16 additions & 0 deletions test/testcppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,22 @@ class TestCppcheck : public TestFixture {
" <file index=\"0\" name=\"test.cpp\"/>\n"
" </rawtokens>\n";
ASSERT_EQUALS(expected, cppcheck.getDumpFileContentsRawTokens(files, tokens1));

const char code[] = "//x \\ \n"
"y\n"
";\n";

std::istringstream fin(code);
simplecpp::OutputList outputList;
const simplecpp::TokenList tokens2(fin, files, "", &outputList);
const std::string expected2 = " <rawtokens>\n"
" <file index=\"0\" name=\"test.cpp\"/>\n"
" <file index=\"1\" name=\"\"/>\n"
" <tok fileIndex=\"1\" linenr=\"1\" column=\"1\" str=\"//x &#10;y\"/>\n"
" <tok fileIndex=\"1\" linenr=\"3\" column=\"1\" str=\";\"/>\n"
" </rawtokens>\n";
ASSERT_EQUALS(expected2, cppcheck.getDumpFileContentsRawTokens(files, tokens2));

}

void getDumpFileContentsLibrary() const {
Expand Down