diff --git a/gui/about.ui b/gui/about.ui index 50e33b1b9..a28d44248 100644 --- a/gui/about.ui +++ b/gui/about.ui @@ -78,7 +78,7 @@ - Copyright © 2007-2017 Cppcheck team. + Copyright © 2007-2018 Cppcheck team. true diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 065006c41..584f402db 100755 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1942,26 +1942,27 @@ void Tokenizer::simplifyRoundCurlyParentheses() void Tokenizer::simplifySQL() { for (Token *tok = list.front(); tok; tok = tok->next()) { - if (Token::simpleMatch(tok, "__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL")) { - const Token *end = findSQLBlockEnd(tok); - if (end == nullptr) - syntaxError(nullptr); + if (!Token::simpleMatch(tok, "__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL")) + continue; - const std::string instruction = tok->stringifyList(end); - // delete all tokens until the embedded SQL block end - Token::eraseTokens(tok, end); + const Token *end = findSQLBlockEnd(tok); + if (end == nullptr) + syntaxError(nullptr); - // insert "asm ( "instruction" ) ;" - tok->str("asm"); - // it can happen that 'end' is NULL when wrong code is inserted - if (!tok->next()) - tok->insertToken(";"); - tok->insertToken(")"); - tok->insertToken("\"" + instruction + "\""); - tok->insertToken("("); - // jump to ';' and continue - tok = tok->tokAt(3); - } + const std::string instruction = tok->stringifyList(end); + // delete all tokens until the embedded SQL block end + Token::eraseTokens(tok, end); + + // insert "asm ( "instruction" ) ;" + tok->str("asm"); + // it can happen that 'end' is NULL when wrong code is inserted + if (!tok->next()) + tok->insertToken(";"); + tok->insertToken(")"); + tok->insertToken("\"" + instruction + "\""); + tok->insertToken("("); + // jump to ';' and continue + tok = tok->tokAt(3); } } @@ -10058,7 +10059,7 @@ void Tokenizer::SimplifyNamelessRValueReferences() } } -const Token *Tokenizer::findSQLBlockEnd(const Token *tokSQLStart) const +const Token *Tokenizer::findSQLBlockEnd(const Token *tokSQLStart) { const Token *tokLastEnd = nullptr; for (const Token *tok = tokSQLStart->tokAt(2); tok != nullptr; tok = tok->next()) { diff --git a/lib/tokenize.h b/lib/tokenize.h index 3a0552667..37ce3cb46 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -719,7 +719,7 @@ private: void printUnknownTypes() const; /** Find end of SQL (or PL/SQL) block */ - const Token *findSQLBlockEnd(const Token *tokSQLStart) const; + static const Token *findSQLBlockEnd(const Token *tokSQLStart); public: