mORMot and Open Source friends
Check-in [6273ad17b3]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{6054} two minor fixes - intercept exception in case FPCUSEVERSIONINFO is defined but no resource info is available - use UTF-8 codepage if none is defined
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6273ad17b38f1068a5ed25030c1c9442cb11ca97
User & Date: ab 2020-06-13 10:08:12
Context
2020-06-13
10:13
{6055} updated HTTP_REQUEST_AUTH_INFO fields - from https://github.com/synopse/mORMot/pull/319 check-in: 74c8713250 user: ab tags: trunk
10:08
{6054} two minor fixes - intercept exception in case FPCUSEVERSIONINFO is defined but no resource info is available - use UTF-8 codepage if none is defined check-in: 6273ad17b3 user: ab tags: trunk
2020-06-12
09:51
{6053} fixed TMongoDatabase.CreateUser with MongoDB 4.x check-in: fd93a93e5e user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynCommons.pas.

20931
20932
20933
20934
20935
20936
20937
20938
20939



20940
20941
20942
20943
20944
20945
20946
.....
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
.....
40638
40639
40640
40641
40642
40643
40644
40645

40646
40647
40648
40649
40650
40651
40652
.....
40682
40683
40684
40685
40686
40687
40688


40689
40690
40691
40692
40693
40694
40695
.....
62804
62805
62806
62807
62808
62809
62810
62811
62812
62813
62814
62815
62816
62817
62818
{$ifdef FPC_HAS_CPSTRING}

{$ifdef FPC_X64MM}
procedure _ansistr_setlength_new(var s: RawByteString; len: PtrInt; cp: cardinal);
var p, new: PAnsiChar;
    l: PtrInt;
begin
  if cp<=CP_OEMCP then // TranslatePlaceholderCP logic
    cp := DefaultSystemCodePage;



  new := FastNewString(len,cp);
  p := pointer(s);
  if p<>nil then begin
    l := PStrLen(p-_STRLEN)^+1;
    if l>len then
      l := len;
    MoveFast(p^,new^,l);
................................................................................
  if (cp=CP_UTF8) or (cp>=CP_SQLRAWBLOB) then
    dest := u else
    TSynAnsiConvert.Engine(cp).UTF8BufferToAnsi(pointer(u),length(u),dest);
end;

procedure _ansistr_concat_multi_utf8(var dest: RawByteString;
  const s: array of RawByteString; cp: cardinal);
var first,len,i,l: TStrLen;
    cpf,cpi: cardinal;
    p: pointer;
    new: PAnsiChar;
begin
  if cp<=CP_OEMCP then
    cp := CP_UTF8;
  first := 0;
................................................................................
      finally
        Freemem(Pt);
      end;
    end;
  end;
  {$else MSWINDOWS}
  {$ifdef FPCUSEVERSIONINFO} // FPC 3.0+ if enabled in Synopse.inc / project options
  if aFileName<>'' then begin

    VI := TVersionInfo.Create;
    try
      if (aFileName<>ExeVersion.ProgramFileName) and (aFileName<>ParamStr(0)) then
        VI.Load(aFileName) else
        VI.Load(HInstance); // load info for currently running program
      aMajor := VI.FixedInfo.FileVersion[0];
      aMinor := VI.FixedInfo.FileVersion[1];
................................................................................
        ProductName := Values['ProductName'];
        ProductVersion := Values['ProductVersion'];
        Comments := Values['Comments'];
      end;
    finally
      VI.Free;
    end;


  end;
  {$endif FPCUSEVERSIONINFO}
  {$endif MSWINDOWS}
  SetVersion(aMajor,aMinor,aRelease,aBuild);
  if fBuildDateTime=0 then  // get build date from file age
    fBuildDateTime := FileAgeToDateTime(aFileName);
  if fBuildDateTime<>0 then
................................................................................
    PatchJmp(@fpc_unicodestr_decr_ref,@_ansistr_decr_ref,$27);  // fpclen=$3f
    PatchJmp(@fpc_unicodestr_assign,@_ansistr_assign,$3f);      // fpclen=$3f
    PatchCode(@fpc_dynarray_incr_ref,@_dynarray_incr_ref,$17);  // fpclen=$2f
    PatchJmp(@fpc_dynarray_clear,@_dynarray_decr_ref,$2f,PtrUInt(@_dynarray_decr_ref_free));
    RedirectCode(@fpc_dynarray_decr_ref,@fpc_dynarray_clear);
    {$ifdef FPC_HAS_CPSTRING}
    {$ifdef LINUX}
    if DefaultSystemCodePage=CP_UTF8 then begin
      RedirectRtl(@_fpc_ansistr_concat,@_ansistr_concat_utf8);
      RedirectRtl(@_fpc_ansistr_concat_multi,@_ansistr_concat_multi_utf8);
    end;
    {$endif LINUX}
    {$ifdef FPC_X64MM}
    RedirectCode(@fpc_ansistr_setlength,@_ansistr_setlength);
    {$endif FPC_X64MM}






