mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 10:19:17 +02:00
* Merging revisions r45792 from trunk:
------------------------------------------------------------------------ r45792 | michael | 2020-07-15 16:33:51 +0200 (Wed, 15 Jul 2020) | 1 line * Better fix for bug ID #0037352 ------------------------------------------------------------------------ git-svn-id: branches/fixes_3_2@46630 -
This commit is contained in:
parent
2bda5dd2e4
commit
f0fa75e0d8
@ -212,7 +212,8 @@ function TJSONScanner.FetchToken: TJSONToken;
|
|||||||
While Not (FCurPos^ in [#0,#10,#13]) do
|
While Not (FCurPos^ in [#0,#10,#13]) do
|
||||||
Inc(FCurPos);
|
Inc(FCurPos);
|
||||||
FEOL:=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
|
begin
|
||||||
if (FCurPos^=#13) and (FCurPos[1]=#10) then
|
if (FCurPos^=#13) and (FCurPos[1]=#10) then
|
||||||
Inc(FCurPos); // Skip CR-LF
|
Inc(FCurPos); // Skip CR-LF
|
||||||
@ -471,7 +472,7 @@ begin
|
|||||||
TokenStart:=FTokenStr;
|
TokenStart:=FTokenStr;
|
||||||
SectionLength := PChar(FEOL)-TokenStart;
|
SectionLength := PChar(FEOL)-TokenStart;
|
||||||
SetString(FCurTokenString, TokenStart, SectionLength);
|
SetString(FCurTokenString, TokenStart, SectionLength);
|
||||||
FTokenStr:=FCurPos;
|
FetchLine;
|
||||||
end;
|
end;
|
||||||
'*' :
|
'*' :
|
||||||
begin
|
begin
|
||||||
@ -479,7 +480,7 @@ begin
|
|||||||
Inc(FTokenStr);
|
Inc(FTokenStr);
|
||||||
TokenStart:=FTokenStr;
|
TokenStart:=FTokenStr;
|
||||||
Repeat
|
Repeat
|
||||||
if (FTokenStr^=#0) then
|
if (FTokenStr=FEOL) then
|
||||||
begin
|
begin
|
||||||
SectionLength := (FTokenStr - TokenStart);
|
SectionLength := (FTokenStr - TokenStart);
|
||||||
S:='';
|
S:='';
|
||||||
|
@ -73,6 +73,7 @@ type
|
|||||||
Procedure TestStartEmptyLine;
|
Procedure TestStartEmptyLine;
|
||||||
Procedure TestObjectEmptyLine;
|
Procedure TestObjectEmptyLine;
|
||||||
Procedure TestCommentLine;
|
Procedure TestCommentLine;
|
||||||
|
Procedure TestFirstLineComment;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -651,6 +652,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
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);
|
procedure TTestParser.DoTestError(S : String; Options : TJSONOptions = DefaultOpts);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
|
Loading…
Reference in New Issue
Block a user