diff options
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r-- | newlib/libc/stdio/iprintf.c | 7 | ||||
-rw-r--r-- | newlib/libc/stdio/siprintf.c | 43 | ||||
-rw-r--r-- | newlib/libc/stdio/vfprintf.c | 9 |
3 files changed, 52 insertions, 7 deletions
diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c index 9bbe733ea..4b698ad7f 100644 --- a/newlib/libc/stdio/iprintf.c +++ b/newlib/libc/stdio/iprintf.c @@ -96,8 +96,8 @@ int _iprintf_r(struct _reent *ptr, _CONST char *fmt, ...) #else int -_iprintf_r(data, fmt, va_alist) - char *data; +_iprintf_r(ptr, fmt, va_alist) + struct _reent *ptr; char *fmt; va_dcl #endif @@ -111,7 +111,8 @@ _iprintf_r(data, fmt, va_alist) #else va_start (ap); #endif - ret = vfiprintf (_stdout_r (ptr), fmt, ap); + ret = _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap); va_end (ap); return ret; } + diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index 146233971..95ff8084f 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -27,6 +27,12 @@ ANSI_SYNOPSIS int siprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]); +TRAD_SYNOPSIS + #include <stdio.h> + + int siprintf(<[str]>, <[format]>, [, <[arg]>, ...]) + char *<[str]>; + const char *<[format]>; DESCRIPTION <<siprintf>> is a restricted version of <<sprintf>>: it has the same @@ -58,6 +64,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <limits.h> #include "local.h" +#ifndef _REENT_ONLY + int #ifdef _HAVE_STDC _DEFUN(siprintf, (str, fmt), @@ -87,3 +95,38 @@ siprintf(str, fmt, va_alist) *f._p = 0; return (ret); } + +#endif /* ! _REENT_ONLY */ + +int +#ifdef _HAVE_STDC +_DEFUN(_siprintf_r, (rptr, str, fmt), + struct _reent *rptr _AND + char *str _AND + _CONST char *fmt _DOTS) +#else +_siprintf_r(rptr, str, fmt, va_alist) + struct _reent *rptr; + char *str; + _CONST char *fmt; + va_dcl +#endif +{ + int ret; + va_list ap; + FILE f; + + f._flags = __SWR | __SSTR; + f._bf._base = f._p = (unsigned char *) str; + f._bf._size = f._w = INT_MAX; +#ifdef _HAVE_STDC + va_start (ap, fmt); +#else + va_start (ap); +#endif + ret = _vfiprintf_r (rptr, &f, fmt, ap); + va_end (ap); + *f._p = 0; + return (ret); +} + diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index b72117582..906934787 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -233,8 +233,9 @@ _DEFUN(__sprint, (fp, uio), * worries about ungetc buffers and so forth. */ static int -_DEFUN(__sbprintf, (fp, fmt, ap), - register FILE *fp _AND +_DEFUN(__sbprintf, (rptr, fp, fmt, ap), + struct _reent *rptr _AND + register FILE *fp _AND _CONST char *fmt _AND va_list ap) { @@ -257,7 +258,7 @@ _DEFUN(__sbprintf, (fp, fmt, ap), #endif /* do the work, then copy any error status */ - ret = VFPRINTF (&fake, fmt, ap); + ret = _VFPRINTF_R (rptr, &fake, fmt, ap); if (ret >= 0 && fflush(&fake)) ret = EOF; if (fake._flags & __SERR) @@ -541,7 +542,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), /* optimise fprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) - return (__sbprintf (fp, fmt0, ap)); + return (__sbprintf (data, fp, fmt0, ap)); fmt = (char *)fmt0; uio.uio_iov = iovp = iov; |