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
On Sun, 2004-07-04 at 08:53, Paul Brook wrote:
> 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
how about this ?
else
{
/* add to the end */
if (s->dirty_offset + s->ndirty == where)
s->ndirty += *len;
/* add to the beginning */
else if (where + *len == s->dirty_offset)
{
s->dirty_offset = where;
s->ndirty = *len;
}
/* middle */
else if (where > s->dirty_offset && where + *len < s->ndirty + s->dirty_offset)
; /* do nothing, overwriting data written before */
else
fd_flush (s); /* Can't combine two dirty blocks */
}
tested on i686/gnu/linux.
--bud