mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-28 16:11:57 +01:00
MG: fixed searching units in fpc1.1 sources
git-svn-id: trunk@3538 -
This commit is contained in:
parent
cc0fe8109e
commit
4b80bf49f0
@ -1749,7 +1749,7 @@ var FindLen, TxtLen: integer;
|
||||
begin
|
||||
FindLen:=length(Find);
|
||||
TxtLen:=length(Txt);
|
||||
if not CaseSensitive then begin
|
||||
if CaseSensitive then begin
|
||||
while (FindStartPos<=FindLen) and (TxtStartPos<=TxtLen) and (Len>0) do begin
|
||||
if Find[FindStartPos]=Txt[TxtStartPos] then begin
|
||||
inc(FindStartPos);
|
||||
|
||||
@ -71,17 +71,20 @@ function SearchFileInPath(const Filename, BasePath, SearchPath,
|
||||
Delimiter: string; SearchLoUpCase: boolean): string;
|
||||
function FilenameIsMatching(const Mask, Filename: string;
|
||||
MatchExactly: boolean): boolean;
|
||||
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
// to get more detailed error messages consider the os
|
||||
{$IFNDEF win32}
|
||||
uses
|
||||
{$IFDEF Ver1_0} Linux {$ELSE} Unix {$ENDIF};
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
UpChars: array[char] of char;
|
||||
|
||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
begin
|
||||
{$IFDEF WIN32}
|
||||
@ -626,6 +629,77 @@ begin
|
||||
//writeln(' [FilenameIsMatching] Result=',Result,' ',DirStartMask,',',length(Mask),' ',DirStartFile,',',length(Filename));
|
||||
end;
|
||||
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
var
|
||||
FileLen, FilePos, ExtLen, ExtPos: integer;
|
||||
FileChar, ExtChar: char;
|
||||
begin
|
||||
FileLen:=length(Filename);
|
||||
ExtLen:=length(Ext);
|
||||
FilePos:=FileLen;
|
||||
while (FilePos>=1) and (Filename[FilePos]<>'.') do dec(FilePos);
|
||||
if FilePos<1 then begin
|
||||
// no extension in filename
|
||||
Result:=1;
|
||||
exit;
|
||||
end;
|
||||
// skip point
|
||||
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;
|
||||
end;
|
||||
|
||||
|
||||
procedure InternalInit;
|
||||
var
|
||||
c: char;
|
||||
begin
|
||||
for c:=Low(char) to High(char) do begin
|
||||
UpChars[c]:=upcase(c);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
InternalInit;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -1029,8 +1029,8 @@ function TFindDeclarationTool.FindUnitSource(const AnUnitName,
|
||||
{$IFDEF ShowTriedFiles}
|
||||
//writeln(' unit "',copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart),'"');
|
||||
{$ENDIF}
|
||||
if AnsiCompareText(TheUnitName,
|
||||
copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart))=0
|
||||
if CompareSubStrings(TheUnitName,UnitLinks,1,
|
||||
UnitLinkStart,UnitLinkEnd-UnitLinkStart,false)=0
|
||||
then begin
|
||||
// unit found -> parse filename
|
||||
UnitLinkStart:=UnitLinkEnd+1;
|
||||
@ -1041,6 +1041,13 @@ function TFindDeclarationTool.FindUnitSource(const AnUnitName,
|
||||
if UnitLinkEnd>UnitLinkStart then begin
|
||||
CurFilename:=copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart);
|
||||
LoadFile(CurFilename,Result);
|
||||
if Result=nil then begin
|
||||
// try also different extensions
|
||||
if CompareFileExt(CurFilename,'.pp',false)=0 then
|
||||
LoadFile(ChangeFileExt(CurFilename,'.pas'),Result)
|
||||
else
|
||||
LoadFile(ChangeFileExt(CurFilename,'.pp'),Result);
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
end else begin
|
||||
@ -2998,6 +3005,7 @@ begin
|
||||
ReadNextAtom;
|
||||
ReadNextAtom;
|
||||
if (Scanner.PascalCompiler<>pcDelphi)
|
||||
and Scanner.InitialValues.IsDefined('VER1_0')
|
||||
and Scanner.InitialValues.IsDefined('LINUX')
|
||||
then
|
||||
// ToDo: other OS than linux
|
||||
|
||||
Loading…
Reference in New Issue
Block a user