+2007-12-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+ Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/33985
+ * io/transfer.c (read_block, read_block_direct, write_block, write_buf):
+ Don't seek if file position is already there for STREAM I/O.
+ (finalize_transfer): For STREAM I/O don't flush unless the file position
+ has moved past the start position before the transfer.
+
2007-12-01 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* intrinsic/stat.c (stat_i4_sub_0, stat_i8_sub_0): Mark parameter
if (is_stream_io (dtp))
{
- if (sseek (dtp->u.p.current_unit->s,
- dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
+ if (dtp->u.p.current_unit->strm_pos - 1
+ != file_position (dtp->u.p.current_unit->s)
+ && sseek (dtp->u.p.current_unit->s,
+ dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
{
generate_error (&dtp->common, LIBERROR_END, NULL);
return NULL;
if (is_stream_io (dtp))
{
- if (sseek (dtp->u.p.current_unit->s,
- dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
+ if (dtp->u.p.current_unit->strm_pos - 1
+ != file_position (dtp->u.p.current_unit->s)
+ && sseek (dtp->u.p.current_unit->s,
+ dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
{
generate_error (&dtp->common, LIBERROR_END, NULL);
return;
if (is_stream_io (dtp))
{
- if (sseek (dtp->u.p.current_unit->s,
- dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
+ if (dtp->u.p.current_unit->strm_pos - 1
+ != file_position (dtp->u.p.current_unit->s)
+ && sseek (dtp->u.p.current_unit->s,
+ dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return NULL;
if (is_stream_io (dtp))
{
- if (sseek (dtp->u.p.current_unit->s,
- dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
+ if (dtp->u.p.current_unit->strm_pos - 1
+ != file_position (dtp->u.p.current_unit->s)
+ && sseek (dtp->u.p.current_unit->s,
+ dtp->u.p.current_unit->strm_pos - 1) == FAILURE)
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return FAILURE;
{
if (dtp->u.p.current_unit->flags.form == FORM_FORMATTED)
next_record (dtp, 1);
- flush (dtp->u.p.current_unit->s);
- sfree (dtp->u.p.current_unit->s);
+
+ if (dtp->u.p.current_unit->flags.form == FORM_UNFORMATTED
+ && file_position (dtp->u.p.current_unit->s) >= dtp->rec)
+ {
+ flush (dtp->u.p.current_unit->s);
+ sfree (dtp->u.p.current_unit->s);
+ }
return;
}