From f82543e75e69c12da1eb693e2a84f891298b2667 Mon Sep 17 00:00:00 2001 From: bdavis <bdavis@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu, 2 Dec 2004 04:29:00 +0000 Subject: [PATCH] 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 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91612 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/backspace.f90 | 11 +++++++++++ libgfortran/ChangeLog | 6 ++++++ libgfortran/io/backspace.c | 1 + libgfortran/io/unix.c | 3 +++ 5 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/backspace.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2db19aafe496..da801f07a69b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 000000000000..4f0b9e975d63 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/backspace.f90 @@ -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 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index e90c0faa47e8..a0b3ec12cf45 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -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 diff --git a/libgfortran/io/backspace.c b/libgfortran/io/backspace.c index c40e506c8764..e378adf90e67 100644 --- a/libgfortran/io/backspace.c +++ b/libgfortran/io/backspace.c @@ -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; diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 5be631a9aab1..8e3afbdfdc5e 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -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; -- GitLab