std::string Str = RawSR.trim().str();
size_t Pos = 0;
+ // Escape backslashes.
+ while (true) {
+ Pos = Str.find('\\', Pos);
+ if (Pos == std::string::npos)
+ break;
+
+ // Prevent bad conversions.
+ size_t TempPos = (Pos != 0) ? Pos - 1 : 0;
+
+ // See whether the current backslash is not escaped.
+ if (TempPos != Str.find("\\\\", Pos)) {
+ Str.insert(Pos, "\\");
+ ++Pos; // As we insert the backslash move plus one.
+ }
+
+ ++Pos;
+ }
+
// Escape double quotes.
+ Pos = 0;
while (true) {
Pos = Str.find('\"', Pos);
if (Pos == std::string::npos)
// Prevent bad conversions.
size_t TempPos = (Pos != 0) ? Pos - 1 : 0;
- // See whether the current double quote is escaped.
- if (TempPos != Str.find("\\\"", TempPos)) {
+ // See whether the current double quote is not escaped.
+ if (TempPos != Str.find("\\\"", Pos)) {
Str.insert(Pos, "\\");
++Pos; // As we insert the escape-character move plus one.
}
int foo() {
int *x = 0, *y = 0;
+ char c = '\x13';
+
return *x + *y;
}
// CHECK: \"has_report\": true
-// CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 16, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \}
+// CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \}
+
+// CHECK: \"pretty\": \"'\\\\x13'\"
// CHECK: <td align="left"><b>Environment: </b></td>
// CHECK-SAME: <td align="left">"foo"</td>
// CHECK-SAME: <td align="left">&Element\{"foo",0 S64b,char\}</td>
- const char *const foo = "foo";
+ const char *const foo = "\x66\x6f\x6f";
// CHECK: <font color="cyan3">BinaryOperator</font>
// CHECK-SAME: <td align="left">1 \| 2</td>