mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-09 23:49:29 +02:00
* Second patch from Mattias Gaertner (bug 19623, should fix 19633 as well)
git-svn-id: trunk@17845 -
This commit is contained in:
parent
548ee755b1
commit
0d14fc2851
@ -41,15 +41,11 @@ var
|
||||
BytesRead: integer;
|
||||
begin
|
||||
BytesRead := FStream.Read(FBuf^, ParseBufSize);
|
||||
if BytesRead = 0 then
|
||||
begin
|
||||
FEofReached := True;
|
||||
Exit;
|
||||
end;
|
||||
FBuf[BytesRead] := #0;
|
||||
Inc(FDeltaPos, BytesRead);
|
||||
FPos := 0;
|
||||
FBufLen := BytesRead;
|
||||
FEofReached:=BytesRead = 0;
|
||||
end;
|
||||
|
||||
procedure TParser.CheckLoadBuffer; {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
||||
@ -112,9 +108,12 @@ begin
|
||||
begin
|
||||
inc(fPos);
|
||||
CheckLoadBuffer;
|
||||
if fBuf[fPos]=#10 then inc(fPos); //CR LF
|
||||
end
|
||||
else inc(fPos); //LF
|
||||
end;
|
||||
if fBuf[fPos]=#10 then
|
||||
begin
|
||||
inc(fPos); //CR LF or LF
|
||||
CheckLoadBuffer;
|
||||
end;
|
||||
inc(fSourceLine);
|
||||
fDeltaPos:=-(fPos-1);
|
||||
end;
|
||||
@ -132,6 +131,7 @@ begin
|
||||
begin
|
||||
bom[i]:=fBuf[fPos];
|
||||
inc(fPos);
|
||||
CheckLoadBuffer;
|
||||
inc(i);
|
||||
end;
|
||||
if (bom<>(#$EF+#$BB+#$BF)) then
|
||||
@ -140,15 +140,16 @@ end;
|
||||
|
||||
procedure TParser.SkipSpaces;
|
||||
begin
|
||||
while fBuf[fPos] in [' ',#9] do
|
||||
while fBuf[fPos] in [' ',#9] do begin
|
||||
inc(fPos);
|
||||
CheckLoadBuffer;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TParser.SkipWhitespace;
|
||||
begin
|
||||
while true do
|
||||
begin
|
||||
CheckLoadBuffer;
|
||||
case fBuf[fPos] of
|
||||
' ',#9 : SkipSpaces;
|
||||
#10,#13 : HandleNewLine
|
||||
@ -205,6 +206,7 @@ begin
|
||||
begin
|
||||
fFloatType:=fBuf[fPos];
|
||||
inc(fPos);
|
||||
CheckLoadBuffer;
|
||||
fToken:=toFloat;
|
||||
end
|
||||
else fFloatType:=#0;
|
||||
@ -330,6 +332,7 @@ begin
|
||||
fToken:=fBuf[fPos];
|
||||
fLastTokenStr:=fToken;
|
||||
inc(fPos);
|
||||
CheckLoadBuffer;
|
||||
end;
|
||||
|
||||
constructor TParser.Create(Stream: TStream);
|
||||
@ -400,6 +403,7 @@ begin
|
||||
Error(SParUnterminatedBinValue);
|
||||
b:=b or GetHexValue(fBuf[fPos]);
|
||||
inc(fPos);
|
||||
CheckLoadBuffer;
|
||||
outbuf[i]:=b;
|
||||
inc(i);
|
||||
if i>=ParseBufSize then
|
||||
|
Loading…
Reference in New Issue
Block a user