From e66156ab5c1ea470ce3d6f36f60af94d6a542f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 5 Dec 2009 22:19:54 +0100 Subject: [PATCH] Fixed #1049 (Tokenizer: internal error for 'std::list w1, w2;') --- lib/tokenize.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 30f1841e3..18cfa1f72 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3118,15 +3118,24 @@ void Tokenizer::simplifyVarDecl() { tok2->str(";"); insertTokens(tok2, type0, typelen); - std::list link; + std::stack link1; + std::stack link2; while (((typelen--) > 0) && (0 != (tok2 = tok2->next()))) { if (tok2->str() == "(") - link.push_back(tok2); - else if (tok2->str() == ")" && !link.empty()) + link1.push(tok2); + else if (tok2->str() == ")" && !link1.empty()) { - Token::createMutualLinks(tok2, link.back()); - link.pop_back(); + Token::createMutualLinks(tok2, link1.top()); + link1.pop(); + } + + else if (tok2->str() == "[") + link2.push(tok2); + else if (tok2->str() == "]" && !link2.empty()) + { + Token::createMutualLinks(tok2, link2.top()); + link2.pop(); } } }