aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBud Davis <bdavis@gfortran.org>2005-04-10 03:43:09 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2005-04-10 03:43:09 +0000
commit48248fa77131fdcfa4d0f153b5ed2820d9befd4a (patch)
tree6dfb012b1bf45857558cff7d92f6bdd8d50aa04d
parent70370fa0310e07c5b0036812a9ff657e613a2f39 (diff)
downloadgcc-48248fa77131fdcfa4d0f153b5ed2820d9befd4a.zip
gcc-48248fa77131fdcfa4d0f153b5ed2820d9befd4a.tar.gz
gcc-48248fa77131fdcfa4d0f153b5ed2820d9befd4a.tar.bz2
re PR libfortran/19872 ([4.0 only] closed and re-opened file not overwriten)
PR fortran/19872 * io/transfer.c (data_transfer_init): truncate an existing file on the first write. Co-Authored-By: Steven G. Kargl <kargls@comcast.net> From-SVN: r97937
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/transfer.c7
2 files changed, 14 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index ba0257d..46fc3b3 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-09 Bud Davis <bdavis@gfortran.org>
+ Steven G. Kargl <kargls@comcast.net>
+
+ PR fortran/19872
+ * io/transfer.c (data_transfer_init): truncate an existing
+ file on the first write.
+
2005-04-09 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/19106
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 4d48323..f86a852 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. */