[Patch, libgfortran] READ from the terminal is broken - 2nd patch - urgent review, please.
Thomas Koenig
Thomas.Koenig@online.de
Thu Oct 13 11:00:00 GMT 2005
On Thu, Oct 13, 2005 at 09:06:02AM +0300, Janne Blomqvist wrote:
> > ! if (s->special_file)
> > ! {
> > ! int n;
>
> To be pedantic, this really should be of type ssize_t and not int
> (sorry I missed it in my fix too).
OK.
> > ! n = s->len - s->active;
>
> The above statement is unnecessary, since n is immediately overwritten
> with the return value from read() below.
>
> > ! n = read (s->fd, s->buffer + s->active, s->len - s->active);
OK.
Dominique has confirmed that this works for him, so this is what
I will commit after regression-testing has finished.
2005-10-13 Thomas Koenig <Thomas.Koenig@online.de>
* io/unix.c(fd_alloc_r_at): Use read() instead of do_read()
only in case of special files (e.g. terminals).
-------------- next part --------------
Index: unix.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.44
diff -c -p -r1.44 unix.c
*** unix.c 12 Oct 2005 19:54:59 -0000 1.44
--- unix.c 13 Oct 2005 10:37:34 -0000
*************** static char *
*** 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;
--- 440,445 ----
*************** fd_alloc_r_at (unix_stream * s, int *len
*** 462,474 ****
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;
- s->active += n;
if (s->active < *len)
*len = s->active; /* Bytes actually available */
--- 461,492 ----
if (s->physical_offset != m && lseek (s->fd, m, SEEK_SET) < 0)
return NULL;
! /* do_read() hangs on read from terminals for *BSD-systems. Only
! use read() in that case. */
!
! if (s->special_file)
! {
! ssize_t n;
!
! n = read (s->fd, s->buffer + s->active, s->len - s->active);
! if (n < 0)
! return NULL;
!
! s->physical_offset = where + n;
! s->active += n;
! }
! else
! {
! size_t n;
! n = s->len - s->active;
! if (do_read (s, s->buffer + s->active, &n) != 0)
! return NULL;
!
! s->physical_offset = where + n;
! s->active += n;
! }
if (s->active < *len)
*len = s->active; /* Bytes actually available */
More information about the Fortran
mailing list