Browse Source

* Now ansistring of arbitrary length can be read

michael 26 years ago
parent
commit
d753055cfe
1 changed files with 14 additions and 8 deletions
  1. 14 8
      rtl/inc/text.inc

+ 14 - 8
rtl/inc/text.inc

@@ -711,7 +711,7 @@ Begin
      begin
        FileFunc(f.InOutFunc)(f);
        If f.BufPos>=f.BufEnd Then
-        break;
+         break;
      end;
     p:[email protected]^[f.BufPos];
     if SPos+f.BufEnd-f.BufPos>MaxLen then
@@ -765,12 +765,15 @@ var
   len : longint;
 Begin
 { Delete the string }
-  AnsiStr_Decr_ref (Pointer(S));
-  { We assign room for 1024 characters totally at random.... }
-  Pointer(s):=Pointer(NewAnsiString(1024));
-  len:=ReadPCharLen(f,pchar(s),1024);
-  pchar(pchar(s)+len)^:=#0;
-  PAnsiRec(Pointer(S)-FirstOff)^.Len:=len;
+  Setlength(S,0);
+  Repeat 
+    // SetLength will reallocate the length.
+    SetLength(S,Length(S)+255);
+    len:=ReadPCharLen(f,pchar(Pointer(S)+Length(S)-255),255);
+    If Len<255 then 
+      // Set actual length
+      SetLength(S,Length(S)-255+Len);
+  Until len<255;
 End;
 
 
@@ -928,7 +931,10 @@ end;
 
 {
   $Log$
-  Revision 1.49  1999-07-05 20:04:29  peter
+  Revision 1.50  1999-07-08 15:18:14  michael
+  * Now ansistring of arbitrary length can be read
+
+  Revision 1.49  1999/07/05 20:04:29  peter
     * removed temp defines
 
   Revision 1.48  1999/07/01 15:39:52  florian