re PR libfortran/19872 ([4.0 only] closed and re-opened file not overwriten)
authorBud Davis <bdavis@gfortran.org>
Sun, 10 Apr 2005 03:43:09 +0000 (03:43 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sun, 10 Apr 2005 03:43:09 +0000 (03:43 +0000)
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

libgfortran/ChangeLog
libgfortran/io/transfer.c

index ba0257d69b68421432b50c36fd1d3821edf659a3..46fc3b3dedf88f70a21cb49fca1991ba44e8abfa 100644 (file)
@@ -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
index 4d4832395d956a70c8566449e29494b7b18bb819..f86a85272458aef7116c3109fb7e65edb70f3a5f 100644 (file)
@@ -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.  */