mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-24 06:39:36 +02:00
parent
a5a7d2cc91
commit
6e9095be79
packages/fcl-json
@ -212,7 +212,8 @@ function TJSONScanner.FetchToken: TJSONToken;
|
||||
While Not (FCurPos^ in [#0,#10,#13]) do
|
||||
Inc(FCurPos);
|
||||
FEOL:=FCurPos;
|
||||
While (FCurPos^<>#0) and (FCurPos^ in [#10,#13]) do
|
||||
If (FCurPos^<>#0) then
|
||||
// While (FCurPos^<>#0) and (FCurPos^ in [#10,#13]) do
|
||||
begin
|
||||
if (FCurPos^=#13) and (FCurPos[1]=#10) then
|
||||
Inc(FCurPos); // Skip CR-LF
|
||||
@ -471,7 +472,7 @@ begin
|
||||
TokenStart:=FTokenStr;
|
||||
SectionLength := PChar(FEOL)-TokenStart;
|
||||
SetString(FCurTokenString, TokenStart, SectionLength);
|
||||
FTokenStr:=FCurPos;
|
||||
FetchLine;
|
||||
end;
|
||||
'*' :
|
||||
begin
|
||||
@ -479,7 +480,7 @@ begin
|
||||
Inc(FTokenStr);
|
||||
TokenStart:=FTokenStr;
|
||||
Repeat
|
||||
if (FTokenStr^=#0) then
|
||||
if (FTokenStr=FEOL) then
|
||||
begin
|
||||
SectionLength := (FTokenStr - TokenStart);
|
||||
S:='';
|
||||
|
@ -73,6 +73,7 @@ type
|
||||
Procedure TestStartEmptyLine;
|
||||
Procedure TestObjectEmptyLine;
|
||||
Procedure TestCommentLine;
|
||||
Procedure TestFirstLineComment;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -651,6 +652,35 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestParser.TestFirstLineComment;
|
||||
|
||||
// New case
|
||||
const
|
||||
ENDLINE = #$0d#$0a;
|
||||
|
||||
|
||||
Const
|
||||
MyJSON =
|
||||
'//comment1'+ENDLINE+
|
||||
'{'+ENDLINE+
|
||||
'"version":100, //comment2'+ENDLINE+
|
||||
'"value":200'+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
|
||||
|
Loading…
Reference in New Issue
Block a user