3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-24 01:25:33 +00:00

fix handling of escaped chars in json backend and frontend

This commit is contained in:
N. Engelhardt 2022-02-18 17:13:09 +01:00
parent 1586000048
commit 8fd1b06249
5 changed files with 63 additions and 5 deletions

View file

@ -52,8 +52,23 @@ struct JsonWriter
string newstr = "\"";
for (char c : str) {
if (c == '\\')
newstr += "\\\\";
else if (c == '"')
newstr += "\\\"";
else if (c == '\b')
newstr += "\\b";
else if (c == '\f')
newstr += "\\f";
else if (c == '\n')
newstr += "\\n";
else if (c == '\r')
newstr += "\\r";
else if (c == '\t')
newstr += "\\t";
else if (c < 0x20)
newstr += stringf("\\u%04X", c);
else
newstr += c;
newstr += c;
}
return newstr + "\"";
}