mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-09 15:26:29 +02:00
* Avoid exception frame in ansistring compare for cases where codepage is equal
git-svn-id: trunk@35603 -
This commit is contained in:
parent
4b1ac10e0d
commit
ae6b9652fc
@ -687,6 +687,26 @@ end;
|
|||||||
|
|
||||||
{$ifndef FPC_HAS_ANSISTR_COMPARE_EQUAL}
|
{$ifndef FPC_HAS_ANSISTR_COMPARE_EQUAL}
|
||||||
{$define FPC_HAS_ANSISTR_COMPARE_EQUAL}
|
{$define FPC_HAS_ANSISTR_COMPARE_EQUAL}
|
||||||
|
|
||||||
|
Function fpc_utf8_Compare_equal(Const S1,S2 : RawByteString): SizeInt;
|
||||||
|
|
||||||
|
Var
|
||||||
|
r1,r2 : RawByteString;
|
||||||
|
L1,L2 : SizeInt;
|
||||||
|
begin
|
||||||
|
r1:=S1;
|
||||||
|
r2:=S2;
|
||||||
|
//convert them to utf8 then compare
|
||||||
|
SetCodePage(r1,65001);
|
||||||
|
SetCodePage(r2,65001);
|
||||||
|
L1:=Length(r1);
|
||||||
|
L2:=Length(r2);
|
||||||
|
Result:=L1-L2;
|
||||||
|
if Result = 0 then
|
||||||
|
if L1>0 then
|
||||||
|
result:=CompareByte(r1[1],r2[1],L1);
|
||||||
|
end;
|
||||||
|
|
||||||
Function fpc_AnsiStr_Compare_equal(const S1,S2 : RawByteString): SizeInt;[Public,Alias : 'FPC_ANSISTR_COMPARE_EQUAL']; compilerproc;
|
Function fpc_AnsiStr_Compare_equal(const S1,S2 : RawByteString): SizeInt;[Public,Alias : 'FPC_ANSISTR_COMPARE_EQUAL']; compilerproc;
|
||||||
{
|
{
|
||||||
Compares 2 AnsiStrings for equality/inequality only;
|
Compares 2 AnsiStrings for equality/inequality only;
|
||||||
@ -697,7 +717,6 @@ Function fpc_AnsiStr_Compare_equal(const S1,S2 : RawByteString): SizeInt;[Public
|
|||||||
Var
|
Var
|
||||||
MaxI,Temp : SizeInt;
|
MaxI,Temp : SizeInt;
|
||||||
cp1,cp2 : TSystemCodePage;
|
cp1,cp2 : TSystemCodePage;
|
||||||
r1,r2 : RawByteString;
|
|
||||||
begin
|
begin
|
||||||
if pointer(S1)=pointer(S2) then
|
if pointer(S1)=pointer(S2) then
|
||||||
begin
|
begin
|
||||||
@ -728,17 +747,7 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
r1:=S1;
|
Result:=fpc_utf8_Compare_equal(S1,S2);
|
||||||
r2:=S2;
|
|
||||||
//convert them to utf8 then compare
|
|
||||||
SetCodePage(r1,65001);
|
|
||||||
SetCodePage(r2,65001);
|
|
||||||
Maxi:=Length(r1);
|
|
||||||
temp:=Length(r2);
|
|
||||||
Result := Maxi - temp;
|
|
||||||
if Result = 0 then
|
|
||||||
if MaxI>0 then
|
|
||||||
result:=CompareByte(r1[1],r2[1],MaxI);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$endif FPC_HAS_ANSISTR_COMPARE_EQUAL}
|
{$endif FPC_HAS_ANSISTR_COMPARE_EQUAL}
|
||||||
|
Loading…
Reference in New Issue
Block a user