diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index e9b648b04..c0ea2c0aa 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -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 {