diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2022-08-08 21:11:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 21:11:34 +0200 |
commit | 6b4dbf6c364a5dc6a14263e24af6b011266855b7 (patch) | |
tree | 092fb5c922a6b87f5aa72be3b55d8d48142e611a /kernel/rtlil.h | |
parent | 60a787fa50062169c1aae4ecb199d13c0b6f25b6 (diff) | |
parent | f4a1906721507c512050f62080a999c4147d92d6 (diff) | |
download | yosys-6b4dbf6c364a5dc6a14263e24af6b011266855b7.tar.gz yosys-6b4dbf6c364a5dc6a14263e24af6b011266855b7.tar.bz2 yosys-6b4dbf6c364a5dc6a14263e24af6b011266855b7.zip |
Merge pull request #3439 from YosysHQ/micko/filepath_improve
File path encoding improvements
Diffstat (limited to 'kernel/rtlil.h')
-rw-r--r-- | kernel/rtlil.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h index ff5bdf2d7..db175d7e9 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -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); |