mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Add error on illegal --prefix etc. values (#5507).
This commit is contained in:
+9
-2
@@ -216,6 +216,13 @@ string VString::removeWhitespace(const string& str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VString::isIdentifier(const string& str) {
|
||||
for (const char c : str) {
|
||||
if (!isIdentifierChar(c)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VString::isWhitespace(const string& str) {
|
||||
for (const char c : str) {
|
||||
if (!std::isspace(c)) return false;
|
||||
@@ -256,8 +263,8 @@ string VString::replaceWord(const string& str, const string& from, const string&
|
||||
UASSERT_STATIC(len > 0, "Cannot replace empty string");
|
||||
for (size_t pos = 0; (pos = result.find(from, pos)) != string::npos; pos += len) {
|
||||
// Only replace whole words
|
||||
if (((pos > 0) && VString::isWordChar(result[pos - 1])) || //
|
||||
((pos + len < result.size()) && VString::isWordChar(result[pos + len]))) {
|
||||
if (((pos > 0) && VString::isIdentifierChar(result[pos - 1])) || //
|
||||
((pos + len < result.size()) && VString::isIdentifierChar(result[pos + len]))) {
|
||||
continue;
|
||||
}
|
||||
result.replace(pos, len, to);
|
||||
|
||||
Reference in New Issue
Block a user