checkDuplicateExpressions: validate tokens instead of string. Fix for my previous commit.

This commit is contained in:
Daniel Marjamäki 2011-12-01 17:43:29 +01:00
parent 31b576de3b
commit fddfd16758
1 changed files with 6 additions and 6 deletions

View File

@ -2548,19 +2548,19 @@ void CheckOther::checkExpressionRange(const std::list<Function> &constFunctions,
bool valid = true; bool valid = true;
unsigned int parantheses = 0; // () unsigned int parantheses = 0; // ()
unsigned int brackets = 0; // [] unsigned int brackets = 0; // []
const std::string &expr = it->first;
for (std::string::size_type pos = 0; pos < expr.size(); ++pos) { for (const Token *tok = it->second.start; tok && tok != it->second.end; tok = tok->next()) {
if (expr[pos] == '(') { if (tok->str() == "(") {
++parantheses; ++parantheses;
} else if (expr[pos] == ')') { } else if (tok->str() == ")") {
if (parantheses == 0) { if (parantheses == 0) {
valid = false; valid = false;
break; break;
} }
--parantheses; --parantheses;
} else if (expr[pos] == '[') { } else if (tok->str() == "[") {
++brackets; ++brackets;
} else if (expr[pos] == ']') { } else if (tok->str() == "]") {
if (brackets == 0) { if (brackets == 0) {
valid = false; valid = false;
break; break;