From b6763313c5706631797485f2ed5d4a8d93447879 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 26 Jan 2012 17:55:22 +0100 Subject: [PATCH] Tokenizer::simplifyQuestionMark: use links instead of indentation level number. --- lib/tokenize.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ad88d7b15..57e0be97b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4646,19 +4646,14 @@ bool Tokenizer::simplifyQuestionMark() // Find the ":" token.. Token *semicolon = 0; - { - unsigned int parlevel = 0; - for (Token *tok2 = tok; tok2; tok2 = tok2->next()) { - if (tok2->str() == "(") - ++parlevel; - else if (tok2->str() == ")") { - if (parlevel == 0) - break; - --parlevel; - } else if (parlevel == 0 && tok2->str() == ":") { - semicolon = tok2; - break; - } + for (Token *tok2 = tok; tok2; tok2 = tok2->next()) { + if (tok2->str() == "(" || tok2->str() == "[") + tok2 = tok2->link(); + else if (tok2->str() == ")" || tok2->str() == "]") + break; + else if (tok2->str() == ":") { + semicolon = tok2; + break; } } if (!semicolon || !semicolon->next())