Merge pull request #3809 from YosysHQ/nak/show_escape

This commit is contained in:
N. Engelhardt 2023-06-21 10:38:32 +02:00 committed by GitHub
commit 941fa70ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -201,6 +201,12 @@ struct ShowWorker
if (id[0] == '\\') if (id[0] == '\\')
id = id.substr(1); id = id.substr(1);
// TODO: optionally include autoname + print correspondence in case of ambiguity
size_t max_label_len = abbreviateIds ? 256 : 16384;
if (id.size() > max_label_len) {
id = id.substr(0,max_label_len-3) + "...";
}
std::string str; std::string str;
for (char ch : id) { for (char ch : id) {
if (ch == '\\') { if (ch == '\\') {
@ -208,7 +214,7 @@ struct ShowWorker
str += "╲"; str += "╲";
continue; continue;
} }
if (ch == '"') if (ch == '"' || ch == '<' || ch == '>')
str += "\\"; str += "\\";
str += ch; str += ch;
} }