From 4c0b8a072bc2877282383f799274361858ff1c3e Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 14 Dec 2006 22:47:12 +0000 Subject: 2006-12-14 Jeff Johnston Eric Blake * libc/stdio/fflush.c (fflush): On seekable streams, always flush read but unused data. * libc/stdio/fclose.c (_fclose_r): Always flush streams, since even read streams may have side effects that must happen. --- newlib/libc/stdio/fclose.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'newlib/libc/stdio/fclose.c') diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c index bb3acb624..08df75fb4 100644 --- a/newlib/libc/stdio/fclose.c +++ b/newlib/libc/stdio/fclose.c @@ -86,7 +86,10 @@ _DEFUN(_fclose_r, (rptr, fp), __sfp_lock_release (); return (0); } - r = fp->_flags & __SWR ? fflush (fp) : 0; + /* Unconditionally flush to allow special handling for seekable read + files to reposition file to last byte processed as opposed to + last byte read ahead into the buffer. */ + r = fflush (fp); if (fp->_close != NULL && (*fp->_close) (fp->_cookie) < 0) r = EOF; if (fp->_flags & __SMBF) -- cgit v1.2.3