aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/transfer.c
diff options
context:
space:
mode:
authorBud Davis <bdavis9659@comcast.net>2004-08-27 07:59:30 +0000
committerBud Davis <bdavis@gcc.gnu.org>2004-08-27 07:59:30 +0000
commit55948b693ed0cde602e64e7f670450a0e5e96b93 (patch)
tree4050f4a405b432378b98cbcd6661afa4a1f0be61 /libgfortran/io/transfer.c
parentdc700f497caaf7c36db7220ab6f827b8dcf6a7e6 (diff)
downloadgcc-55948b693ed0cde602e64e7f670450a0e5e96b93.zip
gcc-55948b693ed0cde602e64e7f670450a0e5e96b93.tar.gz
gcc-55948b693ed0cde602e64e7f670450a0e5e96b93.tar.bz2
re PR libfortran/16597 (gfortran: bug in unformatted I/O on scratch files)
2004-08-27 Bud Davis <bdavis9659@comcast.net> PR fortran/16597 * io/io.h: created typedef for unit_mode. * io/io.h (gfc_unit): added mode to unit structure. * io/transfer.c (data_transfer_init): flush if a write then read is done on a unit (direct access files). * io/rewind.c (st_rewind): Used unit mode instead of global. * gfortran.dg/pr16597.f90: New test. From-SVN: r86654
Diffstat (limited to 'libgfortran/io/transfer.c')
-rw-r--r--libgfortran/io/transfer.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index b6f7c0e..3800d0b 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -1044,13 +1044,19 @@ data_transfer_init (int read_flag)
return;
}
- /* Position the file. */
+ /* Check to see if we might be reading what we wrote before */
+
+ if (g.mode == READING && current_unit->mode == WRITING)
+ flush(current_unit->s);
+ /* Position the file. */
if (sseek (current_unit->s,
(ioparm.rec - 1) * current_unit->recl) == FAILURE)
generate_error (ERROR_OS, NULL);
}
+ current_unit->mode = g.mode;
+
/* Set the initial value of flags. */
g.blank_status = current_unit->flags.blank;