Răsfoiți Sursa

Merged revisions 6464 via svnmerge from
http://[email protected]/svn/fpc/trunk

........
r6464 | hajny | 2007-02-12 21:49:41 +0000 (Mon, 12 Feb 2007) | 1 line

* fix for bug #7539
........

git-svn-id: branches/fixes_2_0@6728 -

Tomas Hajny 18 ani în urmă
părinte
comite
51b0793c9e
1 a modificat fișierele cu 12 adăugiri și 7 ștergeri
  1. 12 7
      rtl/inc/text.inc

+ 12 - 7
rtl/inc/text.inc

@@ -894,16 +894,19 @@ Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint;
 var
   sPos,len : Longint;
   p,q,startp,maxp : pchar;
-  stop_chars:array[0..3] of char;
+  stop_chars:array[0..2] of char;
   end_of_string:boolean;
 Begin
   {Avoid use of ctrlZmarkseof in the inner loop.}
   stop_chars[0]:=#13;
-  stop_chars[1]:=#10;
-  stop_chars[2]:=#0;
+{ #10 must be always the last valid element in stop_chars - see below. }
   if ctrlZmarkseof then
-    stop_chars[2]:=#26;
-  stop_chars[3]:=#0;
+   begin
+    stop_chars[1]:=#26;
+    stop_chars[2]:=#10;
+   end
+  else
+   stop_chars[1]:=#10;
   ReadPCharLen:=0;
 { Check error and if file is open }
   If (InOutRes<>0) then
@@ -940,9 +943,11 @@ Begin
     while p<maxp do
       begin
         q:=@stop_chars;
-        while (q^<>#0) and (p^<>q^) do
+{ The following line relies on the fact that stop_chars array
+  is always initialized to have #10 as the last valid element. }
+        while (q^<>#10) and (p^<>q^) do
           inc(q);
-        if p^=q^ then 
+        if p^=q^ then
           begin
             end_of_string:=true;
             break;