|

>
>
>







 







|







 







|
>







 







>
>







 







|







20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
.....
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
.....
40641
40642
40643
40644
40645
40646
40647
40648
40649
40650
40651
40652
40653
40654
40655
40656
.....
40686
40687
40688
40689
40690
40691
40692
40693
40694
40695
40696
40697
40698
40699
40700
40701
.....
62810
62811
62812
62813
62814
62815
62816
62817
62818
62819
62820
62821
62822
62823
62824
{$ifdef FPC_HAS_CPSTRING}

{$ifdef FPC_X64MM}
procedure _ansistr_setlength_new(var s: RawByteString; len: PtrInt; cp: cardinal);
var p, new: PAnsiChar;
    l: PtrInt;
begin
  if cp<=CP_OEMCP then begin // TranslatePlaceholderCP logic
    cp := DefaultSystemCodePage;
    if cp=0 then
      cp := CP_NONE;
  end;
  new := FastNewString(len,cp);
  p := pointer(s);
  if p<>nil then begin
    l := PStrLen(p-_STRLEN)^+1;
    if l>len then
      l := len;
    MoveFast(p^,new^,l);
................................................................................
  if (cp=CP_UTF8) or (cp>=CP_SQLRAWBLOB) then
    dest := u else
    TSynAnsiConvert.Engine(cp).UTF8BufferToAnsi(pointer(u),length(u),dest);
end;

procedure _ansistr_concat_multi_utf8(var dest: RawByteString;
  const s: array of RawByteString; cp: cardinal);
var first,len,i,l: integer; // should NOT be PtrInt/SizeInt to avoid FPC bug with high(s) :(
    cpf,cpi: cardinal;
    p: pointer;
    new: PAnsiChar;
begin
  if cp<=CP_OEMCP then
    cp := CP_UTF8;
  first := 0;
................................................................................
      finally
        Freemem(Pt);
      end;
    end;
  end;
  {$else MSWINDOWS}
  {$ifdef FPCUSEVERSIONINFO} // FPC 3.0+ if enabled in Synopse.inc / project options
  if aFileName<>'' then
  try
    VI := TVersionInfo.Create;
    try
      if (aFileName<>ExeVersion.ProgramFileName) and (aFileName<>ParamStr(0)) then
        VI.Load(aFileName) else
        VI.Load(HInstance); // load info for currently running program
      aMajor := VI.FixedInfo.FileVersion[0];
      aMinor := VI.FixedInfo.FileVersion[1];
................................................................................
        ProductName := Values['ProductName'];
        ProductVersion := Values['ProductVersion'];
        Comments := Values['Comments'];
      end;
    finally
      VI.Free;
    end;
  except
    // just ignore if version information resource is missing
  end;
  {$endif FPCUSEVERSIONINFO}
  {$endif MSWINDOWS}
  SetVersion(aMajor,aMinor,aRelease,aBuild);
  if fBuildDateTime=0 then  // get build date from file age
    fBuildDateTime := FileAgeToDateTime(aFileName);
  if fBuildDateTime<>0 then
................................................................................
    PatchJmp(@fpc_unicodestr_decr_ref,@_ansistr_decr_ref,$27);  // fpclen=$3f
    PatchJmp(@fpc_unicodestr_assign,@_ansistr_assign,$3f);      // fpclen=$3f
    PatchCode(@fpc_dynarray_incr_ref,@_dynarray_incr_ref,$17);  // fpclen=$2f
    PatchJmp(@fpc_dynarray_clear,@_dynarray_decr_ref,$2f,PtrUInt(@_dynarray_decr_ref_free));
    RedirectCode(@fpc_dynarray_decr_ref,@fpc_dynarray_clear);
    {$ifdef FPC_HAS_CPSTRING}
    {$ifdef LINUX}
    if (DefaultSystemCodePage=CP_UTF8) or (DefaultSystemCodePage=0) then begin
      RedirectRtl(@_fpc_ansistr_concat,@_ansistr_concat_utf8);
      RedirectRtl(@_fpc_ansistr_concat_multi,@_ansistr_concat_multi_utf8);
    end;
    {$endif LINUX}
    {$ifdef FPC_X64MM}
    RedirectCode(@fpc_ansistr_setlength,@_ansistr_setlength);
    {$endif FPC_X64MM}

Changes to SynopseCommit.inc.

1
'1.18.6053'
|
1
'1.18.6054'