v{fs}printf/v{fs}wprintf: create external output helpers

So far, the printf family of functions has two output helper functions
called __sprint_r and __sfputs_r.  Both are called from all variants of
vfprintf as well as vfwprintf.  There are also analogue helper functions
 for the string-creating functions vsprintf/vswprintf called __ssprint_r
and __ssputs_r.

However, the helpers are built once when building vfprintf/vsprintf with
the INTEGER_ONLY flag, and then they are part of the vfiprintf.c and
vsiprintf.c files.

The problem is this:

Even if a process only calls vfwprintf or the non-INTEGER_ONLY vfprintf
it will always have to include the INTEGER_ONLY vfiprintf. Otherwise the
helper functions are undefined.  Analogue for the string-creating
functions.

That's a useless waste of space by including one (or two) big, unused
function, if newlib is linked in statically.

Create new files to define the printf output helpers separately and
split them into byte-oriented and wide-char-oriented functions.  This
allows to link only the required functions.

Also, simplify the string output helpers and fix a potential (but
unlikely) buffer overflow in __ssprint_r.

Fixes: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Fixes: 6121968b19 ("* libc/include/stdio.h (__VALIST): Guard against multiple definition.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-11-16 20:34:55 +01:00
parent 7e4840bc45
commit 61ccd3f94f
12 changed files with 469 additions and 267 deletions

View File

@ -237,7 +237,15 @@ check_PROGRAMS =
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/viscanf.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/vsiprintf.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/vsiscanf.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/vsniprintf.c
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/vsniprintf.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/sfputs_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/sfputws_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/sprint_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/swprint_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/ssputs_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/ssputws_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/ssprint_r.c \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/sswprint_r.c
@HAVE_STDIO_DIR_TRUE@am__append_12 = libc/stdio/clearerr.c \
@HAVE_STDIO_DIR_TRUE@ libc/stdio/fclose.c libc/stdio/fdopen.c \
@ -1172,7 +1180,15 @@ am__objects_5 = libc/stdlib/libc_a-rpmatch.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-viscanf.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-vsiprintf.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-vsiscanf.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-vsniprintf.$(OBJEXT)
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-vsniprintf.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-sfputs_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-sfputws_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-sprint_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-swprint_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-ssputs_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-ssputws_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-ssprint_r.$(OBJEXT) \
@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-sswprint_r.$(OBJEXT)
@ELIX_LEVEL_1_FALSE@@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_12 = libc/stdio/libc_a-asiprintf.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-vasiprintf.$(OBJEXT)
@ELIX_LEVEL_1_FALSE@@HAVE_STDIO_DIR_TRUE@am__objects_13 = libc/stdio/libc_a-asprintf.$(OBJEXT) \
@ -3907,6 +3923,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
shared_machine_dir = @shared_machine_dir@
sharedstatedir = @sharedstatedir@
@ -5949,6 +5966,22 @@ libc/stdio/libc_a-vsiscanf.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-vsniprintf.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-sfputs_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-sfputws_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-sprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-swprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-ssputs_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-ssputws_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-ssprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-sswprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-clearerr.$(OBJEXT): libc/stdio/$(am__dirstamp) \
libc/stdio/$(DEPDIR)/$(am__dirstamp)
libc/stdio/libc_a-fclose.$(OBJEXT): libc/stdio/$(am__dirstamp) \
@ -13417,12 +13450,19 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-setbuffer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-setlinebuf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-setvbuf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-siprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-siscanf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sniprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-snprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sprint_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sscanf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-stdio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-stdio_ext.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-svfiprintf.Po@am__quote@
@ -13433,6 +13473,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-svfscanf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-svfwprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-svfwscanf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-swprint_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-swprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-swscanf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libc/stdio/$(DEPDIR)/libc_a-tmpfile.Po@am__quote@
@ -23963,6 +24004,118 @@ libc/stdio/libc_a-vsniprintf.obj: libc/stdio/vsniprintf.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-vsniprintf.obj `if test -f 'libc/stdio/vsniprintf.c'; then $(CYGPATH_W) 'libc/stdio/vsniprintf.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/vsniprintf.c'; fi`
libc/stdio/libc_a-sfputs_r.o: libc/stdio/sfputs_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sfputs_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Tpo -c -o libc/stdio/libc_a-sfputs_r.o `test -f 'libc/stdio/sfputs_r.c' || echo '$(srcdir)/'`libc/stdio/sfputs_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sfputs_r.c' object='libc/stdio/libc_a-sfputs_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sfputs_r.o `test -f 'libc/stdio/sfputs_r.c' || echo '$(srcdir)/'`libc/stdio/sfputs_r.c
libc/stdio/libc_a-sfputs_r.obj: libc/stdio/sfputs_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sfputs_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Tpo -c -o libc/stdio/libc_a-sfputs_r.obj `if test -f 'libc/stdio/sfputs_r.c'; then $(CYGPATH_W) 'libc/stdio/sfputs_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sfputs_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sfputs_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sfputs_r.c' object='libc/stdio/libc_a-sfputs_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sfputs_r.obj `if test -f 'libc/stdio/sfputs_r.c'; then $(CYGPATH_W) 'libc/stdio/sfputs_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sfputs_r.c'; fi`
libc/stdio/libc_a-sfputws_r.o: libc/stdio/sfputws_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sfputws_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Tpo -c -o libc/stdio/libc_a-sfputws_r.o `test -f 'libc/stdio/sfputws_r.c' || echo '$(srcdir)/'`libc/stdio/sfputws_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sfputws_r.c' object='libc/stdio/libc_a-sfputws_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sfputws_r.o `test -f 'libc/stdio/sfputws_r.c' || echo '$(srcdir)/'`libc/stdio/sfputws_r.c
libc/stdio/libc_a-sfputws_r.obj: libc/stdio/sfputws_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sfputws_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Tpo -c -o libc/stdio/libc_a-sfputws_r.obj `if test -f 'libc/stdio/sfputws_r.c'; then $(CYGPATH_W) 'libc/stdio/sfputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sfputws_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sfputws_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sfputws_r.c' object='libc/stdio/libc_a-sfputws_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sfputws_r.obj `if test -f 'libc/stdio/sfputws_r.c'; then $(CYGPATH_W) 'libc/stdio/sfputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sfputws_r.c'; fi`
libc/stdio/libc_a-sprint_r.o: libc/stdio/sprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sprint_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sprint_r.Tpo -c -o libc/stdio/libc_a-sprint_r.o `test -f 'libc/stdio/sprint_r.c' || echo '$(srcdir)/'`libc/stdio/sprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sprint_r.c' object='libc/stdio/libc_a-sprint_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sprint_r.o `test -f 'libc/stdio/sprint_r.c' || echo '$(srcdir)/'`libc/stdio/sprint_r.c
libc/stdio/libc_a-sprint_r.obj: libc/stdio/sprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sprint_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sprint_r.Tpo -c -o libc/stdio/libc_a-sprint_r.obj `if test -f 'libc/stdio/sprint_r.c'; then $(CYGPATH_W) 'libc/stdio/sprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sprint_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sprint_r.c' object='libc/stdio/libc_a-sprint_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sprint_r.obj `if test -f 'libc/stdio/sprint_r.c'; then $(CYGPATH_W) 'libc/stdio/sprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sprint_r.c'; fi`
libc/stdio/libc_a-swprint_r.o: libc/stdio/swprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-swprint_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-swprint_r.Tpo -c -o libc/stdio/libc_a-swprint_r.o `test -f 'libc/stdio/swprint_r.c' || echo '$(srcdir)/'`libc/stdio/swprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-swprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-swprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/swprint_r.c' object='libc/stdio/libc_a-swprint_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-swprint_r.o `test -f 'libc/stdio/swprint_r.c' || echo '$(srcdir)/'`libc/stdio/swprint_r.c
libc/stdio/libc_a-swprint_r.obj: libc/stdio/swprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-swprint_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-swprint_r.Tpo -c -o libc/stdio/libc_a-swprint_r.obj `if test -f 'libc/stdio/swprint_r.c'; then $(CYGPATH_W) 'libc/stdio/swprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/swprint_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-swprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-swprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/swprint_r.c' object='libc/stdio/libc_a-swprint_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-swprint_r.obj `if test -f 'libc/stdio/swprint_r.c'; then $(CYGPATH_W) 'libc/stdio/swprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/swprint_r.c'; fi`
libc/stdio/libc_a-ssputs_r.o: libc/stdio/ssputs_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputs_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Tpo -c -o libc/stdio/libc_a-ssputs_r.o `test -f 'libc/stdio/ssputs_r.c' || echo '$(srcdir)/'`libc/stdio/ssputs_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputs_r.c' object='libc/stdio/libc_a-ssputs_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputs_r.o `test -f 'libc/stdio/ssputs_r.c' || echo '$(srcdir)/'`libc/stdio/ssputs_r.c
libc/stdio/libc_a-ssputs_r.obj: libc/stdio/ssputs_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputs_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Tpo -c -o libc/stdio/libc_a-ssputs_r.obj `if test -f 'libc/stdio/ssputs_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputs_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputs_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputs_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputs_r.c' object='libc/stdio/libc_a-ssputs_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputs_r.obj `if test -f 'libc/stdio/ssputs_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputs_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputs_r.c'; fi`
libc/stdio/libc_a-ssputws_r.o: libc/stdio/ssputws_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputws_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo -c -o libc/stdio/libc_a-ssputws_r.o `test -f 'libc/stdio/ssputws_r.c' || echo '$(srcdir)/'`libc/stdio/ssputws_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputws_r.c' object='libc/stdio/libc_a-ssputws_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputws_r.o `test -f 'libc/stdio/ssputws_r.c' || echo '$(srcdir)/'`libc/stdio/ssputws_r.c
libc/stdio/libc_a-ssputws_r.obj: libc/stdio/ssputws_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputws_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo -c -o libc/stdio/libc_a-ssputws_r.obj `if test -f 'libc/stdio/ssputws_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputws_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputws_r.c' object='libc/stdio/libc_a-ssputws_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputws_r.obj `if test -f 'libc/stdio/ssputws_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputws_r.c'; fi`
libc/stdio/libc_a-ssprint_r.o: libc/stdio/ssprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssprint_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Tpo -c -o libc/stdio/libc_a-ssprint_r.o `test -f 'libc/stdio/ssprint_r.c' || echo '$(srcdir)/'`libc/stdio/ssprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssprint_r.c' object='libc/stdio/libc_a-ssprint_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssprint_r.o `test -f 'libc/stdio/ssprint_r.c' || echo '$(srcdir)/'`libc/stdio/ssprint_r.c
libc/stdio/libc_a-ssprint_r.obj: libc/stdio/ssprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssprint_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Tpo -c -o libc/stdio/libc_a-ssprint_r.obj `if test -f 'libc/stdio/ssprint_r.c'; then $(CYGPATH_W) 'libc/stdio/ssprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssprint_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssprint_r.c' object='libc/stdio/libc_a-ssprint_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssprint_r.obj `if test -f 'libc/stdio/ssprint_r.c'; then $(CYGPATH_W) 'libc/stdio/ssprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssprint_r.c'; fi`
libc/stdio/libc_a-sswprint_r.o: libc/stdio/sswprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sswprint_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Tpo -c -o libc/stdio/libc_a-sswprint_r.o `test -f 'libc/stdio/sswprint_r.c' || echo '$(srcdir)/'`libc/stdio/sswprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sswprint_r.c' object='libc/stdio/libc_a-sswprint_r.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sswprint_r.o `test -f 'libc/stdio/sswprint_r.c' || echo '$(srcdir)/'`libc/stdio/sswprint_r.c
libc/stdio/libc_a-sswprint_r.obj: libc/stdio/sswprint_r.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-sswprint_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Tpo -c -o libc/stdio/libc_a-sswprint_r.obj `if test -f 'libc/stdio/sswprint_r.c'; then $(CYGPATH_W) 'libc/stdio/sswprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sswprint_r.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-sswprint_r.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/sswprint_r.c' object='libc/stdio/libc_a-sswprint_r.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sswprint_r.obj `if test -f 'libc/stdio/sswprint_r.c'; then $(CYGPATH_W) 'libc/stdio/sswprint_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sswprint_r.c'; fi`
libc/stdio/libc_a-clearerr.o: libc/stdio/clearerr.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-clearerr.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-clearerr.Tpo -c -o libc/stdio/libc_a-clearerr.o `test -f 'libc/stdio/clearerr.c' || echo '$(srcdir)/'`libc/stdio/clearerr.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-clearerr.Tpo libc/stdio/$(DEPDIR)/libc_a-clearerr.Po

View File

@ -33,7 +33,15 @@ libc_a_SOURCES += \
%D%/viscanf.c \
%D%/vsiprintf.c \
%D%/vsiscanf.c \
%D%/vsniprintf.c
%D%/vsniprintf.c \
%D%/sfputs_r.c \
%D%/sfputws_r.c \
%D%/sprint_r.c \
%D%/swprint_r.c \
%D%/ssputs_r.c \
%D%/ssputws_r.c \
%D%/ssprint_r.c \
%D%/sswprint_r.c
endif
libc_a_SOURCES += \

View File

@ -0,0 +1,23 @@
#include <newlib.h>
#ifndef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
int
__sfputs_r (struct _reent *ptr,
FILE *fp,
const char *buf,
size_t len)
{
register int i;
for (i = 0; i < len; i++) {
if (_fputc_r (ptr, buf[i], fp) == EOF)
return -1;
}
return (0);
}
#endif

View File

@ -0,0 +1,24 @@
#include <newlib.h>
#ifndef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
#include <wchar.h>
int
__sfputws_r (struct _reent *ptr,
FILE *fp,
const wchar_t *buf,
size_t len)
{
register int i;
for (i = 0; i < len; i++) {
if (_fputwc_r (ptr, buf[i], fp) == WEOF)
return -1;
}
return (0);
}
#endif

View File

@ -0,0 +1,30 @@
#include <newlib.h>
#ifdef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
#include "fvwrite.h"
/*
* Flush out all the vectors defined by the given uio,
* then reset it so that it can be reused.
*/
int
__sprint_r (struct _reent *ptr,
FILE *fp,
register struct __suio *uio)
{
register int err = 0;
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
return (0);
}
err = __sfvwrite_r(ptr, fp, uio);
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return (err);
}
#endif

