Fixed some more DOT generation stuff.
This commit is contained in:
17
src/util.cpp
17
src/util.cpp
@@ -21,15 +21,28 @@ std::string removeBeginning(std::string to_remove)
|
||||
return to_return;
|
||||
}
|
||||
|
||||
std::string replace(std::string first, std::string search, std::string replace) {
|
||||
std::string replaceExEscape(std::string first, std::string search, std::string replace) {
|
||||
size_t pos = 0;
|
||||
while (pos < first.size()-search.size()) {
|
||||
pos = first.find(search, pos);
|
||||
if (pos == std::string::npos)
|
||||
break;
|
||||
//std::cout << "Position is " << pos << " size of first is " << first.size() << " size of replace is " << replace.size() << std::endl;
|
||||
//If excaped, don't worry about it.
|
||||
if (pos > 0) {
|
||||
int numBackslashes = 0;
|
||||
int countBack = 1;
|
||||
while (pos-countBack >= 0 && first[pos-countBack] == '\\') {
|
||||
numBackslashes++;
|
||||
countBack++;
|
||||
}
|
||||
if (numBackslashes % 2 == 1) {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
first = first.replace(pos, search.size(), replace);
|
||||
pos++;
|
||||
pos += replace.size();
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user