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/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index 994269b..54ca7a7 100644
--- a/libc/stdio/vfprintf.cpp
+++ b/libc/stdio/vfprintf.cpp
@@ -40,6 +40,26 @@
#define CHAR_TYPE_NAN "NAN"
#define CHAR_TYPE_nan "nan"
#define CHAR_TYPE_ORIENTATION -1
+
+#define PRINT(ptr, len) \
+ do { \
+ iovp->iov_base = (ptr); \
+ iovp->iov_len = (len); \
+ uio.uio_resid += (len); \
+ iovp++; \
+ if (++uio.uio_iovcnt >= NIOV) { \
+ if (helpers::sprint(fp, &uio)) goto error; \
+ iovp = iov; \
+ } \
+ } while (0)
+
+#define FLUSH() \
+ do { \
+ if (uio.uio_resid && helpers::sprint(fp, &uio)) goto error; \
+ uio.uio_iovcnt = 0; \
+ iovp = iov; \
+ } while (0)
+
#include "printf_common.h"
int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) {
@@ -115,24 +135,6 @@
static const char xdigs_lower[] = "0123456789abcdef";
static const char xdigs_upper[] = "0123456789ABCDEF";
-#define PRINT(ptr, len) \
- do { \
- iovp->iov_base = (ptr); \
- iovp->iov_len = (len); \
- uio.uio_resid += (len); \
- iovp++; \
- if (++uio.uio_iovcnt >= NIOV) { \
- if (helpers::sprint(fp, &uio)) goto error; \
- iovp = iov; \
- } \
- } while (0)
-#define FLUSH() \
- do { \
- if (uio.uio_resid && helpers::sprint(fp, &uio)) goto error; \
- uio.uio_iovcnt = 0; \
- iovp = iov; \
- } while (0)
-
_SET_ORIENTATION(fp, CHAR_TYPE_ORIENTATION);
// Writing "" to a read only file returns EOF, not 0.