diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-13 23:11:48 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-13 23:11:48 -0700 |
commit | 459c5c4dbda0048d1cf725f63450e47b29fc96cb (patch) | |
tree | 6aa55c7057e4d395c50494b1abf85a10e9e3d39b | |
parent | c712c2717f7ee14a258b4299d5bda3577b4c13cb (diff) | |
download | mu-459c5c4dbda0048d1cf725f63450e47b29fc96cb.tar.gz |
1558
Make it possible to check multi-line string literals in the trace.
-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; |