diff options
author | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-07-22 03:14:27 +0000 |
---|---|---|
committer | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-07-22 03:14:27 +0000 |
commit | 53eb61095b5fa0d264ebdc59cdcb066880e9f469 (patch) | |
tree | 46c726c03cdacc28c36000c52ab2b61a3090e6a7 /libgfortran/io | |
parent | 29a7fcb19968beac251215b100f86b11d2c7e070 (diff) | |
download | ppe42-gcc-53eb61095b5fa0d264ebdc59cdcb066880e9f469.tar.gz ppe42-gcc-53eb61095b5fa0d264ebdc59cdcb066880e9f469.zip |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115670 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/transfer.c | 13 | ||||
-rw-r--r-- | libgfortran/io/unit.c | 1 |
2 files changed, 10 insertions, 4 deletions
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. */ |