8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00

Let ExtDS preprocessor and SQL parser handle '\r', '\n' and '\r\n' as end of line.

It should fix bug CORE-5783 : execute statement ignores the text of the SQL-query after a comment of the form "-"
This commit is contained in:
hvlad 2018-04-03 01:03:36 +03:00
parent 07a95159c9
commit a9b8442b22
3 changed files with 45 additions and 23 deletions

View File

@ -323,17 +323,12 @@ bool Parser::yylexSkipSpaces()
if (lex.ptr >= lex.end)
return false;
c = *lex.ptr++;
if (yylexSkipEol())
continue;
// Process comments
if (c == '\n')
{
lex.lines++;
lex.line_start = lex.ptr;
continue;
}
c = *lex.ptr++;
if (c == '-' && lex.ptr < lex.end && *lex.ptr == '-')
{
// single-line
@ -341,12 +336,9 @@ bool Parser::yylexSkipSpaces()
lex.ptr++;
while (lex.ptr < lex.end)
{
if ((c = *lex.ptr++) == '\n')
{
lex.lines++;
lex.line_start = lex.ptr; // + 1; // CVC: +1 left out.
lex.ptr++;
if (yylexSkipEol())
break;
}
}
if (lex.ptr >= lex.end)
return false;
@ -361,17 +353,14 @@ bool Parser::yylexSkipSpaces()
lex.ptr++;
while (lex.ptr < lex.end)
{
if (yylexSkipEol())
continue;
if ((c = *lex.ptr++) == '*')
{
if (*lex.ptr == '/')
break;
}
if (c == '\n')
{
lex.lines++;
lex.line_start = lex.ptr; // + 1; // CVC: +1 left out.
}
}
if (lex.ptr >= lex.end)
{
@ -395,6 +384,34 @@ bool Parser::yylexSkipSpaces()
}
bool Parser::yylexSkipEol()
{
bool eol = false;
const TEXT c = *lex.ptr;
if (c == '\r')
{
lex.ptr++;
if (lex.ptr < lex.end && *lex.ptr == '\n')
lex.ptr++;
eol = true;
}
else if (c == '\n')
{
lex.ptr++;
eol = true;
}
if (eol)
{
lex.lines++;
lex.line_start = lex.ptr; // + 1; // CVC: +1 left out.
}
return eol;
}
int Parser::yylexAux()
{
thread_db* tdbb = JRD_get_thread_data();

View File

@ -223,6 +223,7 @@ private:
int yylex();
bool yylexSkipSpaces();
bool yylexSkipEol(); // returns true if EOL is detected and skipped
int yylexAux();
void yyerror(const TEXT* error_string);

View File

@ -1067,15 +1067,19 @@ static TokenType getToken(const char** begin, const char* end)
case '-':
if (p < end && *p == '-')
{
while (p < end)
while (++p < end)
{
if (*p++ == '\n')
if (*p == '\r')
{
p--;
ret = ttComment;
p++;
if (p < end && *p == '\n')
p++;
break;
}
else if (*p == '\n')
break;
}
ret = ttComment;
}
else {
ret = ttOther;