Browse Source

* fix iso i/o with unix style line feeds

git-svn-id: trunk@15706 -
florian 15 years ago
parent
commit
9e053edf2e
2 changed files with 30 additions and 1 deletions
  1. 19 0
      rtl/inc/iso7185.pp
  2. 11 1
      rtl/inc/text.inc

+ 19 - 0
rtl/inc/iso7185.pp

@@ -31,6 +31,8 @@ unit iso7185;
 
 
     Function Eof(Var t: Text): Boolean;
     Function Eof(Var t: Text): Boolean;
     Function Eof:Boolean;
     Function Eof:Boolean;
+    Function Eoln(Var t: Text): Boolean;
+    Function Eoln:Boolean;
 
 
   implementation
   implementation
 
 
@@ -83,6 +85,23 @@ unit iso7185;
         Eof:=Eof(Input);
         Eof:=Eof(Input);
       End;
       End;
 
 
+
+    Function Eoln(Var t: Text): Boolean;[IOCheck];
+      var
+        OldCtrlZMarksEof : Boolean;
+      Begin
+        OldCtrlZMarksEof:=CtrlZMarksEOF;
+        CtrlZMarksEof:=true;
+        Eoln:=System.Eoln(t);
+        CtrlZMarksEof:=OldCtrlZMarksEOF;
+      end;
+
+
+    Function Eoln:Boolean;
+      Begin
+        Eoln:=Eoln(Input);
+      End;
+
 begin
 begin
   { we shouldn't do this because it might confuse user programs, but for now it
   { we shouldn't do this because it might confuse user programs, but for now it
     is good enough to get pretty unique tmp file names }
     is good enough to get pretty unique tmp file names }

+ 11 - 1
rtl/inc/text.inc

@@ -1420,7 +1420,17 @@ Begin
       If TextRec(f).Bufptr^[TextRec(f).BufPos]=#26 then
       If TextRec(f).Bufptr^[TextRec(f).BufPos]=#26 then
         inc(TextRec(f).BufPos);
         inc(TextRec(f).BufPos);
     end
     end
-  else if c in [#10,#26] then
+  else if c=#10 then
+    begin
+      c:=' ';
+      { ignore #26 following a new line }
+      If not CheckRead(f) or
+        (TextRec(f).BufPos>=TextRec(f).BufEnd) then
+        exit;
+      If TextRec(f).Bufptr^[TextRec(f).BufPos]=#26 then
+        inc(TextRec(f).BufPos);
+      end
+  else if c=#26 then
     c:=' ';
     c:=' ';
 end;
 end;