This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, libgfortran] PR46733 fflush called when reading from a string


On Tue, Nov 9, 2010 at 15:54, Jerry DeLisle <jvdelisle@frontier.com> wrote:
> Committed as obvious.
>
> Sending    ÂChangeLog
> Sending    Âio/transfer.c
> Transmitting file data ..
> Committed revision 166490.
>
>
> Index: io/transfer.c
> ===================================================================
> --- io/transfer.c    (revision 166469)
> +++ io/transfer.c    (working copy)
> @@ -2646,7 +2646,8 @@
> Â Â }
>
> Â /* Bugware for badly written mixed C-Fortran I/O. Â*/
> - Âflush_if_preconnected(dtp->u.p.current_unit->s);
> + Âif (!is_internal_unit (dtp))
> + Â Âflush_if_preconnected(dtp->u.p.current_unit->s);
>
> Â dtp->u.p.current_unit->mode = dtp->u.p.mode;

Thanks for fixing this bug.

Generally though, I think this flush_if_preconnected() function should
be removed. Either we

1) Never buffer the preconnected units (or, we have mandatory line
buffering via the use of fbuf.h, but no more than that), in which case
we should remove GFORTRAN_UNBUFFERED_PRECONNECTED and modify the
checks in unix.c:fd_to_stream() such that we always call raw_init()
for preconnected units. This would be practically equivalent to the
status quo.

2) Potentially buffer preconnected units if they are redirected
to/from a regular file, and tell users to use GFORTRAN_UNBUFFERED_ALL
if they wish to prevent said buffering.

In neither of the above cases is flush_if_preconnected() needed. Any
opinions on which approach is preferred?


-- 
Janne Blomqvist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]