Przeglądaj źródła

* Applied patch from Mattias Gaertner to fix parse buffer not always being loaded (bug 19623)

git-svn-id: trunk@17823 -
michael 14 lat temu
rodzic
commit
a2d007dfa3
1 zmienionych plików z 10 dodań i 8 usunięć
  1. 10 8
      rtl/objpas/classes/parser.inc

+ 10 - 8
rtl/objpas/classes/parser.inc

@@ -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}
@@ -114,7 +110,10 @@ begin
     CheckLoadBuffer;
     if fBuf[fPos]=#10 then inc(fPos); //CR LF
   end
-  else inc(fPos); //LF
+  else begin
+    inc(fPos); //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;