rt: strings should escape chars like '\n' as '\n'

This commit is contained in:
Erick Tryzelaar 2012-02-28 18:05:04 -08:00
parent 012dec5e57
commit d3331bce98

View File

@ -447,10 +447,19 @@ log::walk_string2(const std::pair<ptr,ptr> &data) {
ptr subdp = data.first;
while (subdp < data.second) {
char ch = *subdp;
if (isprint(ch))
out << ch;
else if (ch)
out << "\\x" << std::setw(2) << std::setfill('0') << (int)ch;
switch(ch) {
case '\n': out << "\\n"; break;
case '\r': out << "\\r"; break;
case '\t': out << "\\t"; break;
case '\\': out << "\\\\"; break;
case '"': out << "\\\""; break;
default:
if (isprint(ch)) {
out << ch;
} else if (ch) {
out << "\\x" << std::setw(2) << std::setfill('0') << (int)ch;
}
}
++subdp;
}