Renamed pro c sql to embedded sql

This commit is contained in:
Daniel Marjamäki 2017-11-03 21:04:12 +01:00
parent 19af9bc216
commit 4d8f069907
4 changed files with 18 additions and 18 deletions

4
cfg/embedded_sql.cfg Executable file
View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<def format="2">
<define name="EXEC" value="__CPPCHECK_EMBEDDED_SQL_EXEC__"/>
</def>

View File

@ -1,4 +0,0 @@
<?xml version="1.0"?>
<def format="2">
<define name="EXEC" value="__CPPCHECK_PRO_C_EXEC__"/>
</def>

6
lib/tokenize.cpp Normal file → Executable file
View File

@ -1980,7 +1980,7 @@ void Tokenizer::simplifyRoundCurlyParentheses()
void Tokenizer::simplifySQL()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, "__CPPCHECK_PRO_C_EXEC__ SQL")) {
if (Token::simpleMatch(tok, "__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL")) {
const Token *end = findSQLBlockEnd(tok);
if (end == nullptr)
syntaxError(nullptr);
@ -9893,8 +9893,8 @@ const Token *Tokenizer::findSQLBlockEnd(const Token *tokSQLStart) const
for (const Token *tok = tokSQLStart->tokAt(2); tok != nullptr; tok = tok->next()) {
if (tokLastEnd == nullptr && tok->str() == ";")
tokLastEnd = tok;
else if (tok->str() == "__CPPCHECK_PRO_C_EXEC__") {
if (Token::simpleMatch(tok->tokAt(-2), "END - __CPPCHECK_PRO_C_EXEC__ ;"))
else if (tok->str() == "__CPPCHECK_EMBEDDED_SQL_EXEC__") {
if (Token::simpleMatch(tok->tokAt(-2), "END - __CPPCHECK_EMBEDDED_SQL_EXEC__ ;"))
return tok->next();
return tokLastEnd;
}

22
test/testtokenize.cpp Normal file → Executable file
View File

@ -5782,19 +5782,19 @@ private:
void simplifySQL() {
// Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages
// ticket: #1959
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL SELECT A FROM B\"\" ) ;", tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL SELECT A FROM B;",false));
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL",false), InternalError);
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL SELECT A FROM B\"\" ) ;", tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL SELECT A FROM B;",false));
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL",false), InternalError);
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - __CPPCHECK_PRO_C_EXEC__\"\" ) ; asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL COMMIT\"\" ) ;",
tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1(A); END; END-__CPPCHECK_PRO_C_EXEC__; __CPPCHECK_PRO_C_EXEC__ SQL COMMIT;",false));
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL UPDATE A SET B = C\"\" ) ; asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL COMMIT\"\" ) ;",
tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL UPDATE A SET B = C; __CPPCHECK_PRO_C_EXEC__ SQL COMMIT;",false));
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL COMMIT\"\" ) ; asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - __CPPCHECK_PRO_C_EXEC__\"\" ) ;",
tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL COMMIT; __CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1(A); END; END-__CPPCHECK_PRO_C_EXEC__;",false));
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - __CPPCHECK_EMBEDDED_SQL_EXEC__\"\" ) ; asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL COMMIT\"\" ) ;",
tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL EXECUTE BEGIN Proc1(A); END; END-__CPPCHECK_EMBEDDED_SQL_EXEC__; __CPPCHECK_EMBEDDED_SQL_EXEC__ SQL COMMIT;",false));
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL UPDATE A SET B = C\"\" ) ; asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL COMMIT\"\" ) ;",
tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL UPDATE A SET B = C; __CPPCHECK_EMBEDDED_SQL_EXEC__ SQL COMMIT;",false));
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL COMMIT\"\" ) ; asm ( \"\"__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - __CPPCHECK_EMBEDDED_SQL_EXEC__\"\" ) ;",
tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL COMMIT; __CPPCHECK_EMBEDDED_SQL_EXEC__ SQL EXECUTE BEGIN Proc1(A); END; END-__CPPCHECK_EMBEDDED_SQL_EXEC__;",false));
ASSERT_THROW(tokenizeAndStringify("int f(){ __CPPCHECK_PRO_C_EXEC__ SQL } int a;",false), InternalError);
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL int f(){",false), InternalError);
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL END-__CPPCHECK_PRO_C_EXEC__ int a;",false), InternalError);
ASSERT_THROW(tokenizeAndStringify("int f(){ __CPPCHECK_EMBEDDED_SQL_EXEC__ SQL } int a;",false), InternalError);
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL int f(){",false), InternalError);
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_EMBEDDED_SQL_EXEC__ SQL END-__CPPCHECK_EMBEDDED_SQL_EXEC__ int a;",false), InternalError);
}
void simplifyCAlternativeTokens() {