View File

@ -0,0 +1,36 @@
#include <newlib.h>
#ifdef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
#include "fvwrite.h"
extern int __ssputs_r (struct _reent *ptr, FILE *fp, const char *buf,
size_t len);
int
__ssprint_r (struct _reent *ptr,
FILE *fp,
register struct __suio *uio)
{
register struct __siov *iov = uio->uio_iov;
register size_t len;
int ret = 0;
while (uio->uio_resid > 0 && uio->uio_iovcnt-- > 0) {
if ((len = iov->iov_len) > 0) {
if (__ssputs_r (ptr, fp, iov->iov_base, len) == EOF) {
ret = EOF;
break;
}
uio->uio_resid -= len; /* pretend we copied all */
}
iov++;
}
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return ret;
}
#endif

View File

@ -0,0 +1,69 @@
#include <newlib.h>
#include <reent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int
__ssputs_r (struct _reent *ptr,
FILE *fp,
const char *buf,
size_t len)
{
register int w;
w = fp->_w;
if (len >= w && fp->_flags & (__SMBF | __SOPT)) {
/* must be asprintf family */
unsigned char *str;
int curpos = (fp->_p - fp->_bf._base);
/* Choose a geometric growth factor to avoid
* quadratic realloc behavior, but use a rate less
* than (1+sqrt(5))/2 to accomodate malloc
* overhead. asprintf EXPECTS us to overallocate, so
* that it can add a trailing \0 without
* reallocating. The new allocation should thus be
* max(prev_size*1.5, curpos+len+1). */
int newsize = fp->_bf._size * 3 / 2;
if (newsize < curpos + len + 1)
newsize = curpos + len + 1;
if (fp->_flags & __SOPT)
{
/* asnprintf leaves original buffer alone. */
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
goto err;
memcpy (str, fp->_bf._base, curpos);
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF;
}
else
{
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base,
newsize);
if (!str) {
/* Free unneeded buffer. */
_free_r (ptr, fp->_bf._base);
goto err;
}
}
fp->_bf._base = str;
fp->_p = str + curpos;
fp->_bf._size = newsize;
w = len;
fp->_w = newsize - curpos;
}
if (len < w)
w = len;
memmove ((void *) fp->_p, (void *) buf, (size_t) (w));
fp->_w -= w;
fp->_p += w;
return 0;
err:
_REENT_ERRNO(ptr) = ENOMEM;
fp->_flags |= __SERR;
return EOF;
}

