Simplify overengineered search-replace code

This commit is contained in:
Dmitry-Me 2015-09-09 18:43:32 +03:00
parent 47f64df8aa
commit b2cd0aabf5
1 changed files with 5 additions and 3 deletions

View File

@ -6245,9 +6245,11 @@ bool Tokenizer::simplifyKnownVariables()
const Token * const valueToken = tok2->tokAt(4);
std::string value(valueToken->str());
if (tok2->str() == "sprintf") {
std::string::difference_type n = -1;
while (static_cast<std::string::size_type>(n = value.find("%%",n+1)) != std::string::npos) {
value.replace(n,2,"%");
std::string::size_type n = 0;
while ((n = value.find("%%", n)) != std::string::npos) {
// Replace "%%" with "%" - erase the first '%' and continue past the second '%'
value.erase(n, 1);
++n;
}
}
const unsigned int valueVarId(0);