diff options
Diffstat (limited to 'newlib/libc/stdio/vfwprintf.c')
-rw-r--r-- | newlib/libc/stdio/vfwprintf.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c index dfa8fde2f..5860147ec 100644 --- a/newlib/libc/stdio/vfwprintf.c +++ b/newlib/libc/stdio/vfwprintf.c @@ -150,13 +150,21 @@ SEEALSO int _EXFUN(_VFWPRINTF_R, (struct _reent *, FILE *, _CONST wchar_t *, va_list)); /* Defined in vfprintf.c. */ -#ifdef STRING_ONLY -#define __SPRINT __ssprint_r +#ifdef _FVWRITE_IN_STREAMIO +# ifdef STRING_ONLY +# define __SPRINT __ssprint_r +# else +# define __SPRINT __sprint_r +# endif +int _EXFUN(__SPRINT, (struct _reent *, FILE *, register struct __suio *)); #else -#define __SPRINT __sprint_r +# ifdef STRING_ONLY +# define __SPRINT __ssputs_r +# else +# define __SPRINT __sfputs_r +# endif +int _EXFUN(__SPRINT, (struct _reent *, FILE *, _CONST char *, size_t)); #endif -int _EXFUN(__SPRINT, (struct _reent *, FILE *, register struct __suio *)); - #ifndef STRING_ONLY /* * Helper function for `fprintf to unbuffered unix file': creates a @@ -377,7 +385,6 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), register wint_t ch; /* character from fmt */ register int n, m; /* handy integers (short term usage) */ register wchar_t *cp; /* handy char pointer (short term usage) */ - register struct __siov *iovp;/* for PRINT macro */ register int flags; /* flags as above */ wchar_t *fmt_anchor; /* current format spec being processed */ #ifndef _NO_POS_ARGS @@ -426,9 +433,12 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), int realsz; /* field size expanded by dprec */ int size = 0; /* size of converted field or string */ wchar_t *xdigs = NULL; /* digits for [xX] conversion */ +#ifdef _FVWRITE_IN_STREAMIO #define NIOV 8 struct __suio uio; /* output information: summary */ struct __siov iov[NIOV];/* ... and individual io vectors */ + register struct __siov *iovp;/* for PRINT macro */ +#endif wchar_t buf[BUF]; /* space for %c, %ls/%S, %[diouxX], %[aA] */ wchar_t ox[2]; /* space for 0x hex-prefix */ wchar_t *malloc_buf = NULL;/* handy pointer for malloced buffers */ @@ -469,6 +479,7 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), /* * BEWARE, these `goto error' on error, and PAD uses `n'. */ +#ifdef _FVWRITE_IN_STREAMIO #define PRINT(ptr, len) { \ iovp->iov_base = (char *) (ptr); \ iovp->iov_len = (len) * sizeof (wchar_t); \ @@ -503,6 +514,30 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), uio.uio_iovcnt = 0; \ iovp = iov; \ } +#else +#define PRINT(ptr, len) { \ + if (__SPRINT (data, fp, (_CONST char *)(ptr), (len) * sizeof (wchar_t)) == EOF) \ + goto error; \ +} +#define PAD(howmany, with) { \ + if ((n = (howmany)) > 0) { \ + while (n > PADSIZE) { \ + PRINT (with, PADSIZE); \ + n -= PADSIZE; \ + } \ + PRINT (with, n); \ + } \ +} +#define PRINTANDPAD(p, ep, len, with) { \ + int n = (ep) - (p); \ + if (n > (len)) \ + n = (len); \ + if (n > 0) \ + PRINT((p), n); \ + PAD((len) - (n > 0 ? n : 0), (with)); \ +} +#define FLUSH() +#endif /* Macros to support positional arguments */ #ifndef _NO_POS_ARGS @@ -585,9 +620,11 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), #endif /* STRING_ONLY */ fmt = (wchar_t *)fmt0; +#ifdef _FVWRITE_IN_STREAMIO uio.uio_iov = iovp = iov; uio.uio_resid = 0; uio.uio_iovcnt = 0; +#endif ret = 0; #ifndef _NO_POS_ARGS arg_index = 0; |