From 7ee4f67a4372ce1c2a9ef5510a6a6de4d55eb540 Mon Sep 17 00:00:00 2001 From: jb Date: Thu, 30 Apr 2009 15:12:37 +0000 Subject: Fix PR libfortran/39667 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147004 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/io/intrinsics.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libgfortran/io/intrinsics.c') diff --git a/libgfortran/io/intrinsics.c b/libgfortran/io/intrinsics.c index 0a894aac43e..0e33e8490da 100644 --- a/libgfortran/io/intrinsics.c +++ b/libgfortran/io/intrinsics.c @@ -46,6 +46,13 @@ PREFIX(fgetc) (const int * unit, char * c, gfc_charlen_type c_len) if (u == NULL) return -1; + fbuf_reset (u); + if (u->mode == WRITING) + { + sflush (u->s); + u->mode = READING; + } + memset (c, ' ', c_len); ret = sread (u->s, c, 1); unlock_unit (u); @@ -118,6 +125,13 @@ PREFIX(fputc) (const int * unit, char * c, if (u == NULL) return -1; + fbuf_reset (u); + if (u->mode == READING) + { + sflush (u->s); + u->mode = WRITING; + } + s = swrite (u->s, c, 1); unlock_unit (u); if (s < 0) -- cgit v1.2.1