diff options
author | N. Engelhardt <nak@yosyshq.com> | 2022-02-18 17:13:09 +0100 |
---|---|---|
committer | N. Engelhardt <nak@yosyshq.com> | 2022-02-18 17:13:09 +0100 |
commit | 8fd1b062491f9ba1f0aed570086e7697731502d4 (patch) | |
tree | 79837b6f19a083cac3578473769420e2c8c4b1e0 /backends | |
parent | 15860000487e2d6748843888b78289f95f3ea46b (diff) | |
download | yosys-8fd1b062491f9ba1f0aed570086e7697731502d4.tar.gz yosys-8fd1b062491f9ba1f0aed570086e7697731502d4.tar.bz2 yosys-8fd1b062491f9ba1f0aed570086e7697731502d4.zip |
fix handling of escaped chars in json backend and frontend
Diffstat (limited to 'backends')
-rw-r--r-- | backends/json/json.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/backends/json/json.cc b/backends/json/json.cc index 4aa8046d6..42eedc606 100644 --- a/backends/json/json.cc +++ b/backends/json/json.cc @@ -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 + "\""; } |