Tokenizer: Fixed Cppcheck warnings

This commit is contained in:
Daniel Marjamäki 2010-09-02 20:51:01 +02:00
parent 80fdf1ca51
commit 01b05618e5
2 changed files with 8 additions and 9 deletions

View File

@ -1711,19 +1711,18 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s
if (Token::simpleMatch(tok, "EXEC SQL")) if (Token::simpleMatch(tok, "EXEC SQL"))
{ {
// delete all tokens until ";" // delete all tokens until ";"
while (tok && tok->str() != ";") const Token *end = tok;
tok->deleteThis(); while (end && end->str() != ";")
end = end->next();
Token::eraseTokens(tok, end);
// insert "asm ( ) ;"
if (tok) if (tok)
{ {
tok->insertToken("asm"); // insert "asm ( ) ;"
tok = tok->next(); tok->str("asm");
tok->insertToken("("); tok->insertToken("(");
tok = tok->next(); tok = tok->next();
tok->insertToken(")"); tok->insertToken(")");
tok = tok->next();
tok->insertToken(";");
} }
} }
} }
@ -8347,7 +8346,7 @@ void Tokenizer::simplifyBorland()
else if (tok2->str() == "__property" && else if (tok2->str() == "__property" &&
Token::Match(tok2->previous(), ";|{|}|protected:|public:|__published:")) Token::Match(tok2->previous(), ";|{|}|protected:|public:|__published:"))
{ {
while (tok2 && !Token::Match(tok2, "{|;")) while (tok2->next() && !Token::Match(tok2, "{|;"))
tok2->deleteThis(); tok2->deleteThis();
if (Token::simpleMatch(tok2, "{")) if (Token::simpleMatch(tok2, "{"))
{ {

View File

@ -4631,7 +4631,7 @@ private:
// Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages // Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages
// ticket: #1959 // ticket: #1959
const char code1[] = "; EXEC SQL SELECT A FROM B;"; const char code1[] = "; EXEC SQL SELECT A FROM B;";
ASSERT_EQUALS("; ; asm ( ) ;", tokenizeAndStringify(code1,false)); ASSERT_EQUALS("; asm ( ) ;", tokenizeAndStringify(code1,false));
} }
}; };