Compare commits

...

3 Commits

Author SHA1 Message Date
KrystalDelusion 50bc8c8e4d
Merge 260cc42c2f into 4b3c03dabc 2024-11-22 05:32:19 +13:00
Krystine Sherwin 260cc42c2f
rtlil.cc: Fix decode for empty string 2024-06-10 14:32:42 +12:00
Krystine Sherwin 94b44a37b2
rtlil.cc: Fix #4427
If a `RTLIL::Const` is composed of multiple strings, such as when using a ternary expression to select between two strings of different lengths, zero padding for the strings needs to be maintained.
Only leading (and trailing) null characters should be dropped from the decoded string, rather than all null characters.
2024-06-10 14:18:49 +12:00
1 changed files with 6 additions and 5 deletions

View File

@ -480,8 +480,7 @@ std::string RTLIL::Const::decode_string() const
ch |= 1 << j;
}
}
if (ch != 0)
s.append({ch});
s.append({ch});
}
i -= 8;
for (; i >= 0; i -= 8) {
@ -491,10 +490,12 @@ std::string RTLIL::Const::decode_string() const
ch |= 1 << j;
}
}
if (ch != 0)
s.append({ch});
s.append({ch});
}
return s;
auto first_char = s.find_first_not_of('\0');
if (first_char != std::string::npos)
return s.substr(first_char);
else return s;
}
int RTLIL::Const::size() const {