From d3331bce98eefd2f9528c70322f059dcc44553c9 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 28 Feb 2012 18:05:04 -0800 Subject: [PATCH] rt: strings should escape chars like '\n' as '\n' --- src/rt/rust_shape.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 866bc4ac17a..ef53a7ca7fa 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -447,10 +447,19 @@ log::walk_string2(const std::pair &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; }