From d0a3560c921425aa429a09caa7e5c6e41587ed21 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 30 Dec 2011 11:36:09 +0100 Subject: [PATCH] Rewrite Tokenizer::hasEnumsWithTypedef by using 'findmatch' in order to shorten the code. --- lib/tokenize.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index de3deb59f..d2b11465f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2529,13 +2529,11 @@ bool Tokenizer::hasEnumsWithTypedef() { for (const Token *tok = _tokens; tok; tok = tok->next()) { if (Token::Match(tok, "enum %var% {")) { - for (const Token *tok2 = tok->tokAt(3); tok2; tok2 = tok2->next()) { - if (tok2->str() == "typedef") { - syntaxError(tok2); - return true; - } else if (tok2->str() == "}") { - break; - } + tok = tok->tokAt(2); + const Token *tok2 = Token::findmatch(tok, "typedef", tok->link()); + if (tok2) { + syntaxError(tok2); + return true; } } }