* Fix nested comments (* *) style

git-svn-id: trunk@35625 -
This commit is contained in:
michael 2017-03-19 09:44:58 +00:00
parent d831c57883
commit 051f8568b3
2 changed files with 17 additions and 1 deletions

View File

@ -1983,7 +1983,8 @@ begin
TokenStart := TokenStr;
FCurTokenString := '';
OldLength := 0;
while (TokenStr[0] <> '*') or (TokenStr[1] <> ')') do
NestingLevel:=0;
while (TokenStr[0] <> '*') or (TokenStr[1] <> ')') or (NestingLevel>0) do
begin
if TokenStr[0] = #0 then
begin
@ -2002,7 +2003,16 @@ begin
TokenStart:=TokenStr;
end
else
begin
If (msNestedComment in CurrentModeSwitches) then
begin
if (TokenStr[0] = '(') and (TokenStr[1] = '*') then
Inc(NestingLevel)
else if (TokenStr[0] = '*') and (TokenStr[1] = ')') and not PPIsSkipping then
Dec(NestingLevel);
end;
Inc(TokenStr);
end;
end;
SectionLength := TokenStr - TokenStart;
SetLength(FCurTokenString, OldLength + SectionLength);

View File

@ -81,6 +81,7 @@ type
procedure TestNestedComment2;
procedure TestNestedComment3;
procedure TestNestedComment4;
procedure TestNestedComment5;
procedure TestIdentifier;
procedure TestSelf;
procedure TestSelfNoToken;
@ -542,6 +543,11 @@ begin
TestToken(tkComment,'{ (* comment *) }');
end;
procedure TTestScanner.TestNestedComment5;
begin
TestToken(tkComment,'(* (* comment *) *)');
end;
procedure TTestScanner.TestIdentifier;