From 35077d5aed52d82f38476ba5cb95cc4df0382483 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sat, 22 Mar 2008 22:03:13 +0000 Subject: [PATCH] re PR fortran/35632 (stream io broken on FreeBSD due to ftruncate changes.) 2008-03-22 Jerry DeLisle PR libfortran/35632 * io/transfer.c (data_transfer_init): Fix whitespace. (next_record_w): Truncate the file only if the stream position is short of the file end. From-SVN: r133454 --- libgfortran/ChangeLog | 7 +++++++ libgfortran/io/transfer.c | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index c2bf6ca8e0d..3ccccc98f46 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2008-03-22 Jerry DeLisle + + PR libfortran/35632 + * io/transfer.c (data_transfer_init): Fix whitespace. + (next_record_w): Truncate the file only if the stream + position is short of the file end. + 2008-03-21 Jerry DeLisle * intrinsics/pack_generic.c: Fix typo. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index c3e91149a27..5ccc95823a8 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1985,12 +1985,12 @@ data_transfer_init (st_parameter_dt *dtp, int read_flag) if (dtp->u.p.mode == READING && dtp->u.p.current_unit->mode == WRITING && !is_internal_unit (dtp)) - flush(dtp->u.p.current_unit->s); + flush(dtp->u.p.current_unit->s); /* Check whether the record exists to be read. Only a partial record needs to exist. */ - if (dtp->u.p.mode == READING && (dtp->rec -1) + if (dtp->u.p.mode == READING && (dtp->rec - 1) * dtp->u.p.current_unit->recl >= file_length (dtp->u.p.current_unit->s)) { generate_error (&dtp->common, LIBERROR_BAD_OPTION, @@ -2604,7 +2604,9 @@ next_record_w (st_parameter_dt *dtp, int done) if (is_stream_io (dtp)) { dtp->u.p.current_unit->strm_pos += len; - struncate(dtp->u.p.current_unit->s); + if (dtp->u.p.current_unit->strm_pos + < file_length (dtp->u.p.current_unit->s)) + struncate (dtp->u.p.current_unit->s); } } -- 2.30.2