From 92059229cd482e5e8a0224115b23eb1bdc29a3fa Mon Sep 17 00:00:00 2001 From: dmitry Date: Sat, 28 Aug 2010 14:17:24 +0000 Subject: [PATCH] lcl: remove UpChars array from FileUtil replacing them with string comparing functions usage git-svn-id: trunk@27221 - --- lcl/fileutil.pas | 15 ------------- lcl/include/fileutil.inc | 47 +++++++++------------------------------- 2 files changed, 10 insertions(+), 52 deletions(-) diff --git a/lcl/fileutil.pas b/lcl/fileutil.pas index 44973b8b5c..f31868f99a 100644 --- a/lcl/fileutil.pas +++ b/lcl/fileutil.pas @@ -235,22 +235,7 @@ uses Unix, BaseUnix; {$ENDIF} -var - UpChars: array[char] of char; - {$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. diff --git a/lcl/include/fileutil.inc b/lcl/include/fileutil.inc index dd958dd6aa..9ee1ee080e 100644 --- a/lcl/include/fileutil.inc +++ b/lcl/include/fileutil.inc @@ -670,8 +670,8 @@ end; function CompareFileExt(const Filename, Ext: string; CaseSensitive: boolean): integer; var + n, e : AnsiString; FileLen, FilePos, ExtLen, ExtPos: integer; - FileChar, ExtChar: char; begin FileLen:=length(Filename); ExtLen:=length(Ext); @@ -686,43 +686,16 @@ begin inc(FilePos); ExtPos:=1; if (ExtPos<=ExtLen) and (Ext[1]='.') then inc(ExtPos); + // compare extensions - while true do begin - if FilePos<=FileLen then begin - if ExtPos<=ExtLen then begin - FileChar:=Filename[FilePos]; - ExtChar:=Ext[ExtPos]; - if not CaseSensitive then begin - FileChar:=UpChars[FileChar]; - ExtChar:=UpChars[ExtChar]; - 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; + n:=Copy(Filename, FilePos, length(FileName)); + e:=Copy(Ext, ExtPos, length(Ext)); + if CaseSensitive then + Result:=CompareStr(n, e) + else + Result:=AnsiCompareText(n, e); + if Result<0 then Result:=1 + else if Result>0 then Result:=1; end; function CompareFileExt(const Filename, Ext: string): integer;