View File

@ -0,0 +1,21 @@
#include <newlib.h>
#ifndef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
#include <wchar.h>
extern int __ssputs_r (struct _reent *ptr, FILE *fp, const char *buf,
size_t len);
int
__ssputws_r (struct _reent *ptr,
FILE *fp,
const wchar_t *buf,
size_t len)
{
return __ssputs_r (ptr, fp, (const char *) buf, len * sizeof (wchar_t));
}
#endif

View File

@ -0,0 +1,38 @@
#include <newlib.h>
#ifdef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
#include <wchar.h>
#include "fvwrite.h"
extern int __ssputs_r (struct _reent *ptr, FILE *fp, const char *buf,
size_t len);
int
__sswprint_r (struct _reent *ptr,
FILE *fp,
register struct __suio *uio)
{
register struct __siov *iov = uio->uio_iov;
register size_t len;
int ret = 0;
while (uio->uio_resid > 0 && uio->uio_iovcnt-- > 0) {
if ((len = iov->iov_len) > 0) {
if (__ssputs_r (ptr, fp, iov->iov_base,
len * sizeof (wchar_t)) == EOF) {
ret = -1;
break;
}
uio->uio_resid -= len; /* pretend we copied all */
}
iov++;
}
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return ret;
}
#endif

View File

