From: Jerry DeLisle Date: Sat, 22 Jul 2006 03:14:27 +0000 (+0000) Subject: re PR fortran/28339 (gfortran misses a record from a format statement) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=397bc09a6539e72c1e93b7e9fa48870037ba5136;p=gcc.git re PR fortran/28339 (gfortran misses a record from a format statement) 2006-07-21 Jerry DeLisle 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 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 8f87a4fa27b..1ba6a16766c 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2006-07-21 Jerry DeLisle + + 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 PR fortran/27919 diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 9b91536d077..4efb523ce78 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -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) */ diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index 0b7dee10155..eca1b1eb98b 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -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. */