[Patch, libgfortran] READ from the terminal is broken.

Paul Thomas paulthomas2@wanadoo.fr
Wed Oct 12 11:36:00 GMT 2005


:ADDPATCH fortran:

>If this works consider the patch OK:d from me. The rest of my patch
>should work as before despite this change, as after this the only
>place where do_read() is used is for big unformatted reads, which
>obviously don't suffer from weird interactions with the terminal.
>
I applied the correction that you proposed.  Could you make sure that it 
is as intended, please?

Bubblestrapped and regtested on FC3/i686.  Also tests OK with NIST suite 
(to make sure that file IO is OK).  OK for mainline?

Paul T



2005-10-12  Janne Blomqvist <jblomqvi@cc.hut.fi>

    * io/unix.c: Remove parts of patch of 2005/10/07 that cause
    input from the terminal to hang.

Index: gcc/libgfortran/io/unix.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.43
diff -c -p -r1.43 unix.c
*** gcc/libgfortran/io/unix.c    7 Oct 2005 20:02:28 -0000    1.43
--- gcc/libgfortran/io/unix.c    12 Oct 2005 10:51:07 -0000
*************** static char *
*** 440,446 ****
  fd_alloc_r_at (unix_stream * s, int *len, gfc_offset where)
  {
    gfc_offset m;
!   size_t n;
 
    if (where == -1)
      where = s->logical_offset;
--- 440,446 ----
  fd_alloc_r_at (unix_stream * s, int *len, gfc_offset where)
  {
    gfc_offset m;
!   int n;
 
    if (where == -1)
      where = s->logical_offset;
*************** fd_alloc_r_at (unix_stream * s, int *len
*** 462,469 ****
    if (s->physical_offset != m && lseek (s->fd, m, SEEK_SET) < 0)
      return NULL;
 
!   n = s->len - s->active;
!   if (do_read (s, s->buffer + s->active, &n) != 0)
      return NULL;
 
    s->physical_offset = where + n;
--- 462,469 ----
    if (s->physical_offset != m && lseek (s->fd, m, SEEK_SET) < 0)
      return NULL;
 
!   n = read (s->fd, s->buffer + s->active, s->len - s->active);
!   if (n < 0)
      return NULL;
 
    s->physical_offset = where + n;
*************** fd_sfree (unix_stream * s)
*** 548,562 ****
  }
 
 
! static try
  fd_seek (unix_stream * s, gfc_offset offset)
  {
-   if (s->physical_offset == offset) /* Are we lucky and avoid syscall?  */
-     {
-       s->logical_offset = offset;
-       return SUCCESS;
-     }
-
    s->physical_offset = s->logical_offset = offset;
 
    return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS;
--- 548,556 ----
  }
 
 
! static int
  fd_seek (unix_stream * s, gfc_offset offset)
  {
    s->physical_offset = s->logical_offset = offset;
 
    return (lseek (s->fd, offset, SEEK_SET) < 0) ? FAILURE : SUCCESS;




More information about the Fortran mailing list