mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
rt: strings should escape chars like '\n' as '\n'
This commit is contained in:
parent
012dec5e57
commit
d3331bce98
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user