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>2007-04-04 22:32:49 +0400
committerJeff Johnston <jjohnstn@redhat.com>2007-04-04 22:32:49 +0400
commitdb7aa4b168ac43894f6ce58cf9b79b5be528e378 (patch)
treedfcfcb8f9fe73b8cf5b80caff3773925daa13c23 /newlib/libc/stdio
parent26631d2144fcc57286421c1bba8fde1935603dd1 (diff)
2007-04-04 Eric Blake <ebb9@byu.net>
* libc/stdio/asiprintf.c (_asiprintf_r): Fix reentrancy. (asiprintf): Avoid overhead. * libc/stdio/asprintf.c (_asprintf_r): Fix reentrancy. (asprintf): Avoid overhead. * libc/stdio/diprintf.c (_diprintf_r, diprintf): New file. * libc/stdio/dprintf.c (_dprintf_r, dprintf): Use _DEFUN. * libc/stdio/fiprintf.c (_fiprintf_r): Add reentrant version. (fiprintf): Avoid overhead. * libc/stdio/fprintf.c (_fprintf_r): Add reentrant version. (fprintf): Avoid overhead. * libc/stdio/iprintf.c (_iprintf_r): Use _DEFUN. (iprintf): Avoid overhead. * libc/stdio/printf.c (_printf_r): Use _DEFUN. (printf): Avoid overhead. * libc/stdio/vasiprintf.c (vasiprintf): Reduce binary size. * libc/stdio/vasprintf.c (vasprintf): Reduce binary size. * libc/stdio/vdiprintf.c (_vdiprintf_r, vdiprintf): New file. * libc/stdio/vdprintf.c (vdprintf): Avoid overhead. * libc/stdio/vsiprintf.c (vsiprintf): Reduce binary size. * libc/stdio/vsniprintf.c (vsniprintf): Reduce binary size. * libc/stdio/vsnprintf.c (vsnprintf): Reduce binary size. * libc/stdio/vsprintf.c (vsprintf): Reduce binary size. * libc/stdio/Makefile.am (GENERAL_SOURCES): Add diprintf.c, vdiprintf.c. * libc/include/stdio.h (diprintf, _diprintf_r, vdiprintf) (_vdiprintf_r, _fiprintf_r, _vfiprintf_r): Add prototypes.
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r--newlib/libc/stdio/Makefile.am4
-rw-r--r--newlib/libc/stdio/Makefile.in113
-rw-r--r--newlib/libc/stdio/asiprintf.c37
-rw-r--r--newlib/libc/stdio/asprintf.c37
-rw-r--r--newlib/libc/stdio/diprintf.c75
-rw-r--r--newlib/libc/stdio/dprintf.c63
-rw-r--r--newlib/libc/stdio/fiprintf.c40
-rw-r--r--newlib/libc/stdio/fprintf.c40
-rw-r--r--newlib/libc/stdio/iprintf.c40
-rw-r--r--newlib/libc/stdio/printf.c39
-rw-r--r--newlib/libc/stdio/vasiprintf.c23
-rw-r--r--newlib/libc/stdio/vasprintf.c23
-rw-r--r--newlib/libc/stdio/vdiprintf.c42
-rw-r--r--newlib/libc/stdio/vdprintf.c47
-rw-r--r--newlib/libc/stdio/vsiprintf.c22
-rw-r--r--newlib/libc/stdio/vsniprintf.c28
-rw-r--r--newlib/libc/stdio/vsnprintf.c28
-rw-r--r--newlib/libc/stdio/vsprintf.c22
18 files changed, 318 insertions, 405 deletions
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am
index efe0ede49..d13b3febf 100644
--- a/newlib/libc/stdio/Makefile.am
+++ b/newlib/libc/stdio/Makefile.am
@@ -6,6 +6,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = \
clearerr.c \
+ diprintf.c \
dprintf.c \
fclose.c \
fdopen.c \
@@ -71,6 +72,7 @@ GENERAL_SOURCES = \
tmpfile.c \
tmpnam.c \
ungetc.c \
+ vdiprintf.c \
vdprintf.c \
viprintf.c \
viscanf.c \
@@ -83,7 +85,7 @@ GENERAL_SOURCES = \
vsprintf.c \
vsscanf.c \
wbuf.c \
- wsetup.c
+ wsetup.c
## The following are EL/IX level 2 interfaces
if ELIX_LEVEL_1
diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in
index a3745f3c9..67ad99807 100644
--- a/newlib/libc/stdio/Makefile.in
+++ b/newlib/libc/stdio/Makefile.in
@@ -53,39 +53,40 @@ ARFLAGS = cru
lib_a_AR = $(AR) $(ARFLAGS)
am__DEPENDENCIES_1 = $(lpfx)vfiprintf.$(oext) $(lpfx)vfprintf.$(oext) \
$(lpfx)vfscanf.$(oext) $(lpfx)vfiscanf.$(oext)
-am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-dprintf.$(OBJEXT) \
- lib_a-fclose.$(OBJEXT) lib_a-fdopen.$(OBJEXT) \
- lib_a-feof.$(OBJEXT) lib_a-ferror.$(OBJEXT) \
- lib_a-fflush.$(OBJEXT) lib_a-fgetc.$(OBJEXT) \
- lib_a-fgetpos.$(OBJEXT) lib_a-fgets.$(OBJEXT) \
- lib_a-fileno.$(OBJEXT) lib_a-findfp.$(OBJEXT) \
- lib_a-fiprintf.$(OBJEXT) lib_a-flags.$(OBJEXT) \
- lib_a-fopen.$(OBJEXT) lib_a-fprintf.$(OBJEXT) \
- lib_a-fputc.$(OBJEXT) lib_a-fputs.$(OBJEXT) \
- lib_a-fread.$(OBJEXT) lib_a-freopen.$(OBJEXT) \
- lib_a-fscanf.$(OBJEXT) lib_a-fiscanf.$(OBJEXT) \
- lib_a-fseek.$(OBJEXT) lib_a-fsetpos.$(OBJEXT) \
- lib_a-ftell.$(OBJEXT) lib_a-fvwrite.$(OBJEXT) \
- lib_a-fwalk.$(OBJEXT) lib_a-fwrite.$(OBJEXT) \
- lib_a-getc.$(OBJEXT) lib_a-getchar.$(OBJEXT) \
- lib_a-getc_u.$(OBJEXT) lib_a-getchar_u.$(OBJEXT) \
- lib_a-getdelim.$(OBJEXT) lib_a-getline.$(OBJEXT) \
- lib_a-gets.$(OBJEXT) lib_a-iprintf.$(OBJEXT) \
- lib_a-iscanf.$(OBJEXT) lib_a-makebuf.$(OBJEXT) \
- lib_a-perror.$(OBJEXT) lib_a-printf.$(OBJEXT) \
- lib_a-putc.$(OBJEXT) lib_a-putchar.$(OBJEXT) \
- lib_a-putc_u.$(OBJEXT) lib_a-putchar_u.$(OBJEXT) \
- lib_a-puts.$(OBJEXT) lib_a-refill.$(OBJEXT) \
- lib_a-remove.$(OBJEXT) lib_a-rename.$(OBJEXT) \
- lib_a-rewind.$(OBJEXT) lib_a-rget.$(OBJEXT) \
- lib_a-scanf.$(OBJEXT) lib_a-sccl.$(OBJEXT) \
- lib_a-setbuf.$(OBJEXT) lib_a-setbuffer.$(OBJEXT) \
- lib_a-setlinebuf.$(OBJEXT) lib_a-setvbuf.$(OBJEXT) \
- lib_a-siprintf.$(OBJEXT) lib_a-siscanf.$(OBJEXT) \
- lib_a-sniprintf.$(OBJEXT) lib_a-snprintf.$(OBJEXT) \
- lib_a-sprintf.$(OBJEXT) lib_a-sscanf.$(OBJEXT) \
- lib_a-stdio.$(OBJEXT) lib_a-tmpfile.$(OBJEXT) \
- lib_a-tmpnam.$(OBJEXT) lib_a-ungetc.$(OBJEXT) \
+am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-diprintf.$(OBJEXT) \
+ lib_a-dprintf.$(OBJEXT) lib_a-fclose.$(OBJEXT) \
+ lib_a-fdopen.$(OBJEXT) lib_a-feof.$(OBJEXT) \
+ lib_a-ferror.$(OBJEXT) lib_a-fflush.$(OBJEXT) \
+ lib_a-fgetc.$(OBJEXT) lib_a-fgetpos.$(OBJEXT) \
+ lib_a-fgets.$(OBJEXT) lib_a-fileno.$(OBJEXT) \
+ lib_a-findfp.$(OBJEXT) lib_a-fiprintf.$(OBJEXT) \
+ lib_a-flags.$(OBJEXT) lib_a-fopen.$(OBJEXT) \
+ lib_a-fprintf.$(OBJEXT) lib_a-fputc.$(OBJEXT) \
+ lib_a-fputs.$(OBJEXT) lib_a-fread.$(OBJEXT) \
+ lib_a-freopen.$(OBJEXT) lib_a-fscanf.$(OBJEXT) \
+ lib_a-fiscanf.$(OBJEXT) lib_a-fseek.$(OBJEXT) \
+ lib_a-fsetpos.$(OBJEXT) lib_a-ftell.$(OBJEXT) \
+ lib_a-fvwrite.$(OBJEXT) lib_a-fwalk.$(OBJEXT) \
+ lib_a-fwrite.$(OBJEXT) lib_a-getc.$(OBJEXT) \
+ lib_a-getchar.$(OBJEXT) lib_a-getc_u.$(OBJEXT) \
+ lib_a-getchar_u.$(OBJEXT) lib_a-getdelim.$(OBJEXT) \
+ lib_a-getline.$(OBJEXT) lib_a-gets.$(OBJEXT) \
+ lib_a-iprintf.$(OBJEXT) lib_a-iscanf.$(OBJEXT) \
+ lib_a-makebuf.$(OBJEXT) lib_a-perror.$(OBJEXT) \
+ lib_a-printf.$(OBJEXT) lib_a-putc.$(OBJEXT) \
+ lib_a-putchar.$(OBJEXT) lib_a-putc_u.$(OBJEXT) \
+ lib_a-putchar_u.$(OBJEXT) lib_a-puts.$(OBJEXT) \
+ lib_a-refill.$(OBJEXT) lib_a-remove.$(OBJEXT) \
+ lib_a-rename.$(OBJEXT) lib_a-rewind.$(OBJEXT) \
+ lib_a-rget.$(OBJEXT) lib_a-scanf.$(OBJEXT) \
+ lib_a-sccl.$(OBJEXT) lib_a-setbuf.$(OBJEXT) \
+ lib_a-setbuffer.$(OBJEXT) lib_a-setlinebuf.$(OBJEXT) \
+ lib_a-setvbuf.$(OBJEXT) lib_a-siprintf.$(OBJEXT) \
+ lib_a-siscanf.$(OBJEXT) lib_a-sniprintf.$(OBJEXT) \
+ lib_a-snprintf.$(OBJEXT) lib_a-sprintf.$(OBJEXT) \
+ lib_a-sscanf.$(OBJEXT) lib_a-stdio.$(OBJEXT) \
+ lib_a-tmpfile.$(OBJEXT) lib_a-tmpnam.$(OBJEXT) \
+ lib_a-ungetc.$(OBJEXT) lib_a-vdiprintf.$(OBJEXT) \
lib_a-vdprintf.$(OBJEXT) lib_a-viprintf.$(OBJEXT) \
lib_a-viscanf.$(OBJEXT) lib_a-vprintf.$(OBJEXT) \
lib_a-vscanf.$(OBJEXT) lib_a-vsiprintf.$(OBJEXT) \
@@ -107,21 +108,21 @@ am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-dprintf.$(OBJEXT) \
@USE_LIBTOOL_FALSE@ $(am__objects_2)
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
LTLIBRARIES = $(noinst_LTLIBRARIES)
-am__objects_3 = clearerr.lo dprintf.lo fclose.lo fdopen.lo feof.lo \
- ferror.lo fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo \
- findfp.lo fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo \
- fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo \
- fsetpos.lo ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo \
- getchar.lo getc_u.lo getchar_u.lo getdelim.lo getline.lo \
- gets.lo iprintf.lo iscanf.lo makebuf.lo perror.lo printf.lo \
- putc.lo putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo \
- remove.lo rename.lo rewind.lo rget.lo scanf.lo sccl.lo \
- setbuf.lo setbuffer.lo setlinebuf.lo setvbuf.lo siprintf.lo \
- siscanf.lo sniprintf.lo snprintf.lo sprintf.lo sscanf.lo \
- stdio.lo tmpfile.lo tmpnam.lo ungetc.lo vdprintf.lo \
- viprintf.lo viscanf.lo vprintf.lo vscanf.lo vsiprintf.lo \
- vsiscanf.lo vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \
- wbuf.lo wsetup.lo
+am__objects_3 = clearerr.lo diprintf.lo dprintf.lo fclose.lo fdopen.lo \
+ feof.lo ferror.lo fflush.lo fgetc.lo fgetpos.lo fgets.lo \
+ fileno.lo findfp.lo fiprintf.lo flags.lo fopen.lo fprintf.lo \
+ fputc.lo fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo \
+ fseek.lo fsetpos.lo ftell.lo fvwrite.lo fwalk.lo fwrite.lo \
+ getc.lo getchar.lo getc_u.lo getchar_u.lo getdelim.lo \
+ getline.lo gets.lo iprintf.lo iscanf.lo makebuf.lo perror.lo \
+ printf.lo putc.lo putchar.lo putc_u.lo putchar_u.lo puts.lo \
+ refill.lo remove.lo rename.lo rewind.lo rget.lo scanf.lo \
+ sccl.lo setbuf.lo setbuffer.lo setlinebuf.lo setvbuf.lo \
+ siprintf.lo siscanf.lo sniprintf.lo snprintf.lo sprintf.lo \
+ sscanf.lo stdio.lo tmpfile.lo tmpnam.lo ungetc.lo vdiprintf.lo \
+ vdprintf.lo viprintf.lo viscanf.lo vprintf.lo vscanf.lo \
+ vsiprintf.lo vsiscanf.lo vsnprintf.lo vsniprintf.lo \
+ vsprintf.lo vsscanf.lo wbuf.lo wsetup.lo
@ELIX_LEVEL_1_FALSE@am__objects_4 = asiprintf.lo asprintf.lo \
@ELIX_LEVEL_1_FALSE@ fcloseall.lo fseeko.lo ftello.lo getw.lo \
@ELIX_LEVEL_1_FALSE@ mktemp.lo putw.lo vasiprintf.lo \
@@ -293,6 +294,7 @@ AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = \
clearerr.c \
+ diprintf.c \
dprintf.c \
fclose.c \
fdopen.c \
@@ -358,6 +360,7 @@ GENERAL_SOURCES = \
tmpfile.c \
tmpnam.c \
ungetc.c \
+ vdiprintf.c \
vdprintf.c \
viprintf.c \
viscanf.c \
@@ -370,7 +373,7 @@ GENERAL_SOURCES = \
vsprintf.c \
vsscanf.c \
wbuf.c \
- wsetup.c
+ wsetup.c
@ELIX_LEVEL_1_FALSE@ELIX_SOURCES = \
@ELIX_LEVEL_1_FALSE@ asiprintf.c \
@@ -537,6 +540,12 @@ lib_a-clearerr.o: clearerr.c
lib_a-clearerr.obj: clearerr.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-clearerr.obj `if test -f 'clearerr.c'; then $(CYGPATH_W) 'clearerr.c'; else $(CYGPATH_W) '$(srcdir)/clearerr.c'; fi`
+lib_a-diprintf.o: diprintf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-diprintf.o `test -f 'diprintf.c' || echo '$(srcdir)/'`diprintf.c
+
+lib_a-diprintf.obj: diprintf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-diprintf.obj `if test -f 'diprintf.c'; then $(CYGPATH_W) 'diprintf.c'; else $(CYGPATH_W) '$(srcdir)/diprintf.c'; fi`
+
lib_a-dprintf.o: dprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dprintf.o `test -f 'dprintf.c' || echo '$(srcdir)/'`dprintf.c
@@ -927,6 +936,12 @@ lib_a-ungetc.o: ungetc.c
lib_a-ungetc.obj: ungetc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ungetc.obj `if test -f 'ungetc.c'; then $(CYGPATH_W) 'ungetc.c'; else $(CYGPATH_W) '$(srcdir)/ungetc.c'; fi`
+lib_a-vdiprintf.o: vdiprintf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdiprintf.o `test -f 'vdiprintf.c' || echo '$(srcdir)/'`vdiprintf.c
+
+lib_a-vdiprintf.obj: vdiprintf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdiprintf.obj `if test -f 'vdiprintf.c'; then $(CYGPATH_W) 'vdiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vdiprintf.c'; fi`
+
lib_a-vdprintf.o: vdprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdprintf.o `test -f 'vdprintf.c' || echo '$(srcdir)/'`vdprintf.c
diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c
index afb1f7c33..0f2d6d96b 100644
--- a/newlib/libc/stdio/asiprintf.c
+++ b/newlib/libc/stdio/asiprintf.c
@@ -19,27 +19,15 @@
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <limits.h>
#include "local.h"
int
-#ifdef _HAVE_STDC
_DEFUN(_asiprintf_r, (ptr, strp, fmt),
struct _reent *ptr _AND
char **strp _AND
- _CONST char *fmt _DOTS)
-#else
-_asiprintf_r(ptr, strp, fmt, va_alist)
- struct _reent *ptr;
- char **strp;
- _CONST char *fmt;
- va_dcl
-#endif
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
@@ -50,12 +38,8 @@ _asiprintf_r(ptr, strp, fmt, va_alist)
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfiprintf (&f, fmt, ap);
+ ret = _vfiprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (ret >= 0)
{
@@ -68,16 +52,9 @@ _asiprintf_r(ptr, strp, fmt, va_alist)
#ifndef _REENT_ONLY
int
-#ifdef _HAVE_STDC
_DEFUN(asiprintf, (strp, fmt),
char **strp _AND
- _CONST char *fmt _DOTS)
-#else
-asiprintf(strp, fmt, va_alist)
- char **strp;
- _CONST char *fmt;
- va_dcl
-#endif
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
@@ -88,12 +65,8 @@ asiprintf(strp, fmt, va_alist)
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfiprintf (&f, fmt, ap);
+ ret = _vfiprintf_r (_REENT, &f, fmt, ap);
va_end (ap);
if (ret >= 0)
{
@@ -103,4 +76,4 @@ asiprintf(strp, fmt, va_alist)
return (ret);
}
-#endif
+#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c
index 39536800b..c7183f341 100644
--- a/newlib/libc/stdio/asprintf.c
+++ b/newlib/libc/stdio/asprintf.c
@@ -19,27 +19,15 @@
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <limits.h>
#include "local.h"
int
-#ifdef _HAVE_STDC
_DEFUN(_asprintf_r, (ptr, strp, fmt),
struct _reent *ptr _AND
char **strp _AND
- _CONST char *fmt _DOTS)
-#else
-_asprintf_r(ptr, strp, fmt, va_alist)
- struct _reent *ptr;
- char **strp;
- _CONST char *fmt;
- va_dcl
-#endif
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
@@ -50,12 +38,8 @@ _asprintf_r(ptr, strp, fmt, va_alist)
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfprintf (&f, fmt, ap);
+ ret = _vfprintf_r (ptr, &f, fmt, ap);
va_end (ap);
if (ret >= 0)
{
@@ -68,16 +52,9 @@ _asprintf_r(ptr, strp, fmt, va_alist)
#ifndef _REENT_ONLY
int
-#ifdef _HAVE_STDC
_DEFUN(asprintf, (strp, fmt),
char **strp _AND
- _CONST char *fmt _DOTS)
-#else
-asprintf(strp, fmt, va_alist)
- char **strp;
- _CONST char *fmt;
- va_dcl
-#endif
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
@@ -88,12 +65,8 @@ asprintf(strp, fmt, va_alist)
f._bf._base = f._p = NULL;
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfprintf (&f, fmt, ap);
+ ret = _vfprintf_r (_REENT, &f, fmt, ap);
va_end (ap);
if (ret >= 0)
{
@@ -103,4 +76,4 @@ asprintf(strp, fmt, va_alist)
return (ret);
}
-#endif
+#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/diprintf.c b/newlib/libc/stdio/diprintf.c
new file mode 100644
index 000000000..7882e46b2
--- /dev/null
+++ b/newlib/libc/stdio/diprintf.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 2005, 2007 Shaun Jackman
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+/*
+FUNCTION
+<<diprintf>>, <<vdiprintf>>---print to a file descriptor
+
+INDEX
+ diprintf
+INDEX
+ vdiprintf
+
+ANSI_SYNOPSIS
+ #include <stdio.h>
+ #include <stdarg.h>
+ int diprintf(int <[fd]>, const char *<[format]>, ...);
+ int vdiprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>);
+ int _diprintf_r(struct _reent *<[ptr]>, int <[fd]>,
+ const char *<[format]>, ...);
+ int _vidprintf_r(struct _reent *<[ptr]>, int <[fd]>,
+ const char *<[format]>, va_list <[ap]>);
+
+DESCRIPTION
+<<diprintf>> and <<vdiprintf>> are similar to <<dprintf>> and <<vdprintf>>,
+except that only integer format specifiers are processed.
+
+RETURNS
+Similar to <<dprintf>> and <<vdprintf>>.
+
+PORTABILITY
+This set of functions is an integer-only extension, and is not portable.
+
+Supporting OS subroutines required: <<sbrk>>, <<write>>.
+*/
+
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+int
+_DEFUN(_diprintf_r, (ptr, fd, format),
+ struct _reent *ptr _AND
+ int fd _AND
+ const char *format _DOTS)
+{
+ va_list ap;
+ int n;
+
+ va_start (ap, format);
+ n = _vdiprintf_r (ptr, fd, format, ap);
+ va_end (ap);
+ return n;
+}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(diprintf, (fd, format),
+ int fd _AND
+ const char *format _DOTS)
+{
+ va_list ap;
+ int n;
+
+ va_start (ap, format);
+ n = _vdiprintf_r (_REENT, fd, format, ap);
+ va_end (ap);
+ return n;
+}
+
+#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/dprintf.c b/newlib/libc/stdio/dprintf.c
index 6ebf12e8d..fd3c9b684 100644
--- a/newlib/libc/stdio/dprintf.c
+++ b/newlib/libc/stdio/dprintf.c
@@ -1,4 +1,4 @@
-/* Copyright 2005 Shaun Jackman
+/* Copyright 2005, 2007 Shaun Jackman
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
@@ -17,9 +17,9 @@ ANSI_SYNOPSIS
#include <stdarg.h>
int dprintf(int <[fd]>, const char *<[format]>, ...);
int vdprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>);
- int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>,
+ int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>,
const char *<[format]>, ...);
- int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>,
+ int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>,
const char *<[format]>, va_list <[ap]>);
TRAD_SYNOPSIS
@@ -68,32 +68,18 @@ Supporting OS subroutines required: <<sbrk>>, <<write>>.
#include <reent.h>
#include <stdio.h>
#include <unistd.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#ifdef _HAVE_STDC
int
-_dprintf_r(struct _reent *ptr, int fd, _CONST char *format, ...)
-#else
-int
-_dprintf_r(ptr, fd, format, va_alist)
- struct _reent *ptr;
- int fd;
- char *format;
- va_dcl
-#endif
+_DEFUN(_dprintf_r, (ptr, fd, format),
+ struct _reent *ptr _AND
+ int fd _AND
+ const char *format _DOTS)
{
va_list ap;
int n;
_REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
- va_start (ap, format);
-#else
- va_start (ap);
-#endif
+ va_start (ap, format);
n = _vdprintf_r (ptr, fd, format, ap);
va_end (ap);
return n;
@@ -101,29 +87,20 @@ _dprintf_r(ptr, fd, format, va_alist)
#ifndef _REENT_ONLY
-#ifdef _HAVE_STDC
-int
-dprintf(int fd, _CONST char *format, ...)
-#else
int
-dprintf(fd, format, va_alist)
- struct _reent *ptr;
- int fd;
- char *format;
- va_dcl
-#endif
+_DEFUN(dprintf, (fd, format),
+ int fd _AND
+ const char *format _DOTS)
{
- va_list ap;
- int n;
- _REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
- va_start (ap, format);
-#else
- va_start (ap);
-#endif
- n = _vdprintf_r (_REENT, fd, format, ap);
- va_end (ap);
- return n;
+ va_list ap;
+ int n;
+ struct _reent *ptr = _REENT;
+
+ _REENT_SMALL_CHECK_INIT (ptr);
+ va_start (ap, format);
+ n = _vdprintf_r (ptr, fd, format, ap);
+ va_end (ap);
+ return n;
}
#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/fiprintf.c b/newlib/libc/stdio/fiprintf.c
index 3529e7f19..0db5f1b7c 100644
--- a/newlib/libc/stdio/fiprintf.c
+++ b/newlib/libc/stdio/fiprintf.c
@@ -16,33 +16,39 @@
*/
#include <_ansi.h>
+#include <reent.h>
#include <stdio.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#ifdef _HAVE_STDC
int
-fiprintf(FILE * fp, _CONST char *fmt,...)
-#else
+_DEFUN(_fiprintf_r, (ptr, fp, fmt),
+ struct _reent *ptr _AND
+ FILE * fp _AND
+ const char *fmt _DOTS)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ ret = _vfiprintf_r (ptr, fp, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+#ifndef _REENT_ONLY
+
int
-fiprintf(fp, fmt, va_alist)
- FILE *fp;
- char *fmt;
- va_dcl
-#endif
+_DEFUN(fiprintf, (fp, fmt),
+ FILE * fp _AND
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfiprintf (fp, fmt, ap);
+ ret = _vfiprintf_r (_REENT, fp, fmt, ap);
va_end (ap);
return ret;
}
+
+#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/fprintf.c b/newlib/libc/stdio/fprintf.c
index 56a08863a..c33a42c10 100644
--- a/newlib/libc/stdio/fprintf.c
+++ b/newlib/libc/stdio/fprintf.c
@@ -16,33 +16,39 @@
*/
#include <_ansi.h>
+#include <reent.h>
#include <stdio.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#ifdef _HAVE_STDC
int
-fprintf(FILE * fp, _CONST char *fmt,...)
-#else
+_DEFUN(_fprintf_r, (ptr, fp, fmt),
+ struct _reent *ptr _AND
+ FILE *fp _AND
+ const char *fmt _DOTS)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ ret = _vfprintf_r (ptr, fp, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+#ifndef _REENT_ONLY
+
int
-fprintf(fp, fmt, va_alist)
- FILE *fp;
- char *fmt;
- va_dcl
-#endif
+_DEFUN(fprintf, (fp, fmt),
+ FILE *fp _AND
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfprintf (fp, fmt, ap);
+ ret = _vfprintf_r (_REENT, fp, fmt, ap);
va_end (ap);
return ret;
}
+
+#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c
index c9a026424..9af977227 100644
--- a/newlib/libc/stdio/iprintf.c
+++ b/newlib/libc/stdio/iprintf.c
@@ -18,63 +18,39 @@
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include "local.h"
#ifndef _REENT_ONLY
-#ifdef _HAVE_STDC
int
-iprintf(_CONST char *fmt,...)
-#else
-int
-iprintf(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
+_DEFUN(iprintf, (fmt),
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
+ struct _reent *ptr = _REENT;
- _REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
+ _REENT_SMALL_CHECK_INIT (ptr);
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfiprintf (stdout, fmt, ap);
+ ret = _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
#endif /* ! _REENT_ONLY */
-#ifdef _HAVE_STDC
int
-_iprintf_r(struct _reent *ptr, _CONST char *fmt, ...)
-#else
-int
-_iprintf_r(ptr, fmt, va_alist)
- struct _reent *ptr;
- char *fmt;
- va_dcl
-#endif
+_DEFUN(_iprintf_r, (ptr, fmt),
+ struct _reent *ptr _AND
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
ret = _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
-
diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c
index 19f465e34..7330dd918 100644
--- a/newlib/libc/stdio/printf.c
+++ b/newlib/libc/stdio/printf.c
@@ -18,33 +18,19 @@
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include "local.h"
-#ifdef _HAVE_STDC
int
-_printf_r(struct _reent *ptr, _CONST char *fmt, ...)
-#else
-int
-_printf_r(ptr, fmt, va_alist)
- struct _reent *ptr;
- char *fmt;
- va_dcl
-#endif
+_DEFUN(_printf_r, (ptr, fmt),
+ struct _reent *ptr _AND
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
_REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
@@ -52,26 +38,17 @@ _printf_r(ptr, fmt, va_alist)
#ifndef _REENT_ONLY
-#ifdef _HAVE_STDC
-int
-printf(_CONST char *fmt, ...)
-#else
int
-printf(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
+_DEFUN(printf, (fmt),
+ const char *fmt _DOTS)
{
int ret;
va_list ap;
+ struct _reent *ptr = _REENT;
- _REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
+ _REENT_SMALL_CHECK_INIT (ptr);
va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = vfprintf (_stdout_r (_REENT), fmt, ap);
+ ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
va_end (ap);
return ret;
}
diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c
index 72aa19d11..b16efe794 100644
--- a/newlib/libc/stdio/vasiprintf.c
+++ b/newlib/libc/stdio/vasiprintf.c
@@ -24,34 +24,17 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <_ansi.h>
#include <stdio.h>
#include <limits.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#ifndef _REENT_ONLY
int
_DEFUN(vasiprintf, (strp, fmt, ap),
char **strp _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
- int ret;
- FILE f;
-
- f._flags = __SWR | __SSTR | __SMBF;
- f._bf._base = f._p = NULL;
- f._bf._size = f._w = 0;
- f._file = -1; /* No file. */
- ret = _vfiprintf_r (_REENT, &f, fmt, ap);
- if (ret >= 0)
- {
- *f._p = 0;
- *strp = f._bf._base;
- }
- return ret;
+ return _vasiprintf_r (_REENT, strp, fmt, ap);
}
#endif /* !_REENT_ONLY */
@@ -60,7 +43,7 @@ int
_DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap),
struct _reent *ptr _AND
char **strp _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
int ret;
diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c
index 2c8065cbc..90539d1d8 100644
--- a/newlib/libc/stdio/vasprintf.c
+++ b/newlib/libc/stdio/vasprintf.c
@@ -24,34 +24,17 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <_ansi.h>
#include <stdio.h>
#include <limits.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#ifndef _REENT_ONLY
int
_DEFUN(vasprintf, (strp, fmt, ap),
char **strp _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
- int ret;
- FILE f;
-
- f._flags = __SWR | __SSTR | __SMBF;
- f._bf._base = f._p = NULL;
- f._bf._size = f._w = 0;
- f._file = -1; /* No file. */
- ret = _vfprintf_r (_REENT, &f, fmt, ap);
- if (ret >= 0)
- {
- *f._p = 0;
- *strp = f._bf._base;
- }
- return ret;
+ return _vasprintf_r (_REENT, strp, fmt, ap);
}
#endif /* !_REENT_ONLY */
@@ -60,7 +43,7 @@ int
_DEFUN(_vasprintf_r, (ptr, strp, fmt, ap),
struct _reent *ptr _AND
char **strp _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
int ret;
diff --git a/newlib/libc/stdio/vdiprintf.c b/newlib/libc/stdio/vdiprintf.c
new file mode 100644
index 000000000..fcb998b24
--- /dev/null
+++ b/newlib/libc/stdio/vdiprintf.c
@@ -0,0 +1,42 @@
+/* Copyright 2005, 2007 Shaun Jackman
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+int
+_DEFUN(_vdiprintf_r, (ptr, fd, format, ap),
+ struct _reent *ptr _AND
+ int fd _AND
+ const char *format _AND
+ va_list ap)
+{
+ char *p;
+ int n;
+
+ _REENT_SMALL_CHECK_INIT (ptr);
+ n = _vasiprintf_r (ptr, &p, format, ap);
+ if (n == -1) return -1;
+ n = _write_r (ptr, fd, p, n);
+ _free_r (ptr, p);
+ return n;
+}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(vdiprintf, (fd, format, ap),
+ int fd _AND
+ const char *format _AND
+ va_list ap)
+{
+ return _vdiprintf_r (_REENT, fd, format, ap);
+}
+
+#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c
index acd193a13..617d9db1f 100644
--- a/newlib/libc/stdio/vdprintf.c
+++ b/newlib/libc/stdio/vdprintf.c
@@ -1,4 +1,4 @@
-/* Copyright 2005 Shaun Jackman
+/* Copyright 2005, 2007 Shaun Jackman
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
@@ -8,39 +8,36 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
int
-_DEFUN (_vdprintf_r, (ptr, fd, format, ap),
- struct _reent *ptr _AND
- int fd _AND
- _CONST char *format _AND
- va_list ap)
+_DEFUN(_vdprintf_r, (ptr, fd, format, ap),
+ struct _reent *ptr _AND
+ int fd _AND
+ const char *format _AND
+ va_list ap)
{
- char *p;
- int n;
- _REENT_SMALL_CHECK_INIT (ptr);
- n = _vasprintf_r (ptr, &p, format, ap);
- if (n == -1) return -1;
- n = _write_r (ptr, fd, p, n);
- _free_r (ptr, p);
- return n;
+ char *p;
+ int n;
+
+ _REENT_SMALL_CHECK_INIT (ptr);
+ n = _vasprintf_r (ptr, &p, format, ap);
+ if (n == -1)
+ return -1;
+ n = _write_r (ptr, fd, p, n);
+ _free_r (ptr, p);
+ return n;
}
#ifndef _REENT_ONLY
-int
-_DEFUN (vdprintf, (fd, format, ap),
- int fd _AND
- _CONST char *format _AND
- va_list ap)
+int
+_DEFUN(vdprintf, (fd, format, ap),
+ int fd _AND
+ const char *format _AND
+ va_list ap)
{
- _REENT_SMALL_CHECK_INIT (_REENT);
- return _vdprintf_r (_REENT, fd, format, ap);
+ return _vdprintf_r (_REENT, fd, format, ap);
}
#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/vsiprintf.c b/newlib/libc/stdio/vsiprintf.c
index c9d263803..d1a4a7378 100644
--- a/newlib/libc/stdio/vsiprintf.c
+++ b/newlib/libc/stdio/vsiprintf.c
@@ -24,30 +24,17 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <reent.h>
#include <stdio.h>
#include <limits.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#ifndef _REENT_ONLY
+#ifndef _REENT_ONLY
int
_DEFUN(vsiprintf, (str, fmt, ap),
char *str _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
- int ret;
- FILE f;
-
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._w = INT_MAX;
- f._file = -1; /* No file. */
- ret = _vfiprintf_r (_REENT, &f, fmt, ap);
- *f._p = 0;
- return ret;
+ return _vsiprintf_r (_REENT, str, fmt, ap);
}
#endif /* !_REENT_ONLY */
@@ -56,7 +43,7 @@ int
_DEFUN(_vsiprintf_r, (ptr, str, fmt, ap),
struct _reent *ptr _AND
char *str _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
int ret;
@@ -70,4 +57,3 @@ _DEFUN(_vsiprintf_r, (ptr, str, fmt, ap),
*f._p = 0;
return ret;
}
-
diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c
index 68f0c7f02..5e40fdcf8 100644
--- a/newlib/libc/stdio/vsniprintf.c
+++ b/newlib/libc/stdio/vsniprintf.c
@@ -63,11 +63,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <reent.h>
#include <stdio.h>
#include <limits.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <errno.h>
#ifndef _REENT_ONLY
@@ -76,28 +72,10 @@ int
_DEFUN(vsniprintf, (str, size, fmt, ap),
char *str _AND
size_t size _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
- int ret;
- FILE f;
- struct _reent *ptr = _REENT;
-
- if (size > INT_MAX)
- {
- ptr->_errno = EOVERFLOW;
- return EOF;
- }
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._w = (size > 0 ? size - 1 : 0);
- f._file = -1; /* No file. */
- ret = _vfiprintf_r (ptr, &f, fmt, ap);
- if (ret < EOF)
- ptr->_errno = EOVERFLOW;
- if (size > 0)
- *f._p = 0;
- return ret;
+ return _vsniprintf_r (_REENT, str, size, fmt, ap);
}
#endif /* !_REENT_ONLY */
@@ -107,7 +85,7 @@ _DEFUN(_vsniprintf_r, (ptr, str, size, fmt, ap),
struct _reent *ptr _AND
char *str _AND
size_t size _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
int ret;
diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c
index e935b49c1..6a26f8bea 100644
--- a/newlib/libc/stdio/vsnprintf.c
+++ b/newlib/libc/stdio/vsnprintf.c
@@ -24,11 +24,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <reent.h>
#include <stdio.h>
#include <limits.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <errno.h>
#ifndef _REENT_ONLY
@@ -37,28 +33,10 @@ int
_DEFUN(vsnprintf, (str, size, fmt, ap),
char *str _AND
size_t size _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
- int ret;
- FILE f;
- struct _reent *ptr = _REENT;
-
- if (size > INT_MAX)
- {
- ptr->_errno = EOVERFLOW;
- return EOF;
- }
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._w = (size > 0 ? size - 1 : 0);
- f._file = -1; /* No file. */
- ret = _vfprintf_r (ptr, &f, fmt, ap);
- if (ret < EOF)
- ptr->_errno = EOVERFLOW;
- if (size > 0)
- *f._p = 0;
- return ret;
+ return _vsnprintf_r (_REENT, str, size, fmt, ap);
}
#endif /* !_REENT_ONLY */
@@ -68,7 +46,7 @@ _DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap),
struct _reent *ptr _AND
char *str _AND
size_t size _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
int ret;
diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c
index daf4605c1..5c2600411 100644
--- a/newlib/libc/stdio/vsprintf.c
+++ b/newlib/libc/stdio/vsprintf.c
@@ -24,30 +24,17 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <reent.h>
#include <stdio.h>
#include <limits.h>
-#ifdef _HAVE_STDC
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#ifndef _REENT_ONLY
+#ifndef _REENT_ONLY
int
_DEFUN(vsprintf, (str, fmt, ap),
char *str _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
- int ret;
- FILE f;
-
- f._flags = __SWR | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._w = INT_MAX;
- f._file = -1; /* No file. */
- ret = _vfprintf_r (_REENT, &f, fmt, ap);
- *f._p = 0;
- return ret;
+ return _vsprintf_r (_REENT, str, fmt, ap);
}
#endif /* !_REENT_ONLY */
@@ -56,7 +43,7 @@ int
_DEFUN(_vsprintf_r, (ptr, str, fmt, ap),
struct _reent *ptr _AND
char *str _AND
- _CONST char *fmt _AND
+ const char *fmt _AND
va_list ap)
{
int ret;
@@ -70,4 +57,3 @@ _DEFUN(_vsprintf_r, (ptr, str, fmt, ap),
*f._p = 0;
return ret;
}
-