This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, libgfortran] PR46733 fflush called when reading from a string
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Jerry DeLisle <jvdelisle at frontier dot com>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 9 Nov 2010 20:37:38 +0200
- Subject: Re: [patch, libgfortran] PR46733 fflush called when reading from a string
- References: <4CD952A5.7070904@frontier.com>
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