Permalink
Browse files

several fixes for Delphi 10.3 Rio compatibility

  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Nov 22, 2018
1 parent 1e29dc5 commit bd9f4b2398fd30c49b988f3ab04ec858d35f22b8
Showing with 47 additions and 16 deletions.
  1. +37 −8 SynSQLite3RegEx.pas
  2. +1 −1 SynSelfTests.pas
  3. +8 −6 Synopse.inc
  4. +1 −1 SynopseCommit.inc
@@ -76,6 +76,7 @@ interface
// download from http://www.regular-expressions.info/download/TPerlRegEx.zip
PCRE,
{$endif}
{ TODO : use FLRE as pure pascal fast alernative }
SysUtils,
SynCommons,
SynSQLite3;
@@ -97,26 +98,41 @@ TPCREcache = record
TPCREcaches = array of TPCREcache;
PPCREcaches = ^TPCREcaches;
{$ifdef ISDELPHI103}
{$define PCRE16}
// System.RegularExpressionsAPI changed from a UTF-8 to UTF-16 calls :(
{$endif ISDELPHI103}
const
// small regex compilation cache is enough in practice
MAX_PCRECACHE = 16;
procedure InternalRegExp(Context: TSQLite3FunctionContext;
argc: integer; var argv: TSQLite3ValueArray); cdecl;
var regexp, text: PUTF8Char;
errMsg: PAnsiChar;
errMsg: PAnsiChar; // even for PCRE16 :)
errPos: integer;
found, result: boolean;
i, n: integer;
reg: PPCRE;
cache: PPCREcaches;
c: array[1..sizeof(TPCREcache)] of byte; // bulk mem block to avoid ref count
procedure CompileError;
begin // sub procedure to avoid temp RawUTF8
sqlite3.result_error(Context,pointer(FormatUTF8(
'REGEXP "%": % at pos %',[regexp,errMsg,errPos])));
end;
{$ifdef PCRE16}
temp: TSynTempBuffer;
function ToUTF16(p: PUTF8Char; var temp: TSynTempBuffer): integer; inline;
var len: integer;
begin
len := StrLen(p);
temp.Init(len*2+2);
result := UTF8ToWideChar(temp.buf,p,len);
end;
{$endif PCRE16}
procedure CompileError;
begin // sub procedure to avoid temp RawUTF8
sqlite3.result_error(Context,pointer(FormatUTF8(
'REGEXP "%": % at pos %',[regexp,errMsg,errPos])));
end;
begin
if argc<>2 then begin
ErrorWrongNumberOfArgs(Context);
@@ -145,7 +161,13 @@ procedure CompileError;
break;
end;
if not found then begin
{$ifdef PCRE16}
ToUTF16(regexp,temp);
reg := pcre_compile(temp.buf,0,@errMsg,@errPos,nil);
temp.Done;
{$else}
reg := pcre_compile(pointer(regexp),0,@errMsg,@errPos,nil);
{$endif PCRE16}
if reg=nil then begin
CompileError;
exit;
@@ -165,8 +187,15 @@ procedure CompileError;
extra := pcre_study(compiled,0,@errMsg);
end;
end;
with cache^[0] do
with cache^[0] do begin
{$ifdef PCRE16}
i := ToUTF16(text,temp);
result := pcre_exec(compiled,extra,temp.buf,i,0,PCRE_NO_UTF16_CHECK,nil,0)>=0;
temp.Done;
{$else}
result := pcre_exec(compiled,extra,pointer(text),StrLen(text),0,PCRE_NO_UTF8_CHECK,nil,0)>=0;
{$endif PCRE16}
end;
// (faster with PCRE_NO_UTF8_CHECK option)
sqlite3.result_int64(Context,ord(result));
end;
@@ -1116,7 +1116,7 @@ TComplexNumber = class(TPersistent)
end;
/// a record used by IComplexCalculator.EchoRecord
{$ifdef UNICODE}TConsultaNav = record{$else}TConsultaNav = object{$endif}
TConsultaNav = packed record
public
MaxRows, Row0, RowCount: int64;
IsSQLUpdateBack, EOF: boolean;
@@ -25,7 +25,7 @@
Contributor(s):
Alfred Glaenzer (alf)
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -107,7 +107,7 @@
// define this if you compile the unit within a Delphi package
// - it will avoid error like "[DCC Error] E2201 Need imported data reference ($G)
// to access 'VarCopyProc' from unit 'SynCommons'"
// - shall be set at the package options level, and left untouched by default
// - shall be set at the package options level, and left untouched by default
{$define WITHLOG}
// if defined, logging will be supported via the TSQLLog family
@@ -149,7 +149,7 @@
{.$define WITH_ERMS}
// you may define this to enable REP MOVSB/STOSB for Fillchar/Move if cfERMS
// flag is available in Intel's CpuFeatures
// flag is available in Intel's CpuFeatures
// -> disabled by default, since in practice it is much slower for small blocks
{.$define NOXPOWEREDNAME}
@@ -490,7 +490,7 @@
{$define ISDELPHIXE5}
{$define PUBLISHRECORD}
// if defined, will handle RTTI available only since Delphi XE5 for
// record published properties
// record published properties
{$ifend}
{$if CompilerVersion >= 27.0}
{$define ISDELPHIXE6}
@@ -517,6 +517,9 @@
{$endif}
{$endif}
{$ifend}
{$if CompilerVersion >= 33.0}
{$define ISDELPHI103}
{$ifend}
{$ifend CompilerVersion >= 17}
{$ifopt O-} // if we don't expect fast code, don't optimize the framework
{$undef ENHANCEDRTL}
@@ -595,7 +598,7 @@
{$endif}
{$ifdef NOSQLITE3STATIC}
// our proprietary crypto expects a statically linked custom sqlite3.c
// our proprietary crypto expects a statically linked custom sqlite3.c
{$define NOSQLITE3ENCRYPT}
{$endif}
@@ -613,4 +616,3 @@
{$endif}
{$endif}
@@ -1 +1 @@
'1.18.4885'
'1.18.4886'

0 comments on commit bd9f4b2

Please sign in to comment.