diff --git a/src/dsql/Parser.cpp b/src/dsql/Parser.cpp index b9f6d66597..fc56c3e2cb 100644 --- a/src/dsql/Parser.cpp +++ b/src/dsql/Parser.cpp @@ -21,6 +21,7 @@ */ #include "firebird.h" +#include #include "../dsql/Parser.h" #include "../jrd/jrd.h" @@ -123,17 +124,20 @@ void Parser::transformString(const char* start, unsigned length, string& dest) const char* s = lex.start + mark.pos; buffer.add(pos, s - pos); + if (!isspace(UCHAR(pos[s - pos - 1]))) + buffer.add(' '); // fix _charset'' becoming invalid syntax _charsetX'' + const size_t count = buffer.getCount(); - const size_t newSize = count + 2 + mark.textLength * 2 + 1; + const size_t newSize = count + 2 + mark.str->str_length * 2 + 1; buffer.grow(newSize); char* p = buffer.begin() + count; *p++ = 'X'; *p++ = '\''; - const char* s2 = lex.start + mark.textPos; + const char* s2 = mark.str->str_data; - for (const char* end = lex.start + mark.textPos + mark.textLength; s2 < end; ++s2) + for (const char* end = s2 + mark.str->str_length; s2 < end; ++s2) { *p++ = HEX_DIGITS[UCHAR(*s2) >> 4]; *p++ = HEX_DIGITS[UCHAR(*s2) & 0xF]; diff --git a/src/dsql/Parser.h b/src/dsql/Parser.h index 59f2ad75eb..672204bb4e 100644 --- a/src/dsql/Parser.h +++ b/src/dsql/Parser.h @@ -91,8 +91,7 @@ private: { unsigned pos; unsigned length; - unsigned textPos; - unsigned textLength; + dsql_str* str; }; public: diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 98a49e42b7..6b4320ddd0 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -4422,10 +4422,7 @@ sql_string IntroducerMark mark; mark.pos = lex.last_token - lex.start; mark.length = lex.ptr - lex.last_token; - mark.textLength = str->str_length; - - fb_assert(mark.length - mark.textLength == 2); - mark.textPos = mark.pos + 1; + mark.str = str; introducerMarks.push(mark); }