From fddfd1675827111b95212002cd2bb5e7b0e57321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 1 Dec 2011 17:43:29 +0100 Subject: [PATCH] checkDuplicateExpressions: validate tokens instead of string. Fix for my previous commit. --- lib/checkother.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index d047516d0..29b02b11a 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2548,19 +2548,19 @@ void CheckOther::checkExpressionRange(const std::list &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;