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
1 changed files with 5 additions and 3 deletions

View File

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