mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-29 13:49:36 +02:00
Revert r41592 #173ff71396 "Codetools: optimize TPascalReaderTool.ExtractSourceName." Does not work in every situation.
git-svn-id: trunk@41638 -
This commit is contained in:
parent
66c76d4f6f
commit
cf11b400f8
@ -2117,13 +2117,27 @@ begin
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.ExtractSourceName: string;
|
||||
var
|
||||
NamePos: TAtomPosition;
|
||||
begin
|
||||
Result:='';
|
||||
if GetSourceNamePos(NamePos) then
|
||||
Result:=copy(Src, NamePos.StartPos, NamePos.EndPos-NamePos.StartPos)
|
||||
else if (Tree.Root<>nil) and (Tree.Root.Desc=ctnProgram) then
|
||||
if Tree.Root<>nil then begin
|
||||
MoveCursorToNodeStart(Tree.Root);
|
||||
ReadNextAtom; // read source type 'program', 'unit' ...
|
||||
if (Tree.Root.Desc<>ctnProgram) or UpAtomIs('PROGRAM') then begin
|
||||
ReadNextAtom; // read name
|
||||
if AtomIsIdentifier then begin
|
||||
Result:=copy(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
|
||||
ReadNextAtom;
|
||||
while CurPos.Flag=cafPoint do begin
|
||||
ReadNextAtom;
|
||||
if not AtomIsIdentifier then exit;
|
||||
Result:=Result+'.'+copy(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
|
||||
ReadNextAtom;
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if (Tree.Root<>nil) and (Tree.Root.Desc=ctnProgram) then
|
||||
// a program without the 'program' header uses the file name as name
|
||||
Result:=ExtractFileNameOnly(MainFilename)
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user