mirror of git://gcc.gnu.org/git/gcc.git
re PR libfortran/26499 (gfortran - End of File incorrectly positioned after binary I/O.)
2006-03-09 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/26499 * io/file_pos (st_rewind): Flush always. * io/unix.c (fd_truncate): Return SUCCESS rather than FAILURE for special files like /dev/null. * io/transfer.c (st_write_done): Remove broken logic that prevented calling fd_truncate. From-SVN: r111924
This commit is contained in:
parent
d1781ab0f5
commit
99c6db71de
|
@ -1,3 +1,12 @@
|
||||||
|
2006-03-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR libgfortran/26499
|
||||||
|
* io/file_pos (st_rewind): Flush always.
|
||||||
|
* io/unix.c (fd_truncate): Return SUCCESS rather than FAILURE for
|
||||||
|
special files like /dev/null.
|
||||||
|
* io/transfer.c (st_write_done): Remove broken logic that prevented
|
||||||
|
calling fd_truncate.
|
||||||
|
|
||||||
2006-03-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
2006-03-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
PR libgfortran/26554
|
PR libgfortran/26554
|
||||||
|
|
|
@ -246,15 +246,14 @@ st_rewind (st_parameter_filepos *fpp)
|
||||||
"Cannot REWIND a file opened for DIRECT access");
|
"Cannot REWIND a file opened for DIRECT access");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If we have been writing to the file, the last written record
|
/* Flush the buffers. If we have been writing to the file, the last
|
||||||
is the last record in the file, so truncate the file now.
|
written record is the last record in the file, so truncate the
|
||||||
Reset to read mode so two consecutive rewind statements do not
|
file now. Reset to read mode so two consecutive rewind
|
||||||
delete the file contents. Flush buffer when switching mode. */
|
statements do not delete the file contents. */
|
||||||
if (u->mode == WRITING)
|
flush (u->s);
|
||||||
{
|
if (u->mode == WRITING)
|
||||||
flush (u->s);
|
struncate (u->s);
|
||||||
struncate (u->s);
|
|
||||||
}
|
|
||||||
u->mode = READING;
|
u->mode = READING;
|
||||||
u->last_record = 0;
|
u->last_record = 0;
|
||||||
if (sseek (u->s, 0) == FAILURE)
|
if (sseek (u->s, 0) == FAILURE)
|
||||||
|
|
|
@ -2189,7 +2189,8 @@ st_write_done (st_parameter_dt *dtp)
|
||||||
|
|
||||||
/* Deal with endfile conditions associated with sequential files. */
|
/* Deal with endfile conditions associated with sequential files. */
|
||||||
|
|
||||||
if (dtp->u.p.current_unit != NULL && dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
|
if (dtp->u.p.current_unit != NULL
|
||||||
|
&& dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
|
||||||
switch (dtp->u.p.current_unit->endfile)
|
switch (dtp->u.p.current_unit->endfile)
|
||||||
{
|
{
|
||||||
case AT_ENDFILE: /* Remain at the endfile record. */
|
case AT_ENDFILE: /* Remain at the endfile record. */
|
||||||
|
@ -2200,12 +2201,10 @@ st_write_done (st_parameter_dt *dtp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_ENDFILE:
|
case NO_ENDFILE:
|
||||||
if (dtp->u.p.current_unit->current_record > dtp->u.p.current_unit->last_record)
|
/* Get rid of whatever is after this record. */
|
||||||
{
|
flush (dtp->u.p.current_unit->s);
|
||||||
/* Get rid of whatever is after this record. */
|
if (struncate (dtp->u.p.current_unit->s) == FAILURE)
|
||||||
if (struncate (dtp->u.p.current_unit->s) == FAILURE)
|
generate_error (&dtp->common, ERROR_OS, NULL);
|
||||||
generate_error (&dtp->common, ERROR_OS, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
dtp->u.p.current_unit->endfile = AT_ENDFILE;
|
dtp->u.p.current_unit->endfile = AT_ENDFILE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -586,7 +586,7 @@ fd_truncate (unix_stream * s)
|
||||||
|
|
||||||
/* non-seekable files, like terminals and fifo's fail the lseek.
|
/* non-seekable files, like terminals and fifo's fail the lseek.
|
||||||
Using ftruncate on a seekable special file (like /dev/null)
|
Using ftruncate on a seekable special file (like /dev/null)
|
||||||
is undefined, so we treat it as if the ftruncate failed.
|
is undefined, so we treat it as if the ftruncate succeeded.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_FTRUNCATE
|
#ifdef HAVE_FTRUNCATE
|
||||||
if (s->special_file || ftruncate (s->fd, s->logical_offset))
|
if (s->special_file || ftruncate (s->fd, s->logical_offset))
|
||||||
|
@ -597,7 +597,7 @@ fd_truncate (unix_stream * s)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
s->physical_offset = s->file_length = 0;
|
s->physical_offset = s->file_length = 0;
|
||||||
return FAILURE;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->physical_offset = s->file_length = s->logical_offset;
|
s->physical_offset = s->file_length = s->logical_offset;
|
||||||
|
|
Loading…
Reference in New Issue