mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
@@ -116,6 +116,19 @@ string VString::quoteStringLiteralForShell(const string& str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
string VString::escapeStringForPath(const string &str) {
|
||||
if (str.find(R"(\\)") != string::npos) return str; // if it has been escaped already, don't do it again
|
||||
if (str.find('/') != string::npos) return str; // can be replaced by `__MINGW32__` or `_WIN32`
|
||||
string result;
|
||||
const char space = ' '; // escape space like this `Program Files`
|
||||
const char escape = '\\';
|
||||
for (const char c: str) {
|
||||
if (c == space || c == escape) result.push_back(escape);
|
||||
result.push_back(c);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string VString::spaceUnprintable(const string& str) {
|
||||
string out;
|
||||
for (const char c : str) {
|
||||
|
||||
Reference in New Issue
Block a user