From 99db626d210c747e8e8da2de09afb523547329bc Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Mon, 20 Feb 2006 23:24:00 +0000 Subject: 2006-02-20 Jeff Johnston * libc/stdio/fflush.c (fflush): For an fflush on a read-only stream, turn off fseek/rewind optimization as per POSIX/SUSv3. * libc/stdio/fseek.c (_fseek_r): After a successful unoptimized seek, turn off the __SNPT no-optimization flag. --- newlib/libc/stdio/fseek.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'newlib/libc/stdio/fseek.c') diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 2ad98551c..8b189ba17 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -359,6 +359,13 @@ dumb: fp->_r = 0; /* fp->_w = 0; *//* unnecessary (I think...) */ fp->_flags &= ~__SEOF; + /* Reset no-optimization flag after successful seek. The + no-optimization flag may be set in the case of a read + stream that is flushed which by POSIX/SUSv3 standards, + means that a corresponding seek must not optimize. The + optimization is then allowed if no subsequent flush + is performed. */ + fp->_flags &= ~__SNPT; _funlockfile (fp); return 0; } -- cgit v1.2.3