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

Merge pull request #3207 from nakengelhardt/json_escape_quotes

fix handling of escaped chars in json backend and frontend (mostly)
This commit is contained in:
Miodrag Milanović 2022-03-04 13:57:32 +01:00 committed by GitHub
commit c3124023e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 + "\"";
}