3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 09:05:32 +00:00

Encode filename unprintable chars

This commit is contained in:
Miodrag Milanovic 2022-08-08 16:13:33 +02:00
parent 2b1aeb44d9
commit 6c65ca4e50
4 changed files with 42 additions and 27 deletions

View file

@ -440,6 +440,21 @@ namespace RTLIL
}
};
static inline std::string encode_filename(const std::string &filename)
{
std::stringstream val;
if (!std::any_of(filename.begin(), filename.end(), [](char c) {
return static_cast<unsigned char>(c) < 33 || static_cast<unsigned char>(c) > 126;
})) return filename;
for (unsigned char const c : filename) {
if (c < 33 || c > 126)
val << stringf("$%02x", c);
else
val << c;
}
return val.str();
}
// see calc.cc for the implementation of this functions
RTLIL::Const const_not (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
RTLIL::Const const_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);