From 01b05618e55e93b8728cd53b599d34b1326f246f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 2 Sep 2010 20:51:01 +0200 Subject: [PATCH] Tokenizer: Fixed Cppcheck warnings --- lib/tokenize.cpp | 15 +++++++-------- test/testtokenize.cpp | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7a58ccb63..252f36355 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1711,19 +1711,18 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s if (Token::simpleMatch(tok, "EXEC SQL")) { // delete all tokens until ";" - while (tok && tok->str() != ";") - tok->deleteThis(); + const Token *end = tok; + while (end && end->str() != ";") + end = end->next(); + Token::eraseTokens(tok, end); - // insert "asm ( ) ;" if (tok) { - tok->insertToken("asm"); - tok = tok->next(); + // insert "asm ( ) ;" + tok->str("asm"); tok->insertToken("("); tok = tok->next(); tok->insertToken(")"); - tok = tok->next(); - tok->insertToken(";"); } } } @@ -8347,7 +8346,7 @@ void Tokenizer::simplifyBorland() else if (tok2->str() == "__property" && Token::Match(tok2->previous(), ";|{|}|protected:|public:|__published:")) { - while (tok2 && !Token::Match(tok2, "{|;")) + while (tok2->next() && !Token::Match(tok2, "{|;")) tok2->deleteThis(); if (Token::simpleMatch(tok2, "{")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 04b3341aa..f24b80ea0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4631,7 +4631,7 @@ private: // Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages // ticket: #1959 const char code1[] = "; EXEC SQL SELECT A FROM B;"; - ASSERT_EQUALS("; ; asm ( ) ;", tokenizeAndStringify(code1,false)); + ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(code1,false)); } };