1
0
mirror of synced 2026-05-03 06:40:15 +00:00

fmt: correct parsing of {{ and }} for brace literals

This commit is contained in:
Charlotte
2023-06-28 11:51:13 +10:00
committed by Marcelina Kościelnicka
parent 3c8f84b70b
commit 289f8d42cb

View File

@@ -36,11 +36,13 @@ void Fmt::parse_rtlil(RTLIL::Cell *cell) {
FmtPart part;
for (size_t i = 0; i < fmt.size(); i++) {
if (fmt.substr(i, 2) == "}}")
if (fmt.substr(i, 2) == "}}") {
part.str += '}';
else if (fmt.substr(i, 2) == "{{")
++i;
} else if (fmt.substr(i, 2) == "{{") {
part.str += '{';
else if (fmt[i] == '}')
++i;
} else if (fmt[i] == '}')
log_assert(false && "Unexpected '}' in format string");
else if (fmt[i] == '{') {
if (!part.str.empty()) {