@ -0,0 +1,46 @@
#include <newlib.h>
#ifdef _FVWRITE_IN_STREAMIO
#include <reent.h>
#include <stdio.h>
#include <wchar.h>
#include "fvwrite.h"
/*
* Flush out all the vectors defined by the given uio,
* then reset it so that it can be reused.
*/
int
__swprint_r (struct _reent *ptr,
FILE *fp,
register struct __suio *uio)
{
register int err = 0;
struct __siov *iov;
wchar_t *p;
int i, len;
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
return (0);
}
iov = uio->uio_iov;
for (; uio->uio_resid != 0;
uio->uio_resid -= len, iov++) {
p = (wchar_t *) iov->iov_base;
len = iov->iov_len;
for (i = 0; i < len; i++) {
if (_fputwc_r (ptr, p[i], fp) == WEOF) {
err = -1;
goto out;
}
}
}
out:
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return (err);
}
#endif

View File

@ -174,270 +174,24 @@ static char *rcsid = "$Id$";
#endif
#ifdef STRING_ONLY
# ifdef _FVWRITE_IN_STREAMIO
# define __SPRINT __ssprint_r
int __ssprint_r (struct _reent *, FILE *, register struct __suio *);
# else
# define __SPRINT __ssputs_r
int __ssputs_r (struct _reent *, FILE *, const char *, size_t);
# endif
#else
# ifdef _FVWRITE_IN_STREAMIO
# define __SPRINT __sprint_r
# else
# define __SPRINT __sfputs_r
# endif
#endif
/* The __sprint_r/__ssprint_r functions are shared between all versions of
vfprintf and vfwprintf. They must only be defined once, which we do in
the INTEGER_ONLY versions here. */
#ifdef STRING_ONLY
#ifdef INTEGER_ONLY
#ifndef _FVWRITE_IN_STREAMIO
int
__ssputs_r (struct _reent *ptr,
FILE *fp,
const char *buf,
size_t len)
{
register int w;
w = fp->_w;
if (len >= w && fp->_flags & (__SMBF | __SOPT)) {
/* must be asprintf family */
unsigned char *str;
int curpos = (fp->_p - fp->_bf._base);
/* Choose a geometric growth factor to avoid
* quadratic realloc behavior, but use a rate less
* than (1+sqrt(5))/2 to accomodate malloc
* overhead. asprintf EXPECTS us to overallocate, so
* that it can add a trailing \0 without
* reallocating. The new allocation should thus be
* max(prev_size*1.5, curpos+len+1). */
int newsize = fp->_bf._size * 3 / 2;
if (newsize < curpos + len + 1)
newsize = curpos + len + 1;
if (fp->_flags & __SOPT)
{
/* asnprintf leaves original buffer alone. */
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF;
}
else
{
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base,
newsize);
if (!str) {
/* Free unneeded buffer. */
_free_r (ptr, fp->_bf._base);
/* Ensure correct errno, even if free
* changed it. */
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}
fp->_bf._base = str;
fp->_p = str + curpos;
fp->_bf._size = newsize;
w = len;
fp->_w = newsize - curpos;
}
if (len < w)
w = len;
(void)memmove ((void *) fp->_p, (void *) buf, (size_t) (w));
fp->_w -= w;
fp->_p += w;
return 0;
err:
fp->_flags |= __SERR;
return EOF;
}
#endif
int
__ssprint_r (struct _reent *ptr,
FILE *fp,
register struct __suio *uio)
{
register size_t len;
register int w;
register struct __siov *iov;
register const char *p = NULL;
iov = uio->uio_iov;
len = 0;
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
return (0);
}
do {
while (len == 0) {
p = iov->iov_base;
len = iov->iov_len;
iov++;
}
w = fp->_w;
if (len >= w && fp->_flags & (__SMBF | __SOPT)) {
/* must be asprintf family */
unsigned char *str;
int curpos = (fp->_p - fp->_bf._base);
/* Choose a geometric growth factor to avoid
* quadratic realloc behavior, but use a rate less
* than (1+sqrt(5))/2 to accomodate malloc
* overhead. asprintf EXPECTS us to overallocate, so
* that it can add a trailing \0 without
* reallocating. The new allocation should thus be
* max(prev_size*1.5, curpos+len+1). */
int newsize = fp->_bf._size * 3 / 2;
if (newsize < curpos + len + 1)
newsize = curpos + len + 1;
if (fp->_flags & __SOPT)
{
/* asnprintf leaves original buffer alone. */
str = (unsigned char *)_malloc_r (ptr, newsize);
if (!str)
{
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
memcpy (str, fp->_bf._base, curpos);
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF;
}
else
{
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base,
newsize);
if (!str) {
/* Free unneeded buffer. */
_free_r (ptr, fp->_bf._base);
/* Ensure correct errno, even if free
* changed it. */
_REENT_ERRNO(ptr) = ENOMEM;
goto err;
}
}
fp->_bf._base = str;
fp->_p = str + curpos;
fp->_bf._size = newsize;
w = len;
fp->_w = newsize - curpos;
}
if (len < w)
w = len;
(void)memmove ((void *) fp->_p, (void *) p, (size_t) (w));
fp->_w -= w;
fp->_p += w;
w = len; /* pretend we copied all */
p += w;
len -= w;
} while ((uio->uio_resid -= w) != 0);
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return 0;
err:
fp->_flags |= __SERR;
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return EOF;
}
#else /* !INTEGER_ONLY */
#ifndef _FVWRITE_IN_STREAMIO
int __ssputs_r (struct _reent *, FILE *, const char *, size_t);
#endif
int __ssprint_r (struct _reent *, FILE *, register struct __suio *);
#endif /* !INTEGER_ONLY */
#else /* !STRING_ONLY */
#ifdef INTEGER_ONLY
#ifndef _FVWRITE_IN_STREAMIO
int
__sfputs_r (struct _reent *ptr,
FILE *fp,
const char *buf,
size_t len)
{
register int i;
#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
if (fp->_flags2 & __SWID) {
wchar_t *p;
p = (wchar_t *) buf;
for (i = 0; i < (len / sizeof (wchar_t)); i++) {
if (_fputwc_r (ptr, p[i], fp) == WEOF)
return -1;
}
} else {
#else
{
#endif
for (i = 0; i < len; i++) {
if (_fputc_r (ptr, buf[i], fp) == EOF)
return -1;
}
}
return (0);
}
#endif
/*
* Flush out all the vectors defined by the given uio,
* then reset it so that it can be reused.
*/
int
__sprint_r (struct _reent *ptr,
FILE *fp,
register struct __suio *uio)
{
register int err = 0;
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
return (0);
}
#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
if (fp->_flags2 & __SWID) {
struct __siov *iov;
wchar_t *p;
int i, len;
iov = uio->uio_iov;
for (; uio->uio_resid != 0;
uio->uio_resid -= len * sizeof (wchar_t), iov++) {
p = (wchar_t *) iov->iov_base;
len = iov->iov_len / sizeof (wchar_t);
for (i = 0; i < len; i++) {
if (_fputwc_r (ptr, p[i], fp) == WEOF) {
err = -1;
goto out;
}
}
}
} else
#endif
err = __sfvwrite_r(ptr, fp, uio);
out:
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return (err);
}
#else /* !INTEGER_ONLY */
#ifndef _FVWRITE_IN_STREAMIO
int __sfputs_r (struct _reent *, FILE *, const char *buf, size_t);
#endif
int __sprint_r (struct _reent *, FILE *, register struct __suio *);
#endif /* !INTEGER_ONLY */
# ifdef _FVWRITE_IN_STREAMIO
# define __SPRINT __sprint_r
int __sprint_r (struct _reent *, FILE *, register struct __suio *);
# else
# define __SPRINT __sfputs_r
int __sfputs_r (struct _reent *, FILE *, const char *buf, size_t);
# endif
#ifdef _UNBUF_STREAM_OPT
/*

View File

@ -153,18 +153,18 @@ int _VFWPRINTF_R (struct _reent *, FILE *, const wchar_t *, va_list);
/* Defined in vfprintf.c. */
#ifdef _FVWRITE_IN_STREAMIO
# ifdef STRING_ONLY
# define __SPRINT __ssprint_r
# define __SPRINT __sswprint_r
# else
# define __SPRINT __sprint_r
# define __SPRINT __swprint_r
# endif
int __SPRINT (struct _reent *, FILE *, register struct __suio *);
#else
# ifdef STRING_ONLY
# define __SPRINT __ssputs_r
# define __SPRINT __ssputws_r
# else
# define __SPRINT __sfputs_r
# define __SPRINT __sfputws_r
# endif
int __SPRINT (struct _reent *, FILE *, const char *, size_t);
int __SPRINT (struct _reent *, FILE *, const wchar_t *, size_t);
#endif
#ifndef STRING_ONLY
#ifdef _UNBUF_STREAM_OPT
@ -479,8 +479,8 @@ _VFWPRINTF_R (struct _reent *data,
#ifdef _FVWRITE_IN_STREAMIO
#define PRINT(ptr, len) { \
iovp->iov_base = (char *) (ptr); \
iovp->iov_len = (len) * sizeof (wchar_t); \
uio.uio_resid += (len) * sizeof (wchar_t); \
iovp->iov_len = (len); \
uio.uio_resid += iovp->iov_len; \
iovp++; \
if (++uio.uio_iovcnt >= NIOV) { \
if (__SPRINT(data, fp, &uio)) \
@ -513,7 +513,7 @@ _VFWPRINTF_R (struct _reent *data,
}
#else
#define PRINT(ptr, len) { \
if (__SPRINT (data, fp, (const char *)(ptr), (len) * sizeof (wchar_t)) == EOF) \
if (__SPRINT (data, fp, (ptr), (len)) == EOF) \
goto error; \
}
#define PAD(howmany, with) { \