This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] patch for pr15472 and sequential unformatted I/O
- From: Paul Brook <paul at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: Bud Davis <bdavis at gcc dot gnu dot org>,"gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 4 Jul 2004 14:53:29 +0100
- Subject: Re: [gfortran] patch for pr15472 and sequential unformatted I/O
- Organization: CodeSourcery
- References: <1088744301.23348.30.camel@localhost.localdomain>
> 2004-07-02 Bud Davis <bdavis9659@comcast.net>
>
> PR gfortran/15472
> * io/transfer.c(us_write): set recl for seq unform writes to max size.
> * io/transfer.c(data_transfer_init): handle un-opened seq unform unit.
> * io/unix.c(fd_alloc_w_at): deal with writes in the middle of the
> buffer.
> * io/unix.c(is_seekable): set based upon the file/device, not the
> method being used to access it (fd or mmap).
> Index: gcc/libgfortran/io/unix.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/libgfortran/io/unix.c,v
> retrieving revision 1.6
> diff -c -3 -p -r1.6 unix.c
> *** gcc/libgfortran/io/unix.c 26 Jun 2004 11:49:06 -0000 1.6
> --- gcc/libgfortran/io/unix.c 2 Jul 2004 04:11:32 -0000
> *************** fd_alloc_w_at (unix_stream * s, int *len
> *** 416,423 ****
> {
> if (s->dirty_offset + s->ndirty == where)
> s->ndirty += *len;
> else
> ! fd_flush (s); /* Can't combine two dirty blocks */
> }
>
> s->logical_offset = where + *len;
> --- 416,431 ----
> {
> if (s->dirty_offset + s->ndirty == where)
> s->ndirty += *len;
> + else if (where <= s->dirty_offset && where >= s->buffer_offset)
> + {
> + s->dirty_offset = where;
> + s->ndirty = s->ndirty ;
> + }
This looks wrong. We already know (where >= s->buffer_offset).
Also s->ndirty = s->ndirty; suggests there's something missing.
I guess this is intended to catch overlapping buffers. A comment would be
helpful :)
> + else if (where>s->dirty_offset && where < s->ndirty+s->dirty_offset)
> + ; /* right in the middle, do nothing */
I'm not convinced that this is correct either. What about when
(where + *len > s->dirty_offset + s->ndirty)
Paul