mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 12:19:28 +02:00
codetools: GetPasDocComment: fixed endless loop
git-svn-id: trunk@33014 -
This commit is contained in:
parent
4ca2e72008
commit
95f93fb4a6
@ -1150,7 +1150,10 @@ end;
|
|||||||
function FindNextComment(const ASource: string; StartPos: integer;
|
function FindNextComment(const ASource: string; StartPos: integer;
|
||||||
MaxPos: integer): integer;
|
MaxPos: integer): integer;
|
||||||
// if not found: Result=MaxPos+1
|
// if not found: Result=MaxPos+1
|
||||||
|
var
|
||||||
|
NotFoundPos: Integer;
|
||||||
begin
|
begin
|
||||||
|
NotFoundPos:=MaxPos+1;
|
||||||
if (MaxPos>length(ASource)) or (MaxPos<1) then
|
if (MaxPos>length(ASource)) or (MaxPos<1) then
|
||||||
MaxPos:=length(ASource);
|
MaxPos:=length(ASource);
|
||||||
Result:=StartPos;
|
Result:=StartPos;
|
||||||
@ -1160,11 +1163,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
inc(Result);
|
inc(Result);
|
||||||
while (Result<=MaxPos) do begin
|
while (Result<=MaxPos) do begin
|
||||||
if (ASource[Result]<>'''') then
|
if (ASource[Result] in ['''',#10,#13]) then
|
||||||
inc(Result)
|
|
||||||
else begin
|
|
||||||
break;
|
break;
|
||||||
end;
|
inc(Result);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1182,7 +1183,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
inc(Result);
|
inc(Result);
|
||||||
end;
|
end;
|
||||||
if Result>MaxPos+1 then Result:=MaxPos+1;
|
if Result>=MaxPos+1 then Result:=NotFoundPos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure FindCommentsInRange(const Src: string; StartPos, EndPos: integer;
|
procedure FindCommentsInRange(const Src: string; StartPos, EndPos: integer;
|
||||||
|
@ -2994,6 +2994,7 @@ function TPascalReaderTool.GetPasDocComments(Node: TCodeTreeNode;
|
|||||||
begin
|
begin
|
||||||
// read comments (start in front of node)
|
// read comments (start in front of node)
|
||||||
//DebugLn(['TPascalReaderTool.GetPasDocComments Scan Src=',copy(Src,StartPos,EndPos-StartPos)]);
|
//DebugLn(['TPascalReaderTool.GetPasDocComments Scan Src=',copy(Src,StartPos,EndPos-StartPos)]);
|
||||||
|
if EndPos>SrcLen then EndPos:=SrcLen+1;
|
||||||
p:=FindLineEndOrCodeInFrontOfPosition(StartPos,true);
|
p:=FindLineEndOrCodeInFrontOfPosition(StartPos,true);
|
||||||
while p<EndPos do begin
|
while p<EndPos do begin
|
||||||
p:=FindNextComment(Src,p,EndPos);
|
p:=FindNextComment(Src,p,EndPos);
|
||||||
|
Loading…
Reference in New Issue
Block a user