mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 05:39:27 +02:00
lcl: remove UpChars array from FileUtil replacing them with string comparing functions usage
git-svn-id: trunk@27221 -
This commit is contained in:
parent
c1467eddea
commit
92059229cd
@ -235,22 +235,7 @@ uses
|
|||||||
Unix, BaseUnix;
|
Unix, BaseUnix;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
var
|
|
||||||
UpChars: array[char] of char;
|
|
||||||
|
|
||||||
{$I fileutil.inc}
|
{$I fileutil.inc}
|
||||||
|
|
||||||
procedure InternalInit;
|
|
||||||
var
|
|
||||||
c: char;
|
|
||||||
begin
|
|
||||||
for c:=Low(char) to High(char) do begin
|
|
||||||
UpChars[c]:=upcase(c);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
initialization
|
|
||||||
InternalInit;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -670,8 +670,8 @@ end;
|
|||||||
function CompareFileExt(const Filename, Ext: string;
|
function CompareFileExt(const Filename, Ext: string;
|
||||||
CaseSensitive: boolean): integer;
|
CaseSensitive: boolean): integer;
|
||||||
var
|
var
|
||||||
|
n, e : AnsiString;
|
||||||
FileLen, FilePos, ExtLen, ExtPos: integer;
|
FileLen, FilePos, ExtLen, ExtPos: integer;
|
||||||
FileChar, ExtChar: char;
|
|
||||||
begin
|
begin
|
||||||
FileLen:=length(Filename);
|
FileLen:=length(Filename);
|
||||||
ExtLen:=length(Ext);
|
ExtLen:=length(Ext);
|
||||||
@ -686,43 +686,16 @@ begin
|
|||||||
inc(FilePos);
|
inc(FilePos);
|
||||||
ExtPos:=1;
|
ExtPos:=1;
|
||||||
if (ExtPos<=ExtLen) and (Ext[1]='.') then inc(ExtPos);
|
if (ExtPos<=ExtLen) and (Ext[1]='.') then inc(ExtPos);
|
||||||
|
|
||||||
// compare extensions
|
// compare extensions
|
||||||
while true do begin
|
n:=Copy(Filename, FilePos, length(FileName));
|
||||||
if FilePos<=FileLen then begin
|
e:=Copy(Ext, ExtPos, length(Ext));
|
||||||
if ExtPos<=ExtLen then begin
|
if CaseSensitive then
|
||||||
FileChar:=Filename[FilePos];
|
Result:=CompareStr(n, e)
|
||||||
ExtChar:=Ext[ExtPos];
|
else
|
||||||
if not CaseSensitive then begin
|
Result:=AnsiCompareText(n, e);
|
||||||
FileChar:=UpChars[FileChar];
|
if Result<0 then Result:=1
|
||||||
ExtChar:=UpChars[ExtChar];
|
else if Result>0 then Result:=1;
|
||||||
end;
|
|
||||||
if FileChar=ExtChar then begin
|
|
||||||
inc(FilePos);
|
|
||||||
inc(ExtPos);
|
|
||||||
end else if FileChar>ExtChar then begin
|
|
||||||
Result:=1;
|
|
||||||
exit;
|
|
||||||
end else begin
|
|
||||||
Result:=-1;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end else begin
|
|
||||||
// fileext longer than ext
|
|
||||||
Result:=1;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end else begin
|
|
||||||
if ExtPos<=ExtLen then begin
|
|
||||||
// fileext shorter than ext
|
|
||||||
Result:=-1;
|
|
||||||
exit;
|
|
||||||
end else begin
|
|
||||||
// equal
|
|
||||||
Result:=0;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareFileExt(const Filename, Ext: string): integer;
|
function CompareFileExt(const Filename, Ext: string): integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user