mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 00:19:38 +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
|
begin
|
||||||
FindLen:=length(Find);
|
FindLen:=length(Find);
|
||||||
TxtLen:=length(Txt);
|
TxtLen:=length(Txt);
|
||||||
if not CaseSensitive then begin
|
if CaseSensitive then begin
|
||||||
while (FindStartPos<=FindLen) and (TxtStartPos<=TxtLen) and (Len>0) do begin
|
while (FindStartPos<=FindLen) and (TxtStartPos<=TxtLen) and (Len>0) do begin
|
||||||
if Find[FindStartPos]=Txt[TxtStartPos] then begin
|
if Find[FindStartPos]=Txt[TxtStartPos] then begin
|
||||||
inc(FindStartPos);
|
inc(FindStartPos);
|
||||||
|
|||||||
@ -71,17 +71,20 @@ function SearchFileInPath(const Filename, BasePath, SearchPath,
|
|||||||
Delimiter: string; SearchLoUpCase: boolean): string;
|
Delimiter: string; SearchLoUpCase: boolean): string;
|
||||||
function FilenameIsMatching(const Mask, Filename: string;
|
function FilenameIsMatching(const Mask, Filename: string;
|
||||||
MatchExactly: boolean): boolean;
|
MatchExactly: boolean): boolean;
|
||||||
|
function CompareFileExt(const Filename, Ext: string;
|
||||||
|
CaseSensitive: boolean): integer;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
// to get more detailed error messages consider the os
|
// to get more detailed error messages consider the os
|
||||||
{$IFNDEF win32}
|
{$IFNDEF win32}
|
||||||
uses
|
uses
|
||||||
{$IFDEF Ver1_0} Linux {$ELSE} Unix {$ENDIF};
|
{$IFDEF Ver1_0} Linux {$ELSE} Unix {$ENDIF};
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
var
|
||||||
|
UpChars: array[char] of char;
|
||||||
|
|
||||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF WIN32}
|
{$IFDEF WIN32}
|
||||||
@ -626,6 +629,77 @@ begin
|
|||||||
//writeln(' [FilenameIsMatching] Result=',Result,' ',DirStartMask,',',length(Mask),' ',DirStartFile,',',length(Filename));
|
//writeln(' [FilenameIsMatching] Result=',Result,' ',DirStartMask,',',length(Mask),' ',DirStartFile,',',length(Filename));
|
||||||
end;
|
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.
|
end.
|
||||||
|
|
||||||
|
|||||||
@ -1029,8 +1029,8 @@ function TFindDeclarationTool.FindUnitSource(const AnUnitName,
|
|||||||
{$IFDEF ShowTriedFiles}
|
{$IFDEF ShowTriedFiles}
|
||||||
//writeln(' unit "',copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart),'"');
|
//writeln(' unit "',copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart),'"');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if AnsiCompareText(TheUnitName,
|
if CompareSubStrings(TheUnitName,UnitLinks,1,
|
||||||
copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart))=0
|
UnitLinkStart,UnitLinkEnd-UnitLinkStart,false)=0
|
||||||
then begin
|
then begin
|
||||||
// unit found -> parse filename
|
// unit found -> parse filename
|
||||||
UnitLinkStart:=UnitLinkEnd+1;
|
UnitLinkStart:=UnitLinkEnd+1;
|
||||||
@ -1041,6 +1041,13 @@ function TFindDeclarationTool.FindUnitSource(const AnUnitName,
|
|||||||
if UnitLinkEnd>UnitLinkStart then begin
|
if UnitLinkEnd>UnitLinkStart then begin
|
||||||
CurFilename:=copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart);
|
CurFilename:=copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart);
|
||||||
LoadFile(CurFilename,Result);
|
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;
|
exit;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
@ -2998,6 +3005,7 @@ begin
|
|||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if (Scanner.PascalCompiler<>pcDelphi)
|
if (Scanner.PascalCompiler<>pcDelphi)
|
||||||
|
and Scanner.InitialValues.IsDefined('VER1_0')
|
||||||
and Scanner.InitialValues.IsDefined('LINUX')
|
and Scanner.InitialValues.IsDefined('LINUX')
|
||||||
then
|
then
|
||||||
// ToDo: other OS than linux
|
// ToDo: other OS than linux
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user