Add error on illegal --prefix etc. values (#5507).

This commit is contained in:
Wilson Snyder
2024-11-26 21:06:43 -05:00
parent 713dab278c
commit bee344d1ae
12 changed files with 97 additions and 9 deletions
+9 -2
View File
@@ -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);