re PR libfortran/18284 (BACKSPACE broken)
authorBud Davis <bdavis9659@comcast.net>
Thu, 2 Dec 2004 04:29:00 +0000 (04:29 +0000)
committerBud Davis <bdavis@gcc.gnu.org>
Thu, 2 Dec 2004 04:29:00 +0000 (04:29 +0000)
2004-12-02  Bud Davis  <bdavis9659@comcast.net>

        PR libfortran/18284
        * io/unix.c (fd_alloc_w_at): Update file_length when extending.
        * io/backspace.c (formatted_backspace): Reset endfile after backspace.

        PR fortran/18284
        * gfortran.dg/backspace.f90

From-SVN: r91612

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/backspace.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/backspace.c
libgfortran/io/unix.c

index 2db19aafe496369fdd123969cf4e9a8b25d67a2c..da801f07a69b34cf37f26b1f9500bafdd3519c41 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-02  Bud Davis  <bdavis9659@comcast.net>
+
+       PR fortran/18284
+       * gfortran.dg/backspace.f90
+
 2004-12-02  Bud Davis  <bdavis9659@comcast.net>
 
        * gfortran.dg/inquire.f90: New test.
diff --git a/gcc/testsuite/gfortran.dg/backspace.f90 b/gcc/testsuite/gfortran.dg/backspace.f90
new file mode 100644 (file)
index 0000000..4f0b9e9
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do run }
+!pr18284 BACKSPACE broken
+       open(unit=10,access='SEQUENTIAL',status='SCRATCH')
+       do I = 1,200
+         write(10,*)I
+       end do
+       backspace(10)
+       backspace(10)
+       read(10,*)I
+       if (I.NE.199) call abort
+       end
index e90c0faa47e8e9cba0ca67a60465edf69f79bbf2..a0b3ec12cf45ea023fd45958a9766c4ae49214b6 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-02  Bud Davis  <bdavis9659@comcast.net>
+
+       PR libfortran/18284
+       * io/unix.c (fd_alloc_w_at): Update file_length when extending.
+       * io/backspace.c (formatted_backspace): Reset endfile after backspace.
+
 2004-12-02  Bud Davis  <bdavis9659@comcast.net>
 
        * io/inquire.c (inquire_via_unit): do not allow a direct access
index c40e506c876476694e4574ff58079e52792aa678..e378adf90e673ec296ea18cc478bf3842a2e0863 100644 (file)
@@ -77,6 +77,7 @@ done:
   if (sseek (current_unit->s, base) == FAILURE)
     goto io_error;
   current_unit->last_record--;
+  current_unit->endfile = NO_ENDFILE;
 
   return;
 
index 5be631a9aab103633749e9162a48388af2f0af19..8e3afbdfdc5e1ad8ee024f9e17bb69e8136e8222 100644 (file)
@@ -462,6 +462,9 @@ fd_alloc_w_at (unix_stream * s, int *len, gfc_offset where)
 
   s->logical_offset = where + *len;
 
+  if (where + *len > s->file_length)
+    s->file_length = where + *len;
+
   n = s->logical_offset - s->buffer_offset;
   if (n > s->active)
     s->active = n;