aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2016-09-28 19:38:03 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2016-09-28 19:38:03 +0000
commitb89f743da8da9cc4884225cb30570c755026d79f (patch)
treeb19be4e6c667ffa7820db3e2b637f97ed4fdf573 /libgfortran/io
parent4b3906980ac60781cddae5a787bf2908dd0920b7 (diff)
downloadgcc-b89f743da8da9cc4884225cb30570c755026d79f.zip
gcc-b89f743da8da9cc4884225cb30570c755026d79f.tar.gz
gcc-b89f743da8da9cc4884225cb30570c755026d79f.tar.bz2
re PR fortran/77707 (formatted direct access: nextrec off by one)
2016-09-28 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/77707 io/transfer.c (next_record): Flush before calculating next_record. Correctly calculate. From-SVN: r240592
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/transfer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 6009c12..902c020 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -3720,6 +3720,8 @@ next_record (st_parameter_dt *dtp, int done)
else
next_record_w (dtp, done);
+ fbuf_flush (dtp->u.p.current_unit, dtp->u.p.mode);
+
if (!is_stream_io (dtp))
{
/* Since we have changed the position, set it to unspecified so
@@ -3733,8 +3735,8 @@ next_record (st_parameter_dt *dtp, int done)
fp = stell (dtp->u.p.current_unit->s);
/* Calculate next record, rounding up partial records. */
dtp->u.p.current_unit->last_record =
- (fp + dtp->u.p.current_unit->recl - 1) /
- dtp->u.p.current_unit->recl;
+ (fp + dtp->u.p.current_unit->recl) /
+ dtp->u.p.current_unit->recl - 1;
}
else
dtp->u.p.current_unit->last_record++;
@@ -3743,7 +3745,6 @@ next_record (st_parameter_dt *dtp, int done)
if (!done)
pre_position (dtp);
- fbuf_flush (dtp->u.p.current_unit, dtp->u.p.mode);
smarkeor (dtp->u.p.current_unit->s);
}