------- Comment #9 from jvdelisle at gcc dot gnu dot org 2007-01-01 17:51 ------- Preliminary patch for formatted only.
Index: io/unix.c =================================================================== *** io/unix.c (revision 120301) --- io/unix.c (working copy) *************** fd_flush (unix_stream * s) *** 349,355 **** size_t writelen; if (s->ndirty == 0) ! return SUCCESS;; if (s->physical_offset != s->dirty_offset && lseek (s->fd, s->dirty_offset, SEEK_SET) < 0) --- 349,358 ---- size_t writelen; if (s->ndirty == 0) ! return SUCCESS; ! ! if (s->file_length == -1) ! return SUCCESS; if (s->physical_offset != s->dirty_offset && lseek (s->fd, s->dirty_offset, SEEK_SET) < 0) *************** fd_sfree (unix_stream * s) *** 562,567 **** --- 565,574 ---- static try fd_seek (unix_stream * s, gfc_offset offset) { + + if (s->file_length == -1) + return SUCCESS; + if (s->physical_offset == offset) /* Are we lucky and avoid syscall? */ { s->logical_offset = offset; *************** static try *** 583,589 **** fd_truncate (unix_stream * s) { if (lseek (s->fd, s->logical_offset, SEEK_SET) == -1) ! return FAILURE; /* non-seekable files, like terminals and fifo's fail the lseek. Using ftruncate on a seekable special file (like /dev/null) --- 590,596 ---- fd_truncate (unix_stream * s) { if (lseek (s->fd, s->logical_offset, SEEK_SET) == -1) ! return SUCCESS; /* non-seekable files, like terminals and fifo's fail the lseek. Using ftruncate on a seekable special file (like /dev/null) *************** fd_to_stream (int fd, int prot) *** 1009,1015 **** /* Get the current length of the file. */ fstat (fd, &statbuf); ! s->file_length = S_ISREG (statbuf.st_mode) ? statbuf.st_size : -1; s->special_file = !S_ISREG (statbuf.st_mode); fd_open (s); --- 1016,1027 ---- /* Get the current length of the file. */ fstat (fd, &statbuf); ! ! if (lseek (fd, 0, SEEK_CUR) == (off_t) -1) ! s->file_length = -1; ! else ! s->file_length = S_ISREG (statbuf.st_mode) ? statbuf.st_size : -1; ! s->special_file = !S_ISREG (statbuf.st_mode); fd_open (s); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30162