Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-05-08 01:00:41 +0400
committerJeff Johnston <jjohnstn@redhat.com>2004-05-08 01:00:41 +0400
commit186420eccf901499b2503548e0cd51c76f781954 (patch)
tree8b1a455ea5df3517d59fdf29b755a7512a353c45
parent631fbe65fa105a836d21838152f2125067f2f27a (diff)
2004-05-07 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* libc/stdio/iprintf.c (_iprintf_r): Fix old-style argument list for reentrant pointer. Call _vfiprintf_r. * libc/stdio/siprintf.c (_siprintf_r): New function. * libc/stdio/vfprintf.c (__sbprintf): Add reetrant struct pointer argument. Change all callers. Call _VFPRINTF_R. * libc/include/stdio.h (_siprintf_r, _vfiprintf_r): New prototypes.
-rw-r--r--newlib/libc/include/stdio.h2
-rw-r--r--newlib/libc/stdio/iprintf.c7
-rw-r--r--newlib/libc/stdio/siprintf.c43
-rw-r--r--newlib/libc/stdio/vfprintf.c9
4 files changed, 54 insertions, 7 deletions
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index 576de35dd..86c948f95 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -282,6 +282,7 @@ long _EXFUN(_ftell_r, (struct _reent *, FILE *));
int _EXFUN(_getchar_r, (struct _reent *));
char * _EXFUN(_gets_r, (struct _reent *, char *));
int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...));
+int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...));
int _EXFUN(_mkstemp_r, (struct _reent *, char *));
char * _EXFUN(_mktemp_r, (struct _reent *, char *));
void _EXFUN(_perror_r, (struct _reent *, const char *));
@@ -300,6 +301,7 @@ FILE * _EXFUN(_tmpfile_r, (struct _reent *));
char * _EXFUN(_tmpnam_r, (struct _reent *, char *));
int _EXFUN(_ungetc_r, (struct _reent *, int, FILE *));
int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST));
+int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST));
int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST));
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;