rtlil.cc: Fix decode for empty string

This commit is contained in:
Krystine Sherwin 2024-06-10 14:32:42 +12:00
parent 94b44a37b2
commit 260cc42c2f
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

View File

@ -337,7 +337,10 @@ std::string RTLIL::Const::decode_string() const
}
s.append({ch});
}
return s.substr(s.find_first_not_of('\0'));
auto first_char = s.find_first_not_of('\0');
if (first_char != std::string::npos)
return s.substr(first_char);
else return s;
}
bool RTLIL::Const::is_fully_zero() const