diff options
-rw-r--r-- | 010vm.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/010vm.cc b/010vm.cc index 5be84982..2b140cba 100644 --- a/010vm.cc +++ b/010vm.cc @@ -226,9 +226,19 @@ string reagent::to_string() const { } string emit_literal_string(string name) { + size_t pos = 0; + while (pos != string::npos) + pos = replace(name, "\n", "\\n", pos); return "{name: \""+name+"\", properties: [_: \"literal-string\"]}"; } +size_t replace(string& str, const string& from, const string& to, size_t n) { + size_t result = str.find(from, n); + if (result != string::npos) + str.replace(result, from.length(), to); + return result; +} + string instruction::to_string() const { if (is_label) return label; ostringstream out; |