More printf unification: FLUSH().
wprintf doesn't need this (and already only has the iov stuff because
the non-wide printf implementation needs it), but we can further reduce
the diff between the two implementations by defining a no-op FLUSH() for
wide characters.
Test: treehugger
Change-Id: Ifefcb4b8474b086f995e2b0796f61558a19e2a42
diff --git a/libc/stdio/vfwprintf.cpp b/libc/stdio/vfwprintf.cpp
index 0caeb2d..2f86b3c 100644
--- a/libc/stdio/vfwprintf.cpp
+++ b/libc/stdio/vfwprintf.cpp
@@ -40,6 +40,16 @@
#define CHAR_TYPE_NAN L"NAN"
#define CHAR_TYPE_nan L"nan"
#define CHAR_TYPE_ORIENTATION 1
+
+#define PRINT(ptr, len) \
+ do { \
+ for (int n3 = 0; n3 < (len); n3++) { \
+ if ((helpers::xfputwc((ptr)[n3], fp)) == WEOF) goto error; \
+ } \
+ } while (0)
+
+#define FLUSH()
+
#include "printf_common.h"
int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) {
@@ -115,13 +125,6 @@
static const char xdigs_lower[] = "0123456789abcdef";
static const char xdigs_upper[] = "0123456789ABCDEF";
-#define PRINT(ptr, len) \
- do { \
- for (int n3 = 0; n3 < (len); n3++) { \
- if ((helpers::xfputwc((ptr)[n3], fp)) == WEOF) goto error; \
- } \
- } while (0)
-
_SET_ORIENTATION(fp, CHAR_TYPE_ORIENTATION);
// Writing "" to a read only file returns EOF, not 0.
@@ -681,8 +684,11 @@
if (width < realsz) width = realsz;
if (width > INT_MAX - ret) goto overflow;
ret += width;
+
+ FLUSH(); /* copy out the I/O vectors */
}
done:
+ FLUSH();
error:
va_end(orgap);
if (__sferror(fp)) ret = -1;