rewind.c (st_rewind): Flush the stream when resetting the mode from WRITING to READING.
authorDavid Edelsohn <dje@gcc.gnu.org>
Tue, 26 Apr 2005 19:27:11 +0000 (15:27 -0400)
committerDavid Edelsohn <dje@gcc.gnu.org>
Tue, 26 Apr 2005 19:27:11 +0000 (15:27 -0400)
        * io/rewind.c (st_rewind): Flush the stream when resetting the mode
        from WRITING to READING.

From-SVN: r98788

libgfortran/ChangeLog
libgfortran/io/rewind.c

index 027ad271f995bc32969163648d3f0e184474ebbe..52f6c9f88fef3a292c1bc7980fcb22d90374c1c9 100644 (file)
@@ -1,5 +1,10 @@
-2005-04-18 Paul Thomas <pault@gcc.gnu.org>
-          Jerry DeLisle <jvdelisle@verizon.net> 
+2005-04-26  David Edelsohn  <edelsohn@gnu.org>
+
+       * io/rewind.c (st_rewind): Flush the stream when resetting the mode
+       from WRITING to READING.
+
+2005-04-22  Paul Thomas  <pault@gcc.gnu.org>
+           Jerry DeLisle  <jvdelisle@verizon.net> 
 
        * io/write.c (nml_write_obj): Provide 1 more byte for ext_name.
        * io/list_read.c (nml_get_obj_data): Put extra brackets in get_mem
index f0b0e90e45449fddb9e003b94d0b7e8b2ad4e74e..48d57bafaa53a719694e3e7f6253466e49f5e6f5 100644 (file)
@@ -54,9 +54,13 @@ st_rewind (void)
          /* If we have been writing to the file, the last written record
             is the last record in the file, so truncate the file now.
             Reset to read mode so two consecutive rewind statements
-            don't delete the file contents.  */
-          if (u->mode==WRITING)
-            struncate(u->s);
+            don't delete the file contents.  Flush buffer when switching
+            mode.  */
+          if (u->mode == WRITING)
+           {
+             flush (u->s);
+             struncate (u->s);
+           }
          u->mode = READING;
          u->last_record = 0;
          if (sseek (u->s, 0) == FAILURE)