From 8ebb828508a4a55565bd200f113b6c92fbef81ef Mon Sep 17 00:00:00 2001 From: kargl Date: Sun, 10 Apr 2005 03:43:09 +0000 Subject: [PATCH] PR fortran/19872 * io/transfer.c (data_transfer_init): truncate an existing file on the first write. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97937 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 7 +++++++ libgfortran/io/transfer.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index ba0257d69b6..46fc3b3dedf 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2005-04-09 Bud Davis + Steven G. Kargl + + PR fortran/19872 + * io/transfer.c (data_transfer_init): truncate an existing + file on the first write. + 2005-04-09 Thomas Koenig PR libfortran/19106 diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 4d4832395d9..f86a8527245 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1103,6 +1103,13 @@ data_transfer_init (int read_flag) generate_error (ERROR_OS, NULL); } + /* Overwriting an existing sequential file ? + it is always safe to truncate the file on the first write */ + if (g.mode == WRITING + && current_unit->flags.access == ACCESS_SEQUENTIAL + && current_unit->current_record == 0) + struncate(current_unit->s); + current_unit->mode = g.mode; /* Set the initial value of flags. */ -- 2.11.4.GIT