* Merging revisions r45795 from trunk:

------------------------------------------------------------------------
    r45795 | michael | 2020-07-16 09:43:36 +0200 (Thu, 16 Jul 2020) | 1 line
    
    * Fix bug ID #37367
    ------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@46631 -
This commit is contained in:
michael 2020-08-23 09:50:53 +00:00
parent f0fa75e0d8
commit 92850edcb1
2 changed files with 43 additions and 7 deletions

View File

@ -237,6 +237,7 @@ var
OldLength, SectionLength, tstart,tcol, u1,u2: Integer;
C , c2: char;
S : String[4];
Line : String;
IsStar,EOC: Boolean;
Procedure MaybeAppendUnicode;
@ -480,12 +481,12 @@ begin
Inc(FTokenStr);
TokenStart:=FTokenStr;
Repeat
if (FTokenStr=FEOL) then
While (FTokenStr=FEOL) do
begin
SectionLength := (FTokenStr - TokenStart);
S:='';
SetString(S, TokenStart, SectionLength);
FCurtokenString:=FCurtokenString+S;
Line:='';
SetString(Line, TokenStart, SectionLength);
FCurtokenString:=FCurtokenString+Line+sLineBreak;
if not fetchLine then
Error(SUnterminatedComment, [CurRow,CurCOlumn,FTokenStr[0]]);
TokenStart:=FTokenStr;
@ -497,9 +498,9 @@ begin
if EOC then
begin
SectionLength := (FTokenStr - TokenStart-1);
S:='';
SetString(S, TokenStart, SectionLength);
FCurtokenString:=FCurtokenString+S;
Line:='';
SetString(Line, TokenStart, SectionLength);
FCurtokenString:=FCurtokenString+Line;
Inc(FTokenStr);
end;
end;

View File

@ -74,6 +74,7 @@ type
Procedure TestObjectEmptyLine;
Procedure TestCommentLine;
Procedure TestFirstLineComment;
Procedure TestMultiLineComment;
end;
implementation
@ -681,6 +682,40 @@ begin
end;
procedure TTestParser.TestMultiLineComment;
// Issue 37367
const
ENDLINE = #$0d#$0a;
Const
MyJSON =
'/* long comment'+ENDLINE+
''+ENDLINE+
' error'+ENDLINE+
'*/'+ENDLINE+
'{'+ENDLINE+
' "version":100, //coment2 without comment2 works well '+ENDLINE+
' "valor":200 /*comment 3'+ENDLINE+
' line 2'+ENDLINE+
' */'+ENDLINE+
'}'+ENDLINE;
var
J : TJSONData;
begin
With TJSONParser.Create(MyJSON,[joComments]) do
Try
J:=Parse;
J.Free;
Finally
Free;
end;
end;
procedure TTestParser.DoTestError(S : String; Options : TJSONOptions = DefaultOpts);
Var