codetools: GetPasDocComment: fixed endless loop

git-svn-id: trunk@33014 -
This commit is contained in:
mattias 2011-10-22 07:25:01 +00:00
parent 4ca2e72008
commit 95f93fb4a6
2 changed files with 7 additions and 5 deletions

View File

@ -1150,7 +1150,10 @@ end;
function FindNextComment(const ASource: string; StartPos: integer;
MaxPos: integer): integer;
// if not found: Result=MaxPos+1
var
NotFoundPos: Integer;
begin
NotFoundPos:=MaxPos+1;
if (MaxPos>length(ASource)) or (MaxPos<1) then
MaxPos:=length(ASource);
Result:=StartPos;
@ -1160,11 +1163,9 @@ begin
begin
inc(Result);
while (Result<=MaxPos) do begin
if (ASource[Result]<>'''') then
inc(Result)
else begin
if (ASource[Result] in ['''',#10,#13]) then
break;
end;
inc(Result);
end;
end;
@ -1182,7 +1183,7 @@ begin
end;
inc(Result);
end;
if Result>MaxPos+1 then Result:=MaxPos+1;
if Result>=MaxPos+1 then Result:=NotFoundPos;
end;
procedure FindCommentsInRange(const Src: string; StartPos, EndPos: integer;

View File

@ -2994,6 +2994,7 @@ function TPascalReaderTool.GetPasDocComments(Node: TCodeTreeNode;
begin
// read comments (start in front of node)
//DebugLn(['TPascalReaderTool.GetPasDocComments Scan Src=',copy(Src,StartPos,EndPos-StartPos)]);
if EndPos>SrcLen then EndPos:=SrcLen+1;
p:=FindLineEndOrCodeInFrontOfPosition(StartPos,true);
while p<EndPos do begin
p:=FindNextComment(Src,p,EndPos);