* Better fix for bug ID

git-svn-id: trunk@45792 -
This commit is contained in:
michael 2020-07-15 14:33:51 +00:00
parent a5a7d2cc91
commit 6e9095be79
2 changed files with 34 additions and 3 deletions
packages/fcl-json

View File

@ -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:='';

View File

@ -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