فهرست منبع

Merged revisions 7502 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r7502 | peter | 2007-05-28 19:39:53 +0200 (Mon, 28 May 2007) | 2 lines

* simplified and optimzied check for eol

........

git-svn-id: branches/fixes_2_2@7711 -

peter 18 سال پیش
والد
کامیت
2df3b4133e
1فایلهای تغییر یافته به همراه9 افزوده شده و 22 حذف شده
  1. 9 22
      rtl/inc/text.inc

+ 9 - 22
rtl/inc/text.inc

@@ -917,20 +917,9 @@ End;
 Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint;
 var
   sPos,len : Longint;
-  p,q,startp,maxp : pchar;
-  stop_chars:array[0..2] of char;
+  p,startp,maxp : pchar;
   end_of_string:boolean;
 Begin
-  {Avoid use of ctrlZmarkseof in the inner loop.}
-  stop_chars[0]:=#13;
-{ #10 must be always the last valid element in stop_chars - see below. }
-  if ctrlZmarkseof then
-   begin
-    stop_chars[1]:=#26;
-    stop_chars[2]:=#10;
-   end
-  else
-   stop_chars[1]:=#10;
   ReadPCharLen:=0;
   If not CheckRead(f) then
     exit;
@@ -951,19 +940,17 @@ Begin
      maxp:=@TextRec(f).Bufptr^[TextRec(f).BufEnd];
     startp:=p;
   { find stop character }
-{    while (p<maxp) and not(P^ in [#10,#13]) do
-     inc(p);}
     while p<maxp do
       begin
-        q:=@stop_chars[0];
-{ 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
+        { Optimization: Do a quick check for a control character first }
+        if (p^<' ') then
           begin
-            end_of_string:=true;
-            break;
+            if (p^ in [#10,#13]) or
+               (ctrlZmarkseof and (p^=#26)) then
+              begin
+                end_of_string:=true;
+                break;
+              end;
           end;
         inc(p);
       end;