mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 12:25:59 +02:00
parent
1dffa17066
commit
0c8103b3a1
@ -237,6 +237,7 @@ var
|
|||||||
OldLength, SectionLength, tstart,tcol, u1,u2: Integer;
|
OldLength, SectionLength, tstart,tcol, u1,u2: Integer;
|
||||||
C , c2: char;
|
C , c2: char;
|
||||||
S : String[4];
|
S : String[4];
|
||||||
|
Line : String;
|
||||||
IsStar,EOC: Boolean;
|
IsStar,EOC: Boolean;
|
||||||
|
|
||||||
Procedure MaybeAppendUnicode;
|
Procedure MaybeAppendUnicode;
|
||||||
@ -480,12 +481,12 @@ begin
|
|||||||
Inc(FTokenStr);
|
Inc(FTokenStr);
|
||||||
TokenStart:=FTokenStr;
|
TokenStart:=FTokenStr;
|
||||||
Repeat
|
Repeat
|
||||||
if (FTokenStr=FEOL) then
|
While (FTokenStr=FEOL) do
|
||||||
begin
|
begin
|
||||||
SectionLength := (FTokenStr - TokenStart);
|
SectionLength := (FTokenStr - TokenStart);
|
||||||
S:='';
|
Line:='';
|
||||||
SetString(S, TokenStart, SectionLength);
|
SetString(Line, TokenStart, SectionLength);
|
||||||
FCurtokenString:=FCurtokenString+S;
|
FCurtokenString:=FCurtokenString+Line+sLineBreak;
|
||||||
if not fetchLine then
|
if not fetchLine then
|
||||||
Error(SUnterminatedComment, [CurRow,CurCOlumn,FTokenStr[0]]);
|
Error(SUnterminatedComment, [CurRow,CurCOlumn,FTokenStr[0]]);
|
||||||
TokenStart:=FTokenStr;
|
TokenStart:=FTokenStr;
|
||||||
@ -497,9 +498,9 @@ begin
|
|||||||
if EOC then
|
if EOC then
|
||||||
begin
|
begin
|
||||||
SectionLength := (FTokenStr - TokenStart-1);
|
SectionLength := (FTokenStr - TokenStart-1);
|
||||||
S:='';
|
Line:='';
|
||||||
SetString(S, TokenStart, SectionLength);
|
SetString(Line, TokenStart, SectionLength);
|
||||||
FCurtokenString:=FCurtokenString+S;
|
FCurtokenString:=FCurtokenString+Line;
|
||||||
Inc(FTokenStr);
|
Inc(FTokenStr);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -74,6 +74,7 @@ type
|
|||||||
Procedure TestObjectEmptyLine;
|
Procedure TestObjectEmptyLine;
|
||||||
Procedure TestCommentLine;
|
Procedure TestCommentLine;
|
||||||
Procedure TestFirstLineComment;
|
Procedure TestFirstLineComment;
|
||||||
|
Procedure TestMultiLineComment;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -681,6 +682,40 @@ begin
|
|||||||
|
|
||||||
end;
|
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);
|
procedure TTestParser.DoTestError(S : String; Options : TJSONOptions = DefaultOpts);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
|
Loading…
Reference in New Issue
Block a user