From d72fc351f3a2e3921448c1b57c24c94f68807585 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 22 Jul 2014 18:37:59 +0000 Subject: [PATCH] Revert r268984: Check for __SAPP flag before calling sflush. This avoids performance degradation compared to the previous approach. Submitted by: ache MFC after: 2 weeks --- lib/libc/stdio/ftell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c index 155248527072..7259e72109ee 100644 --- a/lib/libc/stdio/ftell.c +++ b/lib/libc/stdio/ftell.c @@ -97,8 +97,6 @@ _ftello(FILE *fp, fpos_t *offset) * Find offset of underlying I/O object, then * adjust for buffered bytes. */ - if (__sflush(fp)) /* may adjust seek offset on append stream */ - return (1); if (fp->_flags & __SOFF) pos = fp->_offset; else { @@ -120,6 +118,11 @@ _ftello(FILE *fp, fpos_t *offset) if (HASUB(fp)) pos -= fp->_r; /* Can be negative at this point. */ } else if ((fp->_flags & __SWR) && fp->_p != NULL) { + if (fp->_flags & __SAPP) { + pos = _sseek(fp, (fpos_t)0, SEEK_END); + if (pos == -1) + return (1); + } /* * Writing. Any buffered characters cause the * position to be greater than that in the -- 2.41.0