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)); } };