mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 10:33:13 +02:00
Support hierarchical verilation using protect lib (#2206)
This commit is contained in:
+19
-2
@@ -84,15 +84,32 @@ string VString::upcase(const string& str) {
|
||||
return out;
|
||||
}
|
||||
|
||||
string VString::quotePercent(const string& str) {
|
||||
string VString::quoteAny(const string& str, char tgt, char esc) {
|
||||
string out;
|
||||
for (string::const_iterator pos = str.begin(); pos != str.end(); ++pos) {
|
||||
if (*pos == '%') out += '%';
|
||||
if (*pos == tgt) out += esc;
|
||||
out += *pos;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
string VString::quoteStringLiteralForShell(const string& str) {
|
||||
string result;
|
||||
const char dquote = '"';
|
||||
const char escape = '\\';
|
||||
result.push_back(dquote); // Start quoted string
|
||||
result.push_back(escape);
|
||||
result.push_back(dquote); // "
|
||||
for (string::const_iterator it = str.begin(); it != str.end(); ++it) {
|
||||
if (*it == dquote || *it == escape) { result.push_back(escape); }
|
||||
result.push_back(*it);
|
||||
}
|
||||
result.push_back(escape);
|
||||
result.push_back(dquote); // "
|
||||
result.push_back(dquote); // Terminate quoted string
|
||||
return result;
|
||||
}
|
||||
|
||||
string VString::spaceUnprintable(const string& str) {
|
||||
string out;
|
||||
for (string::const_iterator pos = str.begin(); pos != str.end(); ++pos) {
|
||||
|
||||
Reference in New Issue
Block a user