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;
unsigned int parantheses = 0; // ()
unsigned int brackets = 0; // []
const std::string &expr = it->first;
for (std::string::size_type pos = 0; pos < expr.size(); ++pos) {
if (expr[pos] == '(') {
for (const Token *tok = it->second.start; tok && tok != it->second.end; tok = tok->next()) {
if (tok->str() == "(") {
++parantheses;
} else if (expr[pos] == ')') {
} else if (tok->str() == ")") {
if (parantheses == 0) {
valid = false;
break;
}
--parantheses;
} else if (expr[pos] == '[') {
} else if (tok->str() == "[") {
++brackets;
} else if (expr[pos] == ']') {
} else if (tok->str() == "]") {
if (brackets == 0) {
valid = false;
break;