mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 15:29:35 +01:00
lazutf8: UTF8StrLICompAnsiString: use Count as fixed bound, do not check for #0
git-svn-id: trunk@47162 -
This commit is contained in:
parent
3f37b16f15
commit
3fb03c60b1
@ -419,49 +419,22 @@ begin
|
|||||||
Result:=UTF8CompareText(U1,U2);
|
Result:=UTF8CompareText(U1,U2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function StrMaxLen(S: PChar; MaxLen: PtrUInt): PtrUInt;
|
function UTF8StrLCompAnsiString(S1, S2: PChar; Count: PtrUInt): PtrInt;
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=UTF8CompareStr(S1,Count,S2,Count);
|
||||||
if S=nil then exit;
|
|
||||||
while (Result<MaxLen) and (S^<>#0) do begin
|
|
||||||
inc(S);
|
|
||||||
inc(Result);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function UTF8StrLCompAnsiString(S1, S2: PChar; MaxLen: PtrUInt): PtrInt;
|
function UTF8StrLICompAnsiString(S1, S2: PChar; Count: PtrUInt): PtrInt;
|
||||||
var
|
var
|
||||||
Count1, Count2: PtrUInt;
|
|
||||||
begin
|
|
||||||
Count1:=StrMaxLen(S1,MaxLen);
|
|
||||||
Count2:=StrMaxLen(S2,MaxLen);
|
|
||||||
Result:=UTF8CompareStr(S1,Count1,S2,Count2);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function UTF8StrLICompAnsiString(S1, S2: PChar; MaxLen: PtrUInt): PtrInt;
|
|
||||||
var
|
|
||||||
Count1, Count2, Count: PtrUInt;
|
|
||||||
U1, U2: String;
|
U1, U2: String;
|
||||||
begin
|
begin
|
||||||
Count1:=StrMaxLen(S1,MaxLen);
|
|
||||||
Count2:=StrMaxLen(S2,MaxLen);
|
|
||||||
if Count1<Count2 then
|
|
||||||
Count:=Count1
|
|
||||||
else
|
|
||||||
Count:=Count2;
|
|
||||||
if Count>0 then begin
|
if Count>0 then begin
|
||||||
SetLength(U1,Count);
|
SetLength(U1,Count);
|
||||||
Move(S1^,PByte(U1)^,Count);
|
Move(S1^,PByte(U1)^,Count);
|
||||||
SetLength(U2,Count);
|
SetLength(U2,Count);
|
||||||
Move(S2^,PByte(U2)^,Count);
|
Move(S2^,PByte(U2)^,Count);
|
||||||
Result:=UTF8CompareText(U1,U2);
|
Result:=UTF8CompareText(U1,U2);
|
||||||
if Result<>0 then exit;
|
end else
|
||||||
end;
|
|
||||||
if Count1>Count2 then
|
|
||||||
Result:=1
|
|
||||||
else if Count1<Count2 then
|
|
||||||
Result:=-1
|
|
||||||
else
|
|
||||||
Result:=0;
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -502,7 +475,6 @@ begin
|
|||||||
widestringmanager.StrICompAnsiStringProc:=@UTF8StrICompAnsiString;
|
widestringmanager.StrICompAnsiStringProc:=@UTF8StrICompAnsiString;
|
||||||
widestringmanager.StrLCompAnsiStringProc:=@UTF8StrLCompAnsiString;
|
widestringmanager.StrLCompAnsiStringProc:=@UTF8StrLCompAnsiString;
|
||||||
widestringmanager.StrLICompAnsiStringProc:=@UTF8StrLICompAnsiString;
|
widestringmanager.StrLICompAnsiStringProc:=@UTF8StrLICompAnsiString;
|
||||||
widestringmanager.StrLICompAnsiStringProc:=@UTF8StrLICompAnsiString;
|
|
||||||
// Does anyone need these two?
|
// Does anyone need these two?
|
||||||
//widestringmanager.StrLowerAnsiStringProc;
|
//widestringmanager.StrLowerAnsiStringProc;
|
||||||
//widestringmanager.StrUpperAnsiStringProc;
|
//widestringmanager.StrUpperAnsiStringProc;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user