Revert r41592 #173ff71396 "Codetools: optimize TPascalReaderTool.ExtractSourceName." Does not work in every situation.

git-svn-id: trunk@41638 -
This commit is contained in:
juha 2013-06-09 14:35:13 +00:00
parent 66c76d4f6f
commit cf11b400f8

View File

@ -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