diff options
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
-rw-r--r-- | lib/libc/stdio/vfprintf.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 0b2d9f1..d312e7b 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -65,7 +65,8 @@ __FBSDID("$FreeBSD$"); #include "printflocal.h" static int __sprint(FILE *, struct __suio *); -static int __sbprintf(FILE *, const char *, va_list) __printflike(2, 0); +static int __sbprintf(FILE *, const char *, va_list) __printflike(2, 0) + __noinline; static char *__wcsconv(wchar_t *, int); #define CHAR char @@ -102,6 +103,10 @@ __sbprintf(FILE *fp, const char *fmt, va_list ap) FILE fake; unsigned char buf[BUFSIZ]; + /* XXX This is probably not needed. */ + if (prepwrite(fp) != 0) + return (EOF); + /* copy the important variables */ fake._flags = fp->_flags & ~__SNBF; fake._file = fp->_file; @@ -193,7 +198,12 @@ vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap) int ret; FLOCKFILE(fp); - ret = __vfprintf(fp, fmt0, ap); + /* optimise fprintf(stderr) (and other unbuffered Unix files) */ + if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && + fp->_file >= 0) + ret = __sbprintf(fp, fmt0, ap); + else + ret = __vfprintf(fp, fmt0, ap); FUNLOCKFILE(fp); return (ret); } @@ -367,11 +377,6 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap) if (prepwrite(fp) != 0) return (EOF); - /* optimise fprintf(stderr) (and other unbuffered Unix files) */ - if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && - fp->_file >= 0) - return (__sbprintf(fp, fmt0, ap)); - thousands_sep = '\0'; grouping = NULL; convbuf = NULL; |