diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-02-21 02:27:07 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-02-21 02:27:07 +0000 |
commit | e32883d1a20e755d07956165d0f0362728c749f4 (patch) | |
tree | 63b91da41f92dac4c36797756c45d2f7f9fff586 | |
parent | d5e0c0ae6254a3b019855e77df5c3af25a7da1db (diff) | |
download | gcc-e32883d1a20e755d07956165d0f0362728c749f4.zip gcc-e32883d1a20e755d07956165d0f0362728c749f4.tar.gz gcc-e32883d1a20e755d07956165d0f0362728c749f4.tar.bz2 |
re PR libfortran/35132 (Formatted stream I/O write should truncate)
2008-02-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/35132
* io/transfer.c (next_record_w): Truncate after the last record for
STREAM I/O.
PR libfortran/34954
* io/transfer.c (data_transfer_init): Initialize dtp->rec if writing.
PR libfortran/34974
* io/transfer.c (formatted_transfer_scalar): Flush the buffer if skips
is less than zero. (next_record_w): Use sseek to position the file to
the max position reached.
From-SVN: r132512
-rw-r--r-- | libgfortran/ChangeLog | 14 | ||||
-rw-r--r-- | libgfortran/io/transfer.c | 17 |
2 files changed, 28 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index dcc52a5..7a40198 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,5 +1,19 @@ 2008-02-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> + PR libfortran/35132 + * io/transfer.c (next_record_w): Truncate after the last record for + STREAM I/O. + + PR libfortran/34954 + * io/transfer.c (data_transfer_init): Initialize dtp->rec if writing. + + PR libfortran/34974 + * io/transfer.c (formatted_transfer_scalar): Flush the buffer if skips + is less than zero. (next_record_w): Use sseek to position the file to + the max position reached. + +2008-02-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> + PR libfortran/35036 * write_float.def (output_float): Add error checks for zero digits after decimal point in E and D format specifiers. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 52c6314..c3e9114 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -916,8 +916,8 @@ formatted_transfer_scalar (st_parameter_dt *dtp, bt type, void *p, int len, the entire field has been read. The next read field will start right after the comma in the stream. (Set to 0 for character reads). */ dtp->u.p.sf_read_comma = 1; - dtp->u.p.line_buffer = scratch; + for (;;) { /* If reversion has occurred and there is another real data item, @@ -1274,6 +1274,11 @@ formatted_transfer_scalar (st_parameter_dt *dtp, bt type, void *p, int len, else read_x (dtp, dtp->u.p.skips); } + else + { + if (dtp->u.p.skips < 0) + flush (dtp->u.p.current_unit->s); + } break; @@ -2007,6 +2012,8 @@ data_transfer_init (st_parameter_dt *dtp, int read_flag) dtp->u.p.current_unit->strm_pos = dtp->rec; } + else + dtp->rec = 0; /* Overwriting an existing sequential file ? it is always safe to truncate the file on the first write */ @@ -2583,7 +2590,8 @@ next_record_w (st_parameter_dt *dtp, int done) if (max_pos > m) { length = (int) (max_pos - m); - p = salloc_w (dtp->u.p.current_unit->s, &length); + sseek (dtp->u.p.current_unit->s, + file_position (dtp->u.p.current_unit->s) + length); } #ifdef HAVE_CRLF len = 2; @@ -2594,7 +2602,10 @@ next_record_w (st_parameter_dt *dtp, int done) goto io_error; if (is_stream_io (dtp)) - dtp->u.p.current_unit->strm_pos += len; + { + dtp->u.p.current_unit->strm_pos += len; + struncate(dtp->u.p.current_unit->s); + } } break; |