re PR fortran/28339 (gfortran misses a record from a format statement)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 22 Jul 2006 03:14:27 +0000 (03:14 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 22 Jul 2006 03:14:27 +0000 (03:14 +0000)
2006-07-21  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libgfortran/28339
* io/transfer.c (next_record_w): Use next_array_record result to set
END_FILE. (write_block): Test for END_FILE before the next write occurs.
* io/unit.c (get_internal_unit): Initialize iunit->endfile for internal
unit.

From-SVN: r115670

libgfortran/ChangeLog
libgfortran/io/transfer.c
libgfortran/io/unit.c

index 8f87a4fa27bb30a5dd50f3d644bcafb1a30fc9c6..1ba6a16766cc29f9463c09ffe1cc86161ac9b228 100644 (file)
@@ -1,3 +1,11 @@
+2006-07-21  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libgfortran/28339
+       * io/transfer.c (next_record_w): Use next_array_record result to set
+       END_FILE. (write_block): Test for END_FILE before the next write occurs.
+       * io/init.c (get_internal_unit): Initialize iunit->endfile for internal
+       unit.
+
 2006-07-19  Janne Blomqvist  <jb@gcc.gnu.org>
 
        PR fortran/27919
index 9b91536d0775bffb91a0b61615da208d7a3a7e1c..4efb523ce78d8d03555e82aa5b7b876c04ac1576 100644 (file)
@@ -414,6 +414,9 @@ write_block (st_parameter_dt *dtp, int length)
       return NULL;
     }
 
+  if (is_internal_unit (dtp) && dtp->u.p.current_unit->endfile == AT_ENDFILE)
+    generate_error (&dtp->common, ERROR_END, NULL);
+
   if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
     dtp->u.p.size_used += (gfc_offset) length;
 
@@ -2052,9 +2055,6 @@ next_record_w (st_parameter_dt *dtp, int done)
 
     case FORMATTED_SEQUENTIAL:
 
-      if (dtp->u.p.current_unit->bytes_left == 0)
-       break;
-       
       if (is_internal_unit (dtp))
        {
          if (is_array_io (dtp))
@@ -2083,7 +2083,9 @@ next_record_w (st_parameter_dt *dtp, int done)
              /* Now that the current record has been padded out,
                 determine where the next record in the array is. */
              record = next_array_record (dtp, dtp->u.p.current_unit->ls);
-
+             if (record == 0)
+               dtp->u.p.current_unit->endfile = AT_ENDFILE;
+             
              /* Now seek to this record */
              record = record * dtp->u.p.current_unit->recl;
 
@@ -2124,6 +2126,9 @@ next_record_w (st_parameter_dt *dtp, int done)
        }
       else
        {
+         if (dtp->u.p.current_unit->bytes_left == 0)
+           break;
+
          /* If this is the last call to next_record move to the farthest
          position reached in preparation for completing the record.
          (for file unit) */
index 0b7dee10155f3c22c09c032693da7dfc9b024990..eca1b1eb98b303e6770bac84b620a504d57f0da1 100644 (file)
@@ -420,6 +420,7 @@ get_internal_unit (st_parameter_dt *dtp)
   iunit->flags.form = FORM_FORMATTED;
   iunit->flags.pad = PAD_YES;
   iunit->flags.status = STATUS_UNSPECIFIED;
+  iunit->endfile = NO_ENDFILE;
 
   /* Initialize the data transfer parameters.  */