Fixed #1959 (Do you support the oracle Pro*C ?)

This commit is contained in:
Daniel Marjamäki 2010-08-31 21:40:51 +02:00 committed by Kimmo Varis
parent 42dfd255e3
commit 55e0e435bd
2 changed files with 35 additions and 0 deletions

View File

@ -1701,6 +1701,30 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s
createTokens(code); createTokens(code);
// remove inline SQL (Oracle PRO*C). Ticket: #1959
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (Token::simpleMatch(tok, "EXEC SQL"))
{
// delete all tokens until ";"
while (tok && tok->str() != ";")
tok->deleteThis();
// insert "asm ( ) ;"
if (tok)
{
tok->insertToken("asm");
tok = tok->next();
tok->insertToken("(");
tok = tok->next();
tok->insertToken(")");
tok = tok->next();
tok->insertToken(";");
}
}
}
if (!createLinks()) if (!createLinks())
{ {
// Source has syntax errors, can't proceed // Source has syntax errors, can't proceed

View File

@ -258,6 +258,8 @@ private:
TEST_CASE(bitfields5); // ticket #1956 TEST_CASE(bitfields5); // ticket #1956
TEST_CASE(microsoftMFC); TEST_CASE(microsoftMFC);
TEST_CASE(sql);
} }
@ -4610,6 +4612,15 @@ private:
const char code4[] = "class MyDialog : public CDialog { DECLARE_DYNAMIC_CLASS(MyDialog) private: CString text; };"; const char code4[] = "class MyDialog : public CDialog { DECLARE_DYNAMIC_CLASS(MyDialog) private: CString text; };";
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code4,false)); ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code4,false));
} }
void sql()
{
// 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));
}
}; };
REGISTER_TEST(TestTokenizer) REGISTER_TEST(TestTokenizer)