Loading...
--- Libc/Libc-1082.20.4/stdio/FreeBSD/vfprintf.c
+++ Libc/Libc-825.26/stdio/FreeBSD/vfprintf.c
@@ -70,9 +70,7 @@
#include "printflocal.h"
static int __sprint(FILE *, locale_t, struct __suio *);
-#if 0
static int __sbprintf(FILE *, locale_t, const char *, va_list) __printflike(3, 0);
-#endif
static char *__wcsconv(wchar_t *, int, locale_t);
__private_extern__ const char *__fix_nogrouping(const char *);
@@ -168,7 +166,6 @@
return (err);
}
-#if 0
/*
* Helper function for `fprintf to unbuffered unix file': creates a
* temporary buffer. We only work on write-only files; this avoids
@@ -209,7 +206,6 @@
fp->_flags |= __SERR;
return (ret);
}
-#endif
/*
* Convert a wide character string argument for the %ls format to a multibyte
@@ -279,8 +275,14 @@
{
int ret;
+ NORMALIZE_LOCALE(loc);
FLOCKFILE(fp);
- ret = __xvprintf(XPRINTF_PLAIN, NULL, fp, loc, fmt0, ap);
+ /* optimise fprintf(stderr) (and other unbuffered Unix files) */
+ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
+ fp->_file >= 0)
+ ret = __sbprintf(fp, loc, fmt0, ap);
+ else
+ ret = __vfprintf(fp, loc, fmt0, ap);
FUNLOCKFILE(fp);
return (ret);
}
@@ -289,12 +291,7 @@
vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap)
{
- int ret;
-
- FLOCKFILE(fp);
- ret = __xvprintf(XPRINTF_PLAIN, NULL, fp, __current_locale(), fmt0, ap);
- FUNLOCKFILE(fp);
- return ret;
+ return vfprintf_l(fp, __current_locale(), fmt0, ap);
}
/*
@@ -461,15 +458,19 @@
val = GETARG (int); \
}
- /* The following has been moved to __v2printf() */
-#if 0
+#if 0 // xprintf pending API review
+ if (__use_xprintf == 0 && getenv("USE_XPRINTF"))
+ __use_xprintf = 1;
+ if (__use_xprintf > 0)
+ return (__xvprintf(fp, loc, fmt0, ap));
+#endif
+
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
if (prepwrite(fp) != 0) {
errno = EBADF;
return (EOF);
}
ORIENT(fp, -1);
-#endif
convbuf = NULL;
fmt = (char *)fmt0;