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:
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r--newlib/libc/stdio/Makefile.am37
-rw-r--r--newlib/libc/stdio/Makefile.in103
-rw-r--r--newlib/libc/stdio/asiprintf.c100
-rw-r--r--newlib/libc/stdio/clearerr.c5
-rw-r--r--newlib/libc/stdio/dprintf.c129
-rw-r--r--newlib/libc/stdio/fclose.c4
-rw-r--r--newlib/libc/stdio/feof.c4
-rw-r--r--newlib/libc/stdio/ferror.c2
-rw-r--r--newlib/libc/stdio/fflush.c16
-rw-r--r--newlib/libc/stdio/fgetc.c2
-rw-r--r--newlib/libc/stdio/fgetpos.c3
-rw-r--r--newlib/libc/stdio/fgets.c2
-rw-r--r--newlib/libc/stdio/fileno.c2
-rw-r--r--newlib/libc/stdio/findfp.c22
-rw-r--r--newlib/libc/stdio/fiprintf.c39
-rw-r--r--newlib/libc/stdio/fiscanf.c78
-rw-r--r--newlib/libc/stdio/fputc.c2
-rw-r--r--newlib/libc/stdio/fputs.c4
-rw-r--r--newlib/libc/stdio/fread.c20
-rw-r--r--newlib/libc/stdio/freopen.c69
-rw-r--r--newlib/libc/stdio/fseek.c13
-rw-r--r--newlib/libc/stdio/ftell.c8
-rw-r--r--newlib/libc/stdio/fwrite.c2
-rw-r--r--newlib/libc/stdio/getc.c3
-rw-r--r--newlib/libc/stdio/getchar.c2
-rw-r--r--newlib/libc/stdio/getdelim.c12
-rw-r--r--newlib/libc/stdio/getw.c7
-rw-r--r--newlib/libc/stdio/iprintf.c42
-rw-r--r--newlib/libc/stdio/iscanf.c78
-rw-r--r--newlib/libc/stdio/local.h11
-rw-r--r--newlib/libc/stdio/perror.c2
-rw-r--r--newlib/libc/stdio/printf.c4
-rw-r--r--newlib/libc/stdio/putc.c3
-rw-r--r--newlib/libc/stdio/putchar.c2
-rw-r--r--newlib/libc/stdio/puts.c2
-rw-r--r--newlib/libc/stdio/putw.c5
-rw-r--r--newlib/libc/stdio/refill.c10
-rw-r--r--newlib/libc/stdio/scanf.c4
-rw-r--r--newlib/libc/stdio/sccl.c127
-rw-r--r--newlib/libc/stdio/setvbuf.c4
-rw-r--r--newlib/libc/stdio/siprintf.c97
-rw-r--r--newlib/libc/stdio/siscanf.c195
-rw-r--r--newlib/libc/stdio/sniprintf.c103
-rw-r--r--newlib/libc/stdio/sprintf.c3
-rw-r--r--newlib/libc/stdio/sscanf.c10
-rw-r--r--newlib/libc/stdio/stdio.tex33
-rw-r--r--newlib/libc/stdio/ungetc.c6
-rw-r--r--newlib/libc/stdio/vasiprintf.c75
-rw-r--r--newlib/libc/stdio/vdprintf.c46
-rw-r--r--newlib/libc/stdio/vfprintf.c51
-rw-r--r--newlib/libc/stdio/vfscanf.c203
-rw-r--r--newlib/libc/stdio/viprintf.c163
-rw-r--r--newlib/libc/stdio/viscanf.c139
-rw-r--r--newlib/libc/stdio/vprintf.c4
-rw-r--r--newlib/libc/stdio/vscanf.c4
-rw-r--r--newlib/libc/stdio/vsiprintf.c73
-rw-r--r--newlib/libc/stdio/vsiscanf.c74
-rw-r--r--newlib/libc/stdio/vsniprintf.c115
-rw-r--r--newlib/libc/stdio/wbuf.c2
-rw-r--r--newlib/libc/stdio/wsetup.c8
60 files changed, 385 insertions, 2003 deletions
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am
index 1ae643f4d..37911efb9 100644
--- a/newlib/libc/stdio/Makefile.am
+++ b/newlib/libc/stdio/Makefile.am
@@ -6,7 +6,6 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = \
clearerr.c \
- dprintf.c \
fclose.c \
fdopen.c \
feof.c \
@@ -26,7 +25,6 @@ GENERAL_SOURCES = \
fread.c \
freopen.c \
fscanf.c \
- fiscanf.c \
fseek.c \
fsetpos.c \
ftell.c \
@@ -41,7 +39,6 @@ GENERAL_SOURCES = \
getline.c \
gets.c \
iprintf.c \
- iscanf.c \
makebuf.c \
perror.c \
printf.c \
@@ -56,14 +53,11 @@ GENERAL_SOURCES = \
rewind.c \
rget.c \
scanf.c \
- sccl.c \
setbuf.c \
setbuffer.c \
setlinebuf.c \
setvbuf.c \
siprintf.c \
- siscanf.c \
- sniprintf.c \
snprintf.c \
sprintf.c \
sscanf.c \
@@ -71,15 +65,10 @@ GENERAL_SOURCES = \
tmpfile.c \
tmpnam.c \
ungetc.c \
- vdprintf.c \
- viprintf.c \
- viscanf.c \
+ vfscanf.c \
vprintf.c \
vscanf.c \
- vsiprintf.c \
- vsiscanf.c \
vsnprintf.c \
- vsniprintf.c \
vsprintf.c \
vsscanf.c \
wbuf.c \
@@ -90,7 +79,6 @@ if ELIX_LEVEL_1
LIB_OBJS =
else
LIB_OBJS = \
- asiprintf.$(oext) \
asprintf.$(oext) \
fcloseall.$(oext) \
fseeko.$(oext) \
@@ -98,11 +86,10 @@ LIB_OBJS = \
getw.$(oext) \
mktemp.$(oext) \
putw.$(oext) \
- vasiprintf.$(oext) \
vasprintf.$(oext)
endif
-LIBADD_OBJS = vfiprintf.$(oext) vfprintf.$(oext) vfscanf.$(oext) vfiscanf.$(oext)
+LIBADD_OBJS = vfiprintf.$(oext) vfprintf.$(oext)
libstdio_la_LDFLAGS = -Xcompiler -nostdlib
@@ -133,15 +120,8 @@ vfprintf.$(oext): vfprintf.c
vfiprintf.$(oext): vfprintf.c
$(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@
-vfscanf.$(oext): vfscanf.c
- $(LIB_COMPILE) -c $(srcdir)/vfscanf.c
-
-vfiscanf.$(oext): vfscanf.c
- $(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfscanf.c -o $@
-
CHEWOUT_FILES = \
clearerr.def \
- dprintf.def \
fclose.def \
fcloseall.def \
fdopen.def \
@@ -170,6 +150,7 @@ CHEWOUT_FILES = \
getline.def \
gets.def \
getw.def \
+ iprintf.def \
mktemp.def \
perror.def \
putc.def \
@@ -186,15 +167,12 @@ CHEWOUT_FILES = \
setlinebuf.def \
setvbuf.def \
siprintf.def \
- siscanf.def \
sprintf.def \
sscanf.def \
tmpfile.def \
tmpnam.def \
vfprintf.def \
- vfscanf.def \
- viprintf.def \
- viscanf.def
+ vfscanf.def
SUFFIXES = .def
@@ -224,7 +202,6 @@ ftell.$(oext): local.h
fvwrite.$(oext): local.h fvwrite.h
fwalk.$(oext): local.h
fwrite.$(oext): local.h fvwrite.h
-iscanf.$(oext): local.h
makebuf.$(oext): local.h
puts.$(oext): fvwrite.h
refill.$(oext): local.h
@@ -232,20 +209,14 @@ scanf.$(oext): local.h
setbuf.$(oext): local.h
setvbuf.$(oext): local.h
siprintf.$(oext): local.h
-sniprintf.$(oext): local.h
sprintf.$(oext): local.h
-siscanf.$(oext): local.h
sscanf.$(oext): local.h
stdio.$(oext): local.h
ungetc.$(oext): local.h
vfiprintf.$(oext): local.h
vfprintf.$(oext): local.h
-vfiscanf.$(oext): local.h floatio.h
vfscanf.$(oext): local.h floatio.h
-viscanf.$(oext): local.h
vscanf.$(oext): local.h
-vsniprintf.$(oext): local.h
-vsiscanf.$(oext): local.h
vsscanf.$(oext): local.h
wbuf.$(oext): local.h fvwrite.h
wsetup.$(oext): local.h
diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in
index 49827e332..c876b93a9 100644
--- a/newlib/libc/stdio/Makefile.in
+++ b/newlib/libc/stdio/Makefile.in
@@ -110,12 +110,12 @@ AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
-GENERAL_SOURCES = clearerr.c dprintf.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c fgetpos.c fgets.c fileno.c findfp.c fiprintf.c flags.c fopen.c fprintf.c fputc.c fputs.c fread.c freopen.c fscanf.c fiscanf.c fseek.c fsetpos.c ftell.c fvwrite.c fwalk.c fwrite.c getc.c getchar.c getc_u.c getchar_u.c getdelim.c getline.c gets.c iprintf.c iscanf.c makebuf.c perror.c printf.c putc.c putchar.c putc_u.c putchar_u.c puts.c refill.c remove.c rename.c rewind.c rget.c scanf.c sccl.c setbuf.c setbuffer.c setlinebuf.c setvbuf.c siprintf.c siscanf.c sniprintf.c snprintf.c sprintf.c sscanf.c stdio.c tmpfile.c tmpnam.c ungetc.c vdprintf.c viprintf.c viscanf.c vprintf.c vscanf.c vsiprintf.c vsiscanf.c vsnprintf.c vsniprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c
+GENERAL_SOURCES = clearerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c fgetpos.c fgets.c fileno.c findfp.c fiprintf.c flags.c fopen.c fprintf.c fputc.c fputs.c fread.c freopen.c fscanf.c fseek.c fsetpos.c ftell.c fvwrite.c fwalk.c fwrite.c getc.c getchar.c getc_u.c getchar_u.c getdelim.c getline.c gets.c iprintf.c makebuf.c perror.c printf.c putc.c putchar.c putc_u.c putchar_u.c puts.c refill.c remove.c rename.c rewind.c rget.c scanf.c setbuf.c setbuffer.c setlinebuf.c setvbuf.c siprintf.c snprintf.c sprintf.c sscanf.c stdio.c tmpfile.c tmpnam.c ungetc.c vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c
@ELIX_LEVEL_1_TRUE@LIB_OBJS =
-@ELIX_LEVEL_1_FALSE@LIB_OBJS = asiprintf.$(oext) asprintf.$(oext) fcloseall.$(oext) fseeko.$(oext) ftello.$(oext) getw.$(oext) mktemp.$(oext) putw.$(oext) vasiprintf.$(oext) vasprintf.$(oext)
+@ELIX_LEVEL_1_FALSE@LIB_OBJS = asprintf.$(oext) fcloseall.$(oext) fseeko.$(oext) ftello.$(oext) getw.$(oext) mktemp.$(oext) putw.$(oext) vasprintf.$(oext)
-LIBADD_OBJS = vfiprintf.$(oext) vfprintf.$(oext) vfscanf.$(oext) vfiscanf.$(oext)
+LIBADD_OBJS = vfiprintf.$(oext) vfprintf.$(oext)
libstdio_la_LDFLAGS = -Xcompiler -nostdlib
@@ -132,7 +132,7 @@ libstdio_la_LDFLAGS = -Xcompiler -nostdlib
@USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIBADD_OBJS) $(LIB_OBJS)
@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIBADD_OBJS) $(LIB_OBJS)
-CHEWOUT_FILES = clearerr.def dprintf.def fclose.def fcloseall.def fdopen.def feof.def ferror.def fflush.def fgetc.def fgetpos.def fgets.def fileno.def fiprintf.def fopen.def fputc.def fputs.def fread.def freopen.def fseek.def fsetpos.def ftell.def fwrite.def getc.def getchar.def getc_u.def getchar_u.def getdelim.def getline.def gets.def getw.def mktemp.def perror.def putc.def putchar.def putc_u.def putchar_u.def puts.def putw.def remove.def rename.def rewind.def setbuf.def setbuffer.def setlinebuf.def setvbuf.def siprintf.def siscanf.def sprintf.def sscanf.def tmpfile.def tmpnam.def vfprintf.def vfscanf.def viprintf.def viscanf.def
+CHEWOUT_FILES = clearerr.def fclose.def fcloseall.def fdopen.def feof.def ferror.def fflush.def fgetc.def fgetpos.def fgets.def fileno.def fiprintf.def fopen.def fputc.def fputs.def fread.def freopen.def fseek.def fsetpos.def ftell.def fwrite.def getc.def getchar.def getc_u.def getchar_u.def getdelim.def getline.def gets.def getw.def iprintf.def mktemp.def perror.def putc.def putchar.def putc_u.def putchar_u.def puts.def putw.def remove.def rename.def rewind.def setbuf.def setbuffer.def setlinebuf.def setvbuf.def siprintf.def sprintf.def sscanf.def tmpfile.def tmpnam.def vfprintf.def vfscanf.def
SUFFIXES = .def
@@ -150,56 +150,48 @@ LIBRARIES = $(noinst_LIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
-@USE_LIBTOOL_FALSE@lib_a_OBJECTS = clearerr.$(OBJEXT) dprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fclose.$(OBJEXT) fdopen.$(OBJEXT) feof.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@ferror.$(OBJEXT) fflush.$(OBJEXT) fgetc.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fgetpos.$(OBJEXT) fgets.$(OBJEXT) fileno.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@findfp.$(OBJEXT) fiprintf.$(OBJEXT) flags.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fopen.$(OBJEXT) fprintf.$(OBJEXT) fputc.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fputs.$(OBJEXT) fread.$(OBJEXT) freopen.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fscanf.$(OBJEXT) fiscanf.$(OBJEXT) fseek.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fsetpos.$(OBJEXT) ftell.$(OBJEXT) fvwrite.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@fwalk.$(OBJEXT) fwrite.$(OBJEXT) getc.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@getchar.$(OBJEXT) getc_u.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@lib_a_OBJECTS = clearerr.$(OBJEXT) fclose.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fdopen.$(OBJEXT) feof.$(OBJEXT) ferror.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fflush.$(OBJEXT) fgetc.$(OBJEXT) fgetpos.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fgets.$(OBJEXT) fileno.$(OBJEXT) findfp.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fiprintf.$(OBJEXT) flags.$(OBJEXT) fopen.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fprintf.$(OBJEXT) fputc.$(OBJEXT) fputs.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fread.$(OBJEXT) freopen.$(OBJEXT) fscanf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fseek.$(OBJEXT) fsetpos.$(OBJEXT) ftell.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fvwrite.$(OBJEXT) fwalk.$(OBJEXT) fwrite.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@getc.$(OBJEXT) getchar.$(OBJEXT) getc_u.$(OBJEXT) \
@USE_LIBTOOL_FALSE@getchar_u.$(OBJEXT) getdelim.$(OBJEXT) \
@USE_LIBTOOL_FALSE@getline.$(OBJEXT) gets.$(OBJEXT) iprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@iscanf.$(OBJEXT) makebuf.$(OBJEXT) perror.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@printf.$(OBJEXT) putc.$(OBJEXT) putchar.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@putc_u.$(OBJEXT) putchar_u.$(OBJEXT) puts.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@refill.$(OBJEXT) remove.$(OBJEXT) rename.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@rewind.$(OBJEXT) rget.$(OBJEXT) scanf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@sccl.$(OBJEXT) setbuf.$(OBJEXT) setbuffer.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@setlinebuf.$(OBJEXT) setvbuf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@siprintf.$(OBJEXT) siscanf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@sniprintf.$(OBJEXT) snprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@sprintf.$(OBJEXT) sscanf.$(OBJEXT) stdio.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@tmpfile.$(OBJEXT) tmpnam.$(OBJEXT) ungetc.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@vdprintf.$(OBJEXT) viprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@viscanf.$(OBJEXT) vprintf.$(OBJEXT) vscanf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@vsiprintf.$(OBJEXT) vsiscanf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@vsnprintf.$(OBJEXT) vsniprintf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@vsprintf.$(OBJEXT) vsscanf.$(OBJEXT) wbuf.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@wsetup.$(OBJEXT)
+@USE_LIBTOOL_FALSE@makebuf.$(OBJEXT) perror.$(OBJEXT) printf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@putc.$(OBJEXT) putchar.$(OBJEXT) putc_u.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@putchar_u.$(OBJEXT) puts.$(OBJEXT) refill.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@remove.$(OBJEXT) rename.$(OBJEXT) rewind.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@rget.$(OBJEXT) scanf.$(OBJEXT) setbuf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@setbuffer.$(OBJEXT) setlinebuf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@setvbuf.$(OBJEXT) siprintf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@snprintf.$(OBJEXT) sprintf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@sscanf.$(OBJEXT) stdio.$(OBJEXT) tmpfile.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@tmpnam.$(OBJEXT) ungetc.$(OBJEXT) vfscanf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@vprintf.$(OBJEXT) vscanf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@vsnprintf.$(OBJEXT) vsprintf.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@vsscanf.$(OBJEXT) wbuf.$(OBJEXT) wsetup.$(OBJEXT)
LTLIBRARIES = $(noinst_LTLIBRARIES)
-@USE_LIBTOOL_TRUE@libstdio_la_OBJECTS = clearerr.lo dprintf.lo \
-@USE_LIBTOOL_TRUE@fclose.lo fdopen.lo feof.lo ferror.lo fflush.lo \
-@USE_LIBTOOL_TRUE@fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \
-@USE_LIBTOOL_TRUE@fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo \
-@USE_LIBTOOL_TRUE@fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo \
-@USE_LIBTOOL_TRUE@fseek.lo fsetpos.lo ftell.lo fvwrite.lo fwalk.lo \
-@USE_LIBTOOL_TRUE@fwrite.lo getc.lo getchar.lo getc_u.lo getchar_u.lo \
-@USE_LIBTOOL_TRUE@getdelim.lo getline.lo gets.lo iprintf.lo iscanf.lo \
-@USE_LIBTOOL_TRUE@makebuf.lo perror.lo printf.lo putc.lo putchar.lo \
-@USE_LIBTOOL_TRUE@putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \
-@USE_LIBTOOL_TRUE@rename.lo rewind.lo rget.lo scanf.lo sccl.lo \
+@USE_LIBTOOL_TRUE@libstdio_la_OBJECTS = clearerr.lo fclose.lo fdopen.lo \
+@USE_LIBTOOL_TRUE@feof.lo ferror.lo fflush.lo fgetc.lo fgetpos.lo \
+@USE_LIBTOOL_TRUE@fgets.lo fileno.lo findfp.lo fiprintf.lo flags.lo \
+@USE_LIBTOOL_TRUE@fopen.lo fprintf.lo fputc.lo fputs.lo fread.lo \
+@USE_LIBTOOL_TRUE@freopen.lo fscanf.lo fseek.lo fsetpos.lo ftell.lo \
+@USE_LIBTOOL_TRUE@fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \
+@USE_LIBTOOL_TRUE@getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \
+@USE_LIBTOOL_TRUE@iprintf.lo makebuf.lo perror.lo printf.lo putc.lo \
+@USE_LIBTOOL_TRUE@putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo \
+@USE_LIBTOOL_TRUE@remove.lo rename.lo rewind.lo rget.lo scanf.lo \
@USE_LIBTOOL_TRUE@setbuf.lo setbuffer.lo setlinebuf.lo setvbuf.lo \
-@USE_LIBTOOL_TRUE@siprintf.lo siscanf.lo sniprintf.lo snprintf.lo \
-@USE_LIBTOOL_TRUE@sprintf.lo sscanf.lo stdio.lo tmpfile.lo tmpnam.lo \
-@USE_LIBTOOL_TRUE@ungetc.lo vdprintf.lo viprintf.lo viscanf.lo \
-@USE_LIBTOOL_TRUE@vprintf.lo vscanf.lo vsiprintf.lo vsiscanf.lo \
-@USE_LIBTOOL_TRUE@vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \
-@USE_LIBTOOL_TRUE@wbuf.lo wsetup.lo
+@USE_LIBTOOL_TRUE@siprintf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \
+@USE_LIBTOOL_TRUE@tmpfile.lo tmpnam.lo ungetc.lo vfscanf.lo vprintf.lo \
+@USE_LIBTOOL_TRUE@vscanf.lo vsnprintf.lo vsprintf.lo vsscanf.lo wbuf.lo \
+@USE_LIBTOOL_TRUE@wsetup.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -440,12 +432,6 @@ vfprintf.$(oext): vfprintf.c
vfiprintf.$(oext): vfprintf.c
$(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@
-vfscanf.$(oext): vfscanf.c
- $(LIB_COMPILE) -c $(srcdir)/vfscanf.c
-
-vfiscanf.$(oext): vfscanf.c
- $(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfscanf.c -o $@
-
.c.def:
$(CHEW) < $< > $*.def 2> $*.ref
touch stmp-def
@@ -466,7 +452,6 @@ ftell.$(oext): local.h
fvwrite.$(oext): local.h fvwrite.h
fwalk.$(oext): local.h
fwrite.$(oext): local.h fvwrite.h
-iscanf.$(oext): local.h
makebuf.$(oext): local.h
puts.$(oext): fvwrite.h
refill.$(oext): local.h
@@ -474,20 +459,14 @@ scanf.$(oext): local.h
setbuf.$(oext): local.h
setvbuf.$(oext): local.h
siprintf.$(oext): local.h
-sniprintf.$(oext): local.h
sprintf.$(oext): local.h
-siscanf.$(oext): local.h
sscanf.$(oext): local.h
stdio.$(oext): local.h
ungetc.$(oext): local.h
vfiprintf.$(oext): local.h
vfprintf.$(oext): local.h
-vfiscanf.$(oext): local.h floatio.h
vfscanf.$(oext): local.h floatio.h
-viscanf.$(oext): local.h
vscanf.$(oext): local.h
-vsniprintf.$(oext): local.h
-vsiscanf.$(oext): local.h
vsscanf.$(oext): local.h
wbuf.$(oext): local.h fvwrite.h
wsetup.$(oext): local.h
diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c
deleted file mode 100644
index e8e10bf38..000000000
--- a/newlib/libc/stdio/asiprintf.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-/* This code was copied from asprintf.c */
-
-#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
-{
- int ret;
- va_list ap;
- FILE f;
-
- /* mark a zero-length reallocatable buffer */
- f._flags = __SWR | __SSTR | __SMBF;
- 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);
- va_end (ap);
- *f._p = 0;
- *strp = f._bf._base;
- return (ret);
-}
-
-#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
-{
- int ret;
- va_list ap;
- FILE f;
-
- /* mark a zero-length reallocatable buffer */
- f._flags = __SWR | __SSTR | __SMBF;
- 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);
- va_end (ap);
- *f._p = 0;
- *strp = f._bf._base;
- return (ret);
-}
-
-#endif
diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c
index 0923ff84d..e242ff5e1 100644
--- a/newlib/libc/stdio/clearerr.c
+++ b/newlib/libc/stdio/clearerr.c
@@ -54,17 +54,12 @@ No supporting OS subroutines are required.
#include <_ansi.h>
#include <stdio.h>
-#include "local.h"
-
-/* A subroutine version of the macro clearerr. */
-
#undef clearerr
_VOID
_DEFUN(clearerr, (fp),
FILE * fp)
{
- CHECK_INIT(_REENT);
_flockfile (fp);
__sclearerr (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/dprintf.c b/newlib/libc/stdio/dprintf.c
deleted file mode 100644
index 6ebf12e8d..000000000
--- a/newlib/libc/stdio/dprintf.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Copyright 2005 Shaun Jackman
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
-/*
-FUNCTION
-<<dprintf>>, <<vdprintf>>---print to a file descriptor
-
-INDEX
- dprintf
-INDEX
- vdprintf
-
-ANSI_SYNOPSIS
- #include <stdio.h>
- #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]>,
- const char *<[format]>, ...);
- int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>,
- const char *<[format]>, va_list <[ap]>);
-
-TRAD_SYNOPSIS
- #include <stdio.h>
- #include <varargs.h>
-
- int dprintf(<[fd]>, <[format]> [, <[arg]>, ...])
- int <[fd]>;
- char *<[format]>;
-
- int vdprintf(<[fd]>, <[fmt]>, <[list]>)
- int <[fd]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _dprintf_r(<[ptr]>, <[fd]>, <[format]> [, <[arg]>, ...])
- struct _reent *<[ptr]>;
- int <[fd]>;
- char *<[format]>;
-
- int _vdprintf_r(<[ptr]>, <[fd]>, <[fmt]>, <[list]>)
- struct _reent *<[ptr]>;
- int <[fd]>;
- char *<[fmt]>;
- va_list <[list]>;
-
-DESCRIPTION
-<<dprintf>> and <<vdprintf>> allow printing a format, similarly to
-<<printf>>, but write to a file descriptor instead of to a <<FILE>>
-stream.
-
-The functions <<_dprintf_r>> and <<_vdprintf_r>> are simply
-reentrant versions of the functions above.
-
-RETURNS
-The return value and errors are exactly as for <<write>>, except that
-<<errno>> may also be set to <<ENOMEM>> if the heap is exhausted.
-
-PORTABILITY
-This function is originally a GNU extension in glibc and is not portable.
-
-Supporting OS subroutines required: <<sbrk>>, <<write>>.
-*/
-
-#include <_ansi.h>
-#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
-{
- va_list ap;
- int n;
- _REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
- va_start (ap, format);
-#else
- va_start (ap);
-#endif
- n = _vdprintf_r (ptr, fd, format, ap);
- va_end (ap);
- return n;
-}
-
-#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
-{
- 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;
-}
-
-#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index 66d71c2d4..f9fd17cb0 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -76,10 +76,10 @@ _DEFUN(_fclose_r, (rptr, fp),
__sfp_lock_acquire ();
- CHECK_INIT (rptr);
-
_flockfile (fp);
+ CHECK_INIT (fp);
+
if (fp->_flags == 0) /* not open! */
{
_funlockfile (fp);
diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c
index aff4e84c8..5372f2f37 100644
--- a/newlib/libc/stdio/feof.c
+++ b/newlib/libc/stdio/feof.c
@@ -46,9 +46,6 @@ No supporting OS subroutines are required.
*/
#include <stdio.h>
-#include "local.h"
-
-/* A subroutine version of the macro feof. */
#undef feof
@@ -57,7 +54,6 @@ _DEFUN(feof, (fp),
FILE * fp)
{
int result;
- CHECK_INIT(_REENT);
_flockfile (fp);
result = __sfeof (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c
index ea701bec7..6f665d4c8 100644
--- a/newlib/libc/stdio/ferror.c
+++ b/newlib/libc/stdio/ferror.c
@@ -55,7 +55,6 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <_ansi.h>
#include <stdio.h>
-#include "local.h"
/* A subroutine version of the macro ferror. */
@@ -66,7 +65,6 @@ _DEFUN(ferror, (fp),
FILE * fp)
{
int result;
- CHECK_INIT(_REENT);
_flockfile (fp);
result = __sferror (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index 05084dde0..0b157d0ce 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -67,23 +67,13 @@ _DEFUN(fflush, (fp),
if (fp == NULL)
return _fwalk (_GLOBAL_REENT, fflush);
- CHECK_INIT (_REENT);
-
_flockfile (fp);
+ CHECK_INIT (fp);
+
t = fp->_flags;
- if ((t & __SWR) == 0)
- {
- /* For a read stream, an fflush causes the next seek to be
- unoptimized (i.e. forces a system-level seek). This conforms
- to the POSIX and SUSv3 standards. */
- fp->_flags |= __SNPT;
- _funlockfile (fp);
- return 0;
- }
- if ((p = fp->_bf._base) == NULL)
+ if ((t & __SWR) == 0 || (p = fp->_bf._base) == NULL)
{
- /* Nothing to flush. */
_funlockfile (fp);
return 0;
}
diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c
index 020b2da3a..5d5ad9a00 100644
--- a/newlib/libc/stdio/fgetc.c
+++ b/newlib/libc/stdio/fgetc.c
@@ -55,14 +55,12 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <_ansi.h>
#include <stdio.h>
-#include "local.h"
int
_DEFUN(fgetc, (fp),
FILE * fp)
{
int result;
- CHECK_INIT(_REENT);
_flockfile (fp);
result = __sgetc (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/fgetpos.c b/newlib/libc/stdio/fgetpos.c
index 21a63789d..a89d88f03 100644
--- a/newlib/libc/stdio/fgetpos.c
+++ b/newlib/libc/stdio/fgetpos.c
@@ -81,12 +81,15 @@ _DEFUN(_fgetpos_r, (ptr, fp, pos),
FILE * fp _AND
_fpos_t * pos)
{
+ _flockfile (fp);
*pos = _ftell_r (ptr, fp);
if (*pos != -1)
{
+ _funlockfile (fp);
return 0;
}
+ _funlockfile (fp);
return 1;
}
diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c
index f5dde4903..8c5147ac9 100644
--- a/newlib/libc/stdio/fgets.c
+++ b/newlib/libc/stdio/fgets.c
@@ -80,8 +80,6 @@ _DEFUN(fgets, (buf, n, fp),
s = buf;
- CHECK_INIT(_REENT);
-
_flockfile (fp);
#ifdef __SCLE
if (fp->_flags & __SCLE)
diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c
index b202cc5e3..57d091274 100644
--- a/newlib/libc/stdio/fileno.c
+++ b/newlib/libc/stdio/fileno.c
@@ -54,8 +54,8 @@ _DEFUN(fileno, (f),
FILE * f)
{
int result;
- CHECK_INIT (_REENT);
_flockfile (f);
+ CHECK_INIT (f);
result = __sfileno (f);
_funlockfile (f);
return result;
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index e3270af38..a9695ffff 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -163,14 +163,6 @@ _VOID
_DEFUN(__sinit, (s),
struct _reent *s)
{
- __sinit_lock_acquire ();
-
- if (s->__sdidinit)
- {
- __sinit_lock_release ();
- return;
- }
-
/* make sure we clean up on exit */
s->__cleanup = _cleanup_r; /* conservative */
s->__sdidinit = 1;
@@ -200,13 +192,11 @@ _DEFUN(__sinit, (s),
std (s->_stderr, __SWR | __SNBF, 2, s);
- __sinit_lock_release ();
}
#ifndef __SINGLE_THREAD__
__LOCK_INIT_RECURSIVE(static, __sfp_lock);
-__LOCK_INIT_RECURSIVE(static, __sinit_lock);
_VOID
_DEFUN_VOID(__sfp_lock_acquire)
@@ -220,18 +210,6 @@ _DEFUN_VOID(__sfp_lock_release)
__lock_release_recursive (__sfp_lock);
}
-_VOID
-_DEFUN_VOID(__sinit_lock_acquire)
-{
- __lock_acquire_recursive (__sinit_lock);
-}
-
-_VOID
-_DEFUN_VOID(__sinit_lock_release)
-{
- __lock_release_recursive (__sinit_lock);
-}
-
/* Walkable file locking routine. */
static int
_DEFUN(__fp_lock, (ptr),
diff --git a/newlib/libc/stdio/fiprintf.c b/newlib/libc/stdio/fiprintf.c
index 3529e7f19..4bf60948b 100644
--- a/newlib/libc/stdio/fiprintf.c
+++ b/newlib/libc/stdio/fiprintf.c
@@ -15,6 +15,45 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/*
+FUNCTION
+<<fiprintf>>---format output to file (integer only)
+
+INDEX
+ fiprintf
+
+ANSI_SYNOPSIS
+ #include <stdio.h>
+
+ int fiprintf(FILE *<[fd]>, const char *<[format]>, ...);
+
+TRAD_SYNOPSIS
+ #include <stdio.h>
+
+ int fiprintf(<[fd]>, <[format]> [, <[arg]>, ...]);
+ FILE *<[fd]>;
+ char *<[format]>;
+
+DESCRIPTION
+<<fiprintf>> is a restricted version of <<fprintf>>: it has the same
+arguments and behavior, save that it cannot perform any floating-point
+formatting---the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers
+are not recognized.
+
+RETURNS
+ <<fiprintf>> returns the number of bytes in the output string,
+ save that the concluding <<NULL>> is not counted.
+ <<fiprintf>> returns when the end of the format string is
+ encountered. If an error occurs, <<fiprintf>>
+ returns <<EOF>>.
+
+PORTABILITY
+<<fiprintf>> is not required by ANSI C.
+
+Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
+<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
+*/
+
#include <_ansi.h>
#include <stdio.h>
#ifdef _HAVE_STDC
diff --git a/newlib/libc/stdio/fiscanf.c b/newlib/libc/stdio/fiscanf.c
deleted file mode 100644
index 53fee8454..000000000
--- a/newlib/libc/stdio/fiscanf.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#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
-
-int
-#ifdef _HAVE_STDC
-fiscanf(FILE *fp, _CONST char *fmt, ...)
-#else
-fiscanf(FILE *fp, fmt, va_alist)
- FILE *fp;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = __svfiscanf_r (_REENT, fp, fmt, ap);
- va_end (ap);
- return ret;
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-#ifdef _HAVE_STDC
-_fiscanf_r(struct _reent *ptr, FILE *fp, _CONST char *fmt, ...)
-#else
-_fiscanf_r(ptr, FILE *fp, fmt, va_alist)
- struct _reent *ptr;
- FILE *fp;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = __svfiscanf_r (ptr, fp, fmt, ap);
- va_end (ap);
- return (ret);
-}
-
diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c
index 422f6753a..026ccfb83 100644
--- a/newlib/libc/stdio/fputc.c
+++ b/newlib/libc/stdio/fputc.c
@@ -59,7 +59,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <_ansi.h>
#include <stdio.h>
-#include "local.h"
int
_DEFUN(fputc, (ch, file),
@@ -67,7 +66,6 @@ _DEFUN(fputc, (ch, file),
FILE * file)
{
int result;
- CHECK_INIT(_REENT);
_flockfile (file);
result = putc (ch, file);
_funlockfile (file);
diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c
index 8d02107df..8d605c0df 100644
--- a/newlib/libc/stdio/fputs.c
+++ b/newlib/libc/stdio/fputs.c
@@ -51,7 +51,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <stdio.h>
#include <string.h>
#include "fvwrite.h"
-#include "local.h"
/*
* Write the given string to the given file.
@@ -70,9 +69,6 @@ _DEFUN(fputs, (s, fp),
iov.iov_len = uio.uio_resid = strlen (s);
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
-
- CHECK_INIT(_REENT);
-
_flockfile (fp);
result = __sfvwrite (fp, &uio);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c
index 1354c04ba..fa3873075 100644
--- a/newlib/libc/stdio/fread.c
+++ b/newlib/libc/stdio/fread.c
@@ -125,8 +125,6 @@ _DEFUN(fread, (buf, size, count, fp),
if ((resid = count * size) == 0)
return 0;
- CHECK_INIT(_REENT);
-
_flockfile (fp);
if (fp->_r < 0)
fp->_r = 0;
@@ -151,7 +149,7 @@ _DEFUN(fread, (buf, size, count, fp),
FREEUB (fp);
/* Finally read directly into user's buffer if needed. */
- while (resid > 0)
+ if (resid > 0)
{
int rc = 0;
/* save fp buffering state */
@@ -164,20 +162,20 @@ _DEFUN(fread, (buf, size, count, fp),
fp->_p = p;
rc = __srefill (fp);
/* restore fp buffering back to original state */
+ resid -= fp->_r;
+ fp->_r = 0;
fp->_bf._base = old_base;
fp->_bf._size = old_size;
fp->_p = old_p;
- resid -= fp->_r;
- p += fp->_r;
- fp->_r = 0;
if (rc)
{
+ /* no more input: return partial result */
#ifdef __SCLE
- if (fp->_flags & __SCLE)
- {
- _funlockfile (fp);
- return crlf (fp, buf, total-resid, 1) / size;
- }
+ if (fp->_flags & __SCLE)
+ {
+ _funlockfile (fp);
+ return crlf (fp, buf, total-resid, 1) / size;
+ }
#endif
_funlockfile (fp);
return (total - resid) / size;
diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c
index ae3444b1b..d4a65e77b 100644
--- a/newlib/libc/stdio/freopen.c
+++ b/newlib/libc/stdio/freopen.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 2006 The Regents of the University of California.
+ * Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
@@ -55,12 +55,6 @@ it).
<[file]> and <[mode]> are used just as in <<fopen>>.
-If <[file]> is <<NULL>>, the underlying stream is modified rather than
-closed. The file cannot be given a more permissive access mode (for
-example, a <[mode]> of "w" will fail on a read-only file descriptor),
-but can change status such as append or binary mode. If modification
-is not possible, failure occurs.
-
RETURNS
If successful, the result is the same as the argument <[fp]>. If the
file cannot be opened as specified, the result is <<NULL>>.
@@ -76,7 +70,6 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <reent.h>
#include <time.h>
#include <stdio.h>
-#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/lock.h>
@@ -94,15 +87,14 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
register FILE *fp)
{
register int f;
- int flags, oflags;
- int e = 0;
+ int flags, oflags, e;
__sfp_lock_acquire ();
- CHECK_INIT (ptr);
-
_flockfile (fp);
+ CHECK_INIT (fp);
+
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
_funlockfile (fp);
@@ -125,60 +117,17 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
{
if (fp->_flags & __SWR)
_CAST_VOID fflush (fp);
- /*
- * If close is NULL, closing is a no-op, hence pointless.
- * If file is NULL, the file should not be closed.
- */
- if (fp->_close != NULL && file != NULL)
+ /* if close is NULL, closing is a no-op, hence pointless */
+ if (fp->_close != NULL)
_CAST_VOID (*fp->_close) (fp->_cookie);
}
/*
- * Now get a new descriptor to refer to the new file, or reuse the
- * existing file descriptor if file is NULL.
+ * Now get a new descriptor to refer to the new file.
*/
- if (file != NULL)
- {
- f = _open_r (ptr, (char *) file, oflags, 0666);
- e = ptr->_errno;
- }
- else
- {
-#ifdef HAVE_FCNTL
- int oldflags;
- /*
- * Reuse the file descriptor, but only if the new access mode is
- * equal or less permissive than the old. F_SETFL correctly
- * ignores creation flags.
- */
- f = fp->_file;
- if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1
- || ! ((oldflags & O_ACCMODE) == O_RDWR
- || ((oldflags ^ oflags) & O_ACCMODE) == 0)
- || _fcntl_r (ptr, f, F_SETFL, oflags) == -1)
- f = -1;
-#else
- /* We cannot modify without fcntl support. */
- f = -1;
-#endif
-
-#ifdef __SCLE
- /*
- * F_SETFL doesn't change textmode. Don't mess with modes of ttys.
- */
- if (0 <= f && ! isatty (f)
- && setmode (f, flags & (O_BINARY | O_TEXT)) == -1)
- f = -1;
-#endif
-
- if (f < 0)
- {
- e = EBADF;
- if (fp->_close != NULL)
- _CAST_VOID (*fp->_close) (fp->_cookie);
- }
- }
+ f = _open_r (ptr, (char *) file, oflags, 0666);
+ e = ptr->_errno;
/*
* Finish closing fp. Even if the open succeeded above,
diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c
index 8b189ba17..b3df7f04e 100644
--- a/newlib/libc/stdio/fseek.c
+++ b/newlib/libc/stdio/fseek.c
@@ -129,11 +129,11 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
struct stat st;
int havepos;
- /* Make sure stdio is set up. */
+ _flockfile (fp);
- CHECK_INIT (ptr);
+ /* Make sure stdio is set up. */
- _flockfile (fp);
+ CHECK_INIT (fp);
/* If we've been doing some writing, and we're in append mode
then we don't really know where the filepos is. */
@@ -359,13 +359,6 @@ dumb:
fp->_r = 0;
/* fp->_w = 0; *//* unnecessary (I think...) */
fp->_flags &= ~__SEOF;
- /* Reset no-optimization flag after successful seek. The
- no-optimization flag may be set in the case of a read
- stream that is flushed which by POSIX/SUSv3 standards,
- means that a corresponding seek must not optimize. The
- optimization is then allowed if no subsequent flush
- is performed. */
- fp->_flags &= ~__SNPT;
_funlockfile (fp);
return 0;
}
diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c
index 74d6d906c..952574159 100644
--- a/newlib/libc/stdio/ftell.c
+++ b/newlib/libc/stdio/ftell.c
@@ -105,11 +105,11 @@ _DEFUN(_ftell_r, (ptr, fp),
{
_fpos_t pos;
- /* Ensure stdio is set up. */
+ _flockfile (fp);
- CHECK_INIT (ptr);
+ /* Ensure stdio is set up. */
- _flockfile (fp);
+ CHECK_INIT (fp);
if (fp->_seek == NULL)
{
@@ -143,7 +143,7 @@ _DEFUN(_ftell_r, (ptr, fp),
if (HASUB (fp))
pos -= fp->_ur;
}
- else if ((fp->_flags & __SWR) && fp->_p != NULL)
+ else if (fp->_flags & __SWR && fp->_p != NULL)
{
/*
* Writing. Any buffered characters cause the
diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c
index 663fff62c..18514ec2e 100644
--- a/newlib/libc/stdio/fwrite.c
+++ b/newlib/libc/stdio/fwrite.c
@@ -99,8 +99,6 @@ _DEFUN(fwrite, (buf, size, count, fp),
* generally slow and since this occurs whenever size==0.
*/
- CHECK_INIT(_REENT);
-
_flockfile (fp);
if (__sfvwrite (fp, &uio) == 0)
{
diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c
index 9628a8740..0aa5ce313 100644
--- a/newlib/libc/stdio/getc.c
+++ b/newlib/libc/stdio/getc.c
@@ -64,7 +64,6 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <_ansi.h>
#include <stdio.h>
-#include "local.h"
/*
* A subroutine version of the macro getc.
@@ -77,8 +76,8 @@ _DEFUN(getc, (fp),
register FILE *fp)
{
int result;
- CHECK_INIT (_REENT);
_flockfile (fp);
+ /* CHECK_INIT is called (eventually) by __srefill. */
result = __sgetc (fp);
_funlockfile (fp);
return result;
diff --git a/newlib/libc/stdio/getchar.c b/newlib/libc/stdio/getchar.c
index 19301c113..8bb46ef57 100644
--- a/newlib/libc/stdio/getchar.c
+++ b/newlib/libc/stdio/getchar.c
@@ -82,7 +82,7 @@ int
_DEFUN(_getchar_r, (f),
struct _reent *f)
{
- _REENT_SMALL_CHECK_INIT (f);
+ _REENT_SMALL_CHECK_INIT (_stdin_r (f));
return getc (_stdin_r (f));
}
diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c
index 0fdfb3add..6c3e298d8 100644
--- a/newlib/libc/stdio/getdelim.c
+++ b/newlib/libc/stdio/getdelim.c
@@ -1,7 +1,7 @@
/* Copyright 2002, Red Hat Inc. - all rights reserved */
/*
FUNCTION
-<<getdelim>>---read a line up to a specified line delimiter
+<<getdelim>>---read a line up to a specified line delimeter
INDEX
getdelim
@@ -21,16 +21,16 @@ TRAD_SYNOPSIS
DESCRIPTION
<<getdelim>> reads a file <[fp]> up to and possibly including a specified
-delimiter <[delim]>. The line is read into a buffer pointed to
+delimeter <[delim]>. The line is read into a buffer pointed to
by <[bufptr]> and designated with size *<[n]>. If the buffer is
not large enough, it will be dynamically grown by <<getdelim>>.
As the buffer is grown, the pointer to the size <[n]> will be
updated.
RETURNS
-<<getdelim>> returns <<-1>> if no characters were successfully read;
+<<getdelim>> returns <<-1>> if no characters were successfully read,
otherwise, it returns the number of bytes successfully read.
-At end of file, the result is nonzero.
+at end of file, the result is nonzero.
PORTABILITY
<<getdelim>> is a glibc extension.
@@ -79,10 +79,10 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp),
*n = DEFAULT_LINE_SIZE;
}
- CHECK_INIT (_REENT);
-
_flockfile (fp);
+ CHECK_INIT (fp);
+
numbytes = *n;
ptr = buf;
diff --git a/newlib/libc/stdio/getw.c b/newlib/libc/stdio/getw.c
index 210c5939a..b5065bd53 100644
--- a/newlib/libc/stdio/getw.c
+++ b/newlib/libc/stdio/getw.c
@@ -37,15 +37,14 @@ to get the next word from the file or stream identified by <[fp]>. As
a side effect, <<getw>> advances the file's current position
indicator.
-RETURNS
-The next word (read as an <<int>>), unless there is no more
-data or the host system reports a read error; in either of these
+RETURNS The next word (read as an <<int>>), unless there is no more
+data, or the host system reports a read error; in either of these
situations, <<getw>> returns <<EOF>>. Since <<EOF>> is a valid
<<int>>, you must use <<ferror>> or <<feof>> to distinguish these
situations.
PORTABILITY
-<<getw>> is a remnant of K&R C; it is not part of any ISO C Standard.
+<<getw>> is a remnant of K&R C, it is not part of any ISO C Standard.
<<fread>> should be used instead. In fact, this implementation of
<<getw>> is based upon <<fread>>.
diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c
index c9a026424..4b698ad7f 100644
--- a/newlib/libc/stdio/iprintf.c
+++ b/newlib/libc/stdio/iprintf.c
@@ -15,6 +15,44 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/*
+FUNCTION
+<<iprintf>>---write formatted output (integer only)
+
+INDEX
+ iprintf
+
+ANSI_SYNOPSIS
+ #include <stdio.h>
+
+ int iprintf(const char *<[format]>, ...);
+
+TRAD_SYNOPSIS
+ #include <stdio.h>
+
+ int iprintf(<[format]> [, <[arg]>, ...])
+ char *<[format]>;
+
+DESCRIPTION
+<<iprintf>> is a restricted version of <<printf>>: it has the same
+arguments and behavior, save that it cannot perform any floating-point
+formatting: the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers
+are not recognized.
+
+RETURNS
+ <<iprintf>> returns the number of bytes in the output string,
+ save that the concluding <<NULL>> is not counted.
+ <<iprintf>> returns when the end of the format string is
+ encountered. If an error occurs, <<iprintf>>
+ returns <<EOF>>.
+
+PORTABILITY
+<<iprintf>> is not required by ANSI C.
+
+Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
+<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
+*/
+
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
@@ -40,7 +78,7 @@ iprintf(fmt, va_alist)
int ret;
va_list ap;
- _REENT_SMALL_CHECK_INIT (_REENT);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
@@ -67,7 +105,7 @@ _iprintf_r(ptr, fmt, va_alist)
int ret;
va_list ap;
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (ptr));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
diff --git a/newlib/libc/stdio/iscanf.c b/newlib/libc/stdio/iscanf.c
deleted file mode 100644
index f35acd2ed..000000000
--- a/newlib/libc/stdio/iscanf.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#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
-
-int
-#ifdef _HAVE_STDC
-iscanf(_CONST char *fmt, ...)
-#else
-iscanf(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
- _REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = __svfiscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
- va_end (ap);
- return ret;
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-#ifdef _HAVE_STDC
-_iscanf_r(struct _reent *ptr, _CONST char *fmt, ...)
-#else
-_iscanf_r(ptr, fmt, va_alist)
- struct _reent *ptr;
- char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
-
- _REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = __svfiscanf_r (ptr, _stdin_r (ptr), fmt, ap);
- va_end (ap);
- return (ret);
-}
-
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h
index f7093b697..c4176eb2a 100644
--- a/newlib/libc/stdio/local.h
+++ b/newlib/libc/stdio/local.h
@@ -30,7 +30,6 @@
#include <unistd.h>
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
-extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
extern FILE *_EXFUN(__sfp,(struct _reent *));
extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
extern int _EXFUN(__srefill,(FILE *));
@@ -49,11 +48,11 @@ extern int _EXFUN(__srefill,(FILE *fp));
/* Called by the main entry point fns to ensure stdio has been initialized. */
-#define CHECK_INIT(ptr) \
+#define CHECK_INIT(fp) \
do \
{ \
- if ((ptr) && !(ptr)->__sdidinit) \
- __sinit (ptr); \
+ if (_REENT && !_REENT->__sdidinit) \
+ __sinit (_REENT); \
} \
while (0)
@@ -95,11 +94,7 @@ char *_EXFUN(_llicvt,(char *, long long, char));
#ifdef __SINGLE_THREAD__
#define __sfp_lock_acquire()
#define __sfp_lock_release()
-#define __sinit_lock_acquire()
-#define __sinit_lock_release()
#else
_VOID _EXFUN(__sfp_lock_acquire,(_VOID));
_VOID _EXFUN(__sfp_lock_release,(_VOID));
-_VOID _EXFUN(__sinit_lock_acquire,(_VOID));
-_VOID _EXFUN(__sinit_lock_release,(_VOID));
#endif
diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c
index 5dbf3326c..6ee698705 100644
--- a/newlib/libc/stdio/perror.c
+++ b/newlib/libc/stdio/perror.c
@@ -74,7 +74,7 @@ _DEFUN(_perror_r, (ptr, s),
{
char *error;
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stderr_r (ptr));
if (s != NULL && *s != '\0')
{
fputs (s, _stderr_r (ptr));
diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c
index 19f465e34..2512afe04 100644
--- a/newlib/libc/stdio/printf.c
+++ b/newlib/libc/stdio/printf.c
@@ -39,7 +39,7 @@ _printf_r(ptr, fmt, va_alist)
int ret;
va_list ap;
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (ptr));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
@@ -65,7 +65,7 @@ printf(fmt, va_alist)
int ret;
va_list ap;
- _REENT_SMALL_CHECK_INIT (_REENT);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c
index 097323417..509aaf48d 100644
--- a/newlib/libc/stdio/putc.c
+++ b/newlib/libc/stdio/putc.c
@@ -67,7 +67,6 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#include <_ansi.h>
#include <stdio.h>
-#include "local.h"
/*
* A subroutine version of the macro putc.
@@ -81,8 +80,8 @@ _DEFUN(putc, (c, fp),
register FILE *fp)
{
int result;
- CHECK_INIT (_REENT);
_flockfile (fp);
+ /* CHECK_INIT is (eventually) called by __swbuf. */
result = __sputc (c, fp);
_funlockfile (fp);
return result;
diff --git a/newlib/libc/stdio/putchar.c b/newlib/libc/stdio/putchar.c
index e1d748ae2..903de072d 100644
--- a/newlib/libc/stdio/putchar.c
+++ b/newlib/libc/stdio/putchar.c
@@ -80,7 +80,7 @@ _DEFUN(_putchar_r, (ptr, c),
struct _reent *ptr _AND
int c)
{
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (ptr));
return putc (c, _stdout_r (ptr));
}
diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c
index bf32d0401..68251ce67 100644
--- a/newlib/libc/stdio/puts.c
+++ b/newlib/libc/stdio/puts.c
@@ -90,7 +90,7 @@ _DEFUN(_puts_r, (ptr, s),
uio.uio_iov = &iov[0];
uio.uio_iovcnt = 2;
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (ptr));
return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n');
}
diff --git a/newlib/libc/stdio/putw.c b/newlib/libc/stdio/putw.c
index 682015c0a..78406eeb4 100644
--- a/newlib/libc/stdio/putw.c
+++ b/newlib/libc/stdio/putw.c
@@ -37,11 +37,10 @@ DESCRIPTION
to write a word to the file or stream identified by <[fp]>. As a side
effect, <<putw>> advances the file's current position indicator.
-RETURNS
-Zero on success, <<EOF>> on failure.
+RETURNS Zero on success, <<EOF>> on failure.
PORTABILITY
-<<putw>> is a remnant of K&R C; it is not part of any ISO C Standard.
+<<putw>> is a remnant of K&R C, it is not part of any ISO C Standard.
<<fwrite>> should be used instead. In fact, this implementation of
<<putw>> is based upon <<fwrite>>.
diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c
index 639ce6e24..74573e8fd 100644
--- a/newlib/libc/stdio/refill.c
+++ b/newlib/libc/stdio/refill.c
@@ -41,15 +41,13 @@ _DEFUN(__srefill, (fp),
{
/* make sure stdio is set up */
- CHECK_INIT (_REENT);
+ CHECK_INIT (fp);
fp->_r = 0; /* largely a convenience for callers */
-#ifndef __CYGWIN__
/* SysV does not make this test; take it out for compatibility */
if (fp->_flags & __SEOF)
return EOF;
-#endif
/* if not already reading, have to be reading and writing */
if ((fp->_flags & __SRD) == 0)
@@ -100,13 +98,7 @@ _DEFUN(__srefill, (fp),
fp->_p = fp->_bf._base;
fp->_r = (*fp->_read) (fp->_cookie, (char *) fp->_p, fp->_bf._size);
fp->_flags &= ~__SMOD; /* buffer contents are again pristine */
-#ifndef __CYGWIN__
if (fp->_r <= 0)
-#else
- if (fp->_r > 0)
- fp->_flags &= ~__SEOF;
- else
-#endif
{
if (fp->_r == 0)
fp->_flags |= __SEOF;
diff --git a/newlib/libc/stdio/scanf.c b/newlib/libc/stdio/scanf.c
index cf1472ba7..733a638e6 100644
--- a/newlib/libc/stdio/scanf.c
+++ b/newlib/libc/stdio/scanf.c
@@ -39,7 +39,7 @@ scanf(fmt, va_alist)
int ret;
va_list ap;
- _REENT_SMALL_CHECK_INIT (_REENT);
+ _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
@@ -65,7 +65,7 @@ _scanf_r(ptr, fmt, va_alist)
int ret;
va_list ap;
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdin_r (ptr));
#ifdef _HAVE_STDC
va_start (ap, fmt);
#else
diff --git a/newlib/libc/stdio/sccl.c b/newlib/libc/stdio/sccl.c
deleted file mode 100644
index b01801145..000000000
--- a/newlib/libc/stdio/sccl.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Split from vfscanf.c */
-
-#include <_ansi.h>
-#include <reent.h>
-#include <newlib.h>
-#include <stdio.h>
-#include "local.h"
-
-/*
- * Fill in the given table from the scanset at the given format
- * (just after `['). Return a pointer to the character past the
- * closing `]'. The table has a 1 wherever characters should be
- * considered part of the scanset.
- */
-
-u_char *
-_DEFUN(__sccl, (tab, fmt),
- register char *tab _AND
- register u_char *fmt)
-{
- register int c, n, v;
-
- /* first `clear' the whole table */
- c = *fmt++; /* first char hat => negated scanset */
- if (c == '^')
- {
- v = 1; /* default => accept */
- c = *fmt++; /* get new first char */
- }
- else
- v = 0; /* default => reject */
- /* should probably use memset here */
- for (n = 0; n < 256; n++)
- tab[n] = v;
- if (c == 0)
- return fmt - 1; /* format ended before closing ] */
-
- /*
- * Now set the entries corresponding to the actual scanset to the
- * opposite of the above.
- *
- * The first character may be ']' (or '-') without being special; the
- * last character may be '-'.
- */
-
- v = 1 - v;
- for (;;)
- {
- tab[c] = v; /* take character c */
- doswitch:
- n = *fmt++; /* and examine the next */
- switch (n)
- {
-
- case 0: /* format ended too soon */
- return fmt - 1;
-
- case '-':
- /*
- * A scanset of the form [01+-] is defined as `the digit 0, the
- * digit 1, the character +, the character -', but the effect of a
- * scanset such as [a-zA-Z0-9] is implementation defined. The V7
- * Unix scanf treats `a-z' as `the letters a through z', but treats
- * `a-a' as `the letter a, the character -, and the letter a'.
- *
- * For compatibility, the `-' is not considerd to define a range if
- * the character following it is either a close bracket (required by
- * ANSI) or is not numerically greater than the character we just
- * stored in the table (c).
- */
- n = *fmt;
- if (n == ']' || n < c)
- {
- c = '-';
- break; /* resume the for(;;) */
- }
- fmt++;
- do
- { /* fill in the range */
- tab[++c] = v;
- }
- while (c < n);
-#if 1 /* XXX another disgusting compatibility hack */
- /*
- * Alas, the V7 Unix scanf also treats formats such
- * as [a-c-e] as `the letters a through e'. This too
- * is permitted by the standard....
- */
- goto doswitch;
-#else
- c = *fmt++;
- if (c == 0)
- return fmt - 1;
- if (c == ']')
- return fmt;
-#endif
-
- break;
-
-
- case ']': /* end of scanset */
- return fmt;
-
- default: /* just another character */
- c = n;
- break;
- }
- }
- /* NOTREACHED */
-}
diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c
index f6871c59d..eddfde8e3 100644
--- a/newlib/libc/stdio/setvbuf.c
+++ b/newlib/libc/stdio/setvbuf.c
@@ -104,10 +104,10 @@ _DEFUN(setvbuf, (fp, buf, mode, size),
{
int ret = 0;
- CHECK_INIT (_REENT);
-
_flockfile (fp);
+ CHECK_INIT (fp);
+
/*
* Verify arguments. The `int' limit on `size' is due to this
* particular implementation.
diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c
index 4e8e95aaa..838200805 100644
--- a/newlib/libc/stdio/siprintf.c
+++ b/newlib/libc/stdio/siprintf.c
@@ -17,69 +17,37 @@
/*
FUNCTION
- <<iprintf>>, <<fiprintf>>, <<asiprintf>>, <<siprintf>>, <<sniprintf>>---format output
+<<siprintf>>---write formatted output (integer only)
INDEX
- fiprintf
-INDEX
- iprintf
-INDEX
- asiprintf
-INDEX
siprintf
-INDEX
- sniprintf
ANSI_SYNOPSIS
#include <stdio.h>
- int iprintf(const char *<[format]> [, <[arg]>, ...]);
- int fiprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
int siprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]);
- int asiprintf(char **<[strp]>, const char *<[format]> [, <[arg]>, ...]);
- int sniprintf(char *<[str]>, size_t <[size]>, const char *<[format]>
- [, <[arg]>, ...]);
TRAD_SYNOPSIS
- #include <stdio.h>
-
- int iprintf(<[format]> [, <[arg]>, ...])
- char *<[format]>;
-
- int fiprintf(<[fd]>, <[format]> [, <[arg]>, ...]);
- FILE *<[fd]>;
- char *<[format]>;
-
- int asiprintf(<[strp]>, <[format]> [, <[arg]>, ...]);
- char **<[strp]>;
- char *<[format]>;
-
- int siprintf(<[str]>, <[format]> [, <[arg]>, ...]);
- char *<[str]>;
- char *<[format]>;
+ #include <stdio.h>
- int sniprintf(<[str]>, size_t <[size]>, <[format]> [, <[arg]>, ...]);
- char *<[str]>;
- size_t <[size]>;
- char *<[format]>;
+ int siprintf(<[str]>, <[format]>, [, <[arg]>, ...])
+ char *<[str]>;
+ const char *<[format]>;
DESCRIPTION
- <<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>,
- <<asiprintf>>, are the same as <<printf>>, <<fprintf>>,
- <<sprintf>>, <<snprintf>>, and <<asprintf>>, respectively,
- only that they restrict usage to non-floating-point format
- specifiers.
+<<siprintf>> is a restricted version of <<sprintf>>: it has the same
+arguments and behavior, save that it cannot perform any floating-point
+formatting: the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers
+are not recognized.
RETURNS
-<<siprintf>> and <<asiprintf>> return the number of bytes in the output string,
-save that the concluding <<NULL>> is not counted.
-<<iprintf>> and <<fiprintf>> return the number of characters transmitted.
-If an error occurs, <<iprintf>> and <<fiprintf>> return <<EOF>> and
-<<asiprintf>> returns -1. No error returns occur for <<siprintf>>.
+ <<siprintf>> returns the number of bytes in the output string,
+ save that the concluding <<NULL>> is not counted.
+ <<siprintf>> returns when the end of the format string is
+ encountered.
PORTABILITY
-<<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>, and <<asprintf>>
-are newlib extensions.
+<<siprintf>> is not required by ANSI C.
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
@@ -96,18 +64,18 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <limits.h>
#include "local.h"
+#ifndef _REENT_ONLY
+
int
#ifdef _HAVE_STDC
-_DEFUN(_siprintf_r, (ptr, str, fmt),
- struct _reent *ptr _AND
- char *str _AND
+_DEFUN(siprintf, (str, fmt),
+ char *str _AND
_CONST char *fmt _DOTS)
#else
-_siprintf_r(ptr, str, fmt, va_alist)
- struct _reent *ptr;
- char *str;
- _CONST char *fmt;
- va_dcl
+siprintf(str, fmt, va_alist)
+ char *str;
+ _CONST char *fmt;
+ va_dcl
#endif
{
int ret;
@@ -123,24 +91,26 @@ _siprintf_r(ptr, str, fmt, va_alist)
#else
va_start (ap);
#endif
- ret = _vfiprintf_r (ptr, &f, fmt, ap);
+ ret = vfiprintf (&f, fmt, ap);
va_end (ap);
*f._p = 0;
return (ret);
}
-#ifndef _REENT_ONLY
+#endif /* ! _REENT_ONLY */
int
#ifdef _HAVE_STDC
-_DEFUN(siprintf, (str, fmt),
- char *str _AND
+_DEFUN(_siprintf_r, (rptr, str, fmt),
+ struct _reent *rptr _AND
+ char *str _AND
_CONST char *fmt _DOTS)
#else
-siprintf(str, fmt, va_alist)
- char *str;
- _CONST char *fmt;
- va_dcl
+_siprintf_r(rptr, str, fmt, va_alist)
+ struct _reent *rptr;
+ char *str;
+ _CONST char *fmt;
+ va_dcl
#endif
{
int ret;
@@ -156,10 +126,9 @@ siprintf(str, fmt, va_alist)
#else
va_start (ap);
#endif
- ret = _vfiprintf_r (_REENT, &f, fmt, ap);
+ ret = _vfiprintf_r (rptr, &f, fmt, ap);
va_end (ap);
*f._p = 0;
return (ret);
}
-#endif
diff --git a/newlib/libc/stdio/siscanf.c b/newlib/libc/stdio/siscanf.c
deleted file mode 100644
index 694750dae..000000000
--- a/newlib/libc/stdio/siscanf.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
-FUNCTION
-<<iscanf>>, <<fiscanf>>, <<siscanf>>---scan and format non-floating input
-
-INDEX
- iscanf
-INDEX
- fiscanf
-INDEX
- siscanf
-
-ANSI_SYNOPSIS
- #include <stdio.h>
-
- int iscanf(const char *<[format]> [, <[arg]>, ...]);
- int fiscanf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
- int siscanf(const char *<[str]>, const char *<[format]>
- [, <[arg]>, ...]);
-
- int _iscanf_r(struct _reent *<[ptr]>, const char *<[format]>
- [, <[arg]>, ...]);
- int _fiscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]>
- [, <[arg]>, ...]);
- int _siscanf_r(struct _reent *<[ptr]>, const char *<[str]>,
- const char *<[format]> [, <[arg]>, ...]);
-
-
-TRAD_SYNOPSIS
- #include <stdio.h>
-
- int iscanf(<[format]> [, <[arg]>, ...])
- char *<[format]>;
-
- int fiscanf(<[fd]>, <[format]> [, <[arg]>, ...]);
- FILE *<[fd]>;
- char *<[format]>;
-
- int siscanf(<[str]>, <[format]> [, <[arg]>, ...]);
- char *<[str]>;
- char *<[format]>;
-
- int _iscanf_r(<[ptr]>, <[format]> [, <[arg]>, ...])
- struct _reent *<[ptr]>;
- char *<[format]>;
-
- int _fiscanf_r(<[ptr]>, <[fd]>, <[format]> [, <[arg]>, ...]);
- struct _reent *<[ptr]>;
- FILE *<[fd]>;
- char *<[format]>;
-
- int _siscanf_r(<[ptr]>, <[str]>, <[format]> [, <[arg]>, ...]);
- struct _reent *<[ptr]>;
- char *<[str]>;
- char *<[format]>;
-
-
-DESCRIPTION
- <<iscanf>>, <<fiscanf>>, and <<siscanf>> are the same as
- <<scanf>>, <<fscanf>>, and <<sscanf>> respectively, only that
- they restrict the available formats to non-floating-point
- format specifiers.
-
- The routines <<_iscanf_r>>, <<_fiscanf_r>>, and <<_siscanf_r>> are reentrant
- versions of <<iscanf>>, <<fiscanf>>, and <<siscanf>> that take an additional
- first argument pointing to a reentrancy structure.
-
-RETURNS
- <<iscanf>> returns the number of input fields successfully
- scanned, converted and stored; the return value does
- not include scanned fields which were not stored.
-
- If <<iscanf>> attempts to read at end-of-file, the return
- value is <<EOF>>.
-
- If no fields were stored, the return value is <<0>>.
-
-PORTABILITY
-<<iscanf>>, <<fiscanf>>, and <<siscanf>> are newlib extensions.
-
-Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
-<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
-*/
-
-#include <_ansi.h>
-#include <reent.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef _HAVE_STDC
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "local.h"
-
-/* | ARGSUSED */
-/*SUPPRESS 590*/
-static _READ_WRITE_RETURN_TYPE
-_DEFUN(eofread, (cookie, buf, len),
- _PTR cookie _AND
- char *buf _AND
- int len)
-{
- return 0;
-}
-
-#ifndef _REENT_ONLY
-
-#ifdef _HAVE_STDC
-int
-_DEFUN(siscanf, (str, fmt),
- _CONST char *str _AND
- _CONST char *fmt _DOTS)
-#else
-int
-siscanf(str, fmt, va_alist)
- _CONST char *str;
- _CONST char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
- FILE f;
-
- f._flags = __SRD | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._r = strlen (str);
- f._read = eofread;
- f._ub._base = NULL;
- f._lb._base = NULL;
- f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = __svfiscanf_r (_REENT, &f, fmt, ap);
- va_end (ap);
- return ret;
-}
-
-#endif /* !_REENT_ONLY */
-
-#ifdef _HAVE_STDC
-int
-_DEFUN(_siscanf_r, (ptr, str, fmt),
- struct _reent *ptr _AND
- _CONST char *str _AND
- _CONST char *fmt _DOTS)
-#else
-int
-_siscanf_r(ptr, str, fmt, va_alist)
- struct _reent *ptr;
- _CONST char *str;
- _CONST char *fmt;
- va_dcl
-#endif
-{
- int ret;
- va_list ap;
- FILE f;
-
- f._flags = __SRD | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._r = strlen (str);
- f._read = eofread;
- f._ub._base = NULL;
- f._lb._base = NULL;
- f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = __svfiscanf_r (ptr, &f, fmt, ap);
- va_end (ap);
- return ret;
-}
diff --git a/newlib/libc/stdio/sniprintf.c b/newlib/libc/stdio/sniprintf.c
deleted file mode 100644
index 7650cd080..000000000
--- a/newlib/libc/stdio/sniprintf.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* This code created by modifying snprintf.c so copyright inherited. */
-
-#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 (_sniprintf_r, (ptr, str, size, fmt),
- struct _reent *ptr _AND
- char *str _AND
- size_t size _AND
- _CONST char *fmt _DOTS)
-#else
-_sniprintf_r (ptr, str, size, fmt, va_alist)
- struct _reent *ptr;
- char *str;
- size_t size;
- _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 = (size > 0 ? size - 1 : 0);
- f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = _vfiprintf_r (ptr, &f, fmt, ap);
- va_end (ap);
- if (size > 0)
- *f._p = 0;
- return (ret);
-}
-
-#ifndef _REENT_ONLY
-
-int
-#ifdef _HAVE_STDC
-_DEFUN (sniprintf, (str, size, fmt),
- char *str _AND
- size_t size _AND
- _CONST char *fmt _DOTS)
-#else
-sniprintf (str, size, fmt, va_alist)
- char *str;
- size_t size;
- _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 = (size > 0 ? size - 1 : 0);
- f._file = -1; /* No file. */
-#ifdef _HAVE_STDC
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
- ret = _vfiprintf_r (_REENT, &f, fmt, ap);
- va_end (ap);
- if (size > 0)
- *f._p = 0;
- return (ret);
-}
-
-#endif
diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c
index 346749a68..8ee530730 100644
--- a/newlib/libc/stdio/sprintf.c
+++ b/newlib/libc/stdio/sprintf.c
@@ -37,8 +37,7 @@ ANSI_SYNOPSIS
int fprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
int sprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]);
int asprintf(char **<[strp]>, const char *<[format]> [, <[arg]>, ...]);
- int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]>
- [, <[arg]>, ...]);
+ int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]> [, <[arg]>, ...]);
TRAD_SYNOPSIS
#include <stdio.h>
diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c
index 5ad39d8b7..687f53edf 100644
--- a/newlib/libc/stdio/sscanf.c
+++ b/newlib/libc/stdio/sscanf.c
@@ -34,12 +34,10 @@ ANSI_SYNOPSIS
int sscanf(const char *<[str]>, const char *<[format]>
[, <[arg]>, ...]);
- int _scanf_r(struct _reent *<[ptr]>, const char *<[format]>
- [, <[arg]>, ...]);
- int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]>
- [, <[arg]>, ...]);
- int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>,
- const char *<[format]> [, <[arg]>, ...]);
+ int _scanf_r(struct _reent *<[ptr]>, const char *<[format]> [, <[arg]>, ...]);
+ int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
+ int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>, const char *<[format]>
+ [, <[arg]>, ...]);
TRAD_SYNOPSIS
diff --git a/newlib/libc/stdio/stdio.tex b/newlib/libc/stdio/stdio.tex
index 9c2ca0f5d..728831cd5 100644
--- a/newlib/libc/stdio/stdio.tex
+++ b/newlib/libc/stdio/stdio.tex
@@ -25,7 +25,6 @@ structure.
@menu
* clearerr:: Clear file or stream error indicator
-* dprintf:: Print to a file descriptor
* fclose:: Close a file
* fcloseall:: Close all files
* feof:: Test for end of file
@@ -35,6 +34,7 @@ structure.
* fgetpos:: Record position in a stream or file
* fgets:: Get character string from a file or stream
* fileno:: Get file descriptor associated with stream
+* fiprintf:: Write formatted output to file (integer only)
* fopen:: Open a file
* fdopen:: Turn an open file into a stream
* fputc:: Write a character on a stream or file
@@ -53,6 +53,7 @@ structure.
* getline:: Get character string from a file or stream
* gets:: Get character string from standard input (obsolete)
* getw:: Get a word (int) from a file or stream
+* iprintf:: Write formatted output (integer only)
* mktemp:: Generate unused file name
* perror:: Print an error message on standard error
* putc:: Write a character on a stream or file (macro)
@@ -68,14 +69,11 @@ structure.
* setbuffer:: Specify full buffering for a file or stream with size
* setlinebuf:: Specify line buffering for a file or stream
* setvbuf:: Specify buffering for a file or stream
+* siprintf:: Write formatted output (integer only)
* printf:: Write formatted output
* scanf:: Scan and format input
-* iprintf:: Write formatted output (integer only)
-* iscanf:: Scan and format input (integer only)
* tmpfile:: Create a temporary file
* tmpnam:: Generate name for a temporary file
-* viprintf:: Format variable argument list for non-floating-point output
-* viscanf:: Scan variable format list for non-floating-point input
* vprintf:: Format variable argument list
* vscanf:: Format variable argument list
@end menu
@@ -84,9 +82,6 @@ structure.
@include stdio/clearerr.def
@page
-@include stdio/dprintf.def
-
-@page
@include stdio/fclose.def
@page
@@ -114,6 +109,9 @@ structure.
@include stdio/fileno.def
@page
+@include stdio/fiprintf.def
+
+@page
@include stdio/fopen.def
@page
@@ -168,6 +166,9 @@ structure.
@include stdio/getw.def
@page
+@include stdio/iprintf.def
+
+@page
@include stdio/mktemp.def
@page
@@ -213,17 +214,14 @@ structure.
@include stdio/setvbuf.def
@page
+@include stdio/siprintf.def
+
+@page
@include stdio/sprintf.def
@page
@include stdio/sscanf.def
-@page
-@include stdio/siprintf.def
-
-@page
-@include stdio/siscanf.def
-
@page
@include stdio/tmpfile.def
@@ -235,10 +233,3 @@ structure.
@page
@include stdio/vfscanf.def
-
-@page
-@include stdio/viprintf.def
-
-@page
-@include stdio/viscanf.def
-
diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c
index fc6fa3160..9ccd02766 100644
--- a/newlib/libc/stdio/ungetc.c
+++ b/newlib/libc/stdio/ungetc.c
@@ -77,14 +77,14 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
if (c == EOF)
return (EOF);
+ _flockfile (fp);
+
/* Ensure stdio has been initialized.
??? Might be able to remove this as some other stdio routine should
have already been called to get the char we are un-getting. */
- CHECK_INIT (rptr);
+ CHECK_INIT (fp);
- _flockfile (fp);
-
/* After ungetc, we won't be at eof anymore */
fp->_flags &= ~__SEOF;
diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c
deleted file mode 100644
index 721d6fb29..000000000
--- a/newlib/libc/stdio/vasiprintf.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-/* This code was based on vsiprintf.c */
-/* doc in vfprintf.c */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "%W% (Berkeley) %G%";
-#endif /* LIBC_SCCS and not lint */
-
-#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
- 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);
- *f._p = 0;
- *strp = f._bf._base;
- return ret;
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-_DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap),
- struct _reent *ptr _AND
- char **strp _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 (ptr, &f, fmt, ap);
- *f._p = 0;
- *strp = f._bf._base;
- return ret;
-}
-
diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c
deleted file mode 100644
index acd193a13..000000000
--- a/newlib/libc/stdio/vdprintf.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2005 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>
-#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)
-{
- 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)
-{
- _REENT_SMALL_CHECK_INIT (_REENT);
- return _vdprintf_r (_REENT, fd, format, ap);
-}
-
-#endif /* ! _REENT_ONLY */
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index a8c1f9bca..9e970cef3 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -54,19 +54,18 @@ ANSI_SYNOPSIS
int vfprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>);
int vsprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>);
int vasprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>);
- int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>,
- va_list <[list]>);
+ int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, va_list <[list]>);
int _vprintf_r(struct _reent *<[reent]>, const char *<[fmt]>,
va_list <[list]>);
int _vfprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>,
va_list <[list]>);
- int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>,
- const char *<[fmt]>, va_list <[list]>);
- int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>,
- const char *<[fmt]>, va_list <[list]>);
- int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>,
- const char *<[fmt]>, va_list <[list]>);
+ int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>, const char *<[fmt]>,
+ va_list <[list]>);
+ int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, const char *<[fmt]>,
+ va_list <[list]>);
+ int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>, const char *<[fmt]>,
+ va_list <[list]>);
TRAD_SYNOPSIS
#include <stdio.h>
@@ -158,7 +157,6 @@ static char *rcsid = "$Id$";
*
* This code is large and complicated...
*/
-#include <newlib.h>
#ifdef INTEGER_ONLY
#define VFPRINTF vfiprintf
@@ -178,6 +176,8 @@ static char *rcsid = "$Id$";
#include <_ansi.h>
#include <reent.h>
+#include <newlib.h>
+#include <reent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -533,8 +533,8 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
(u_long)GET_ARG (N, ap, u_int))
#endif
- CHECK_INIT (data);
_flockfile (fp);
+ CHECK_INIT (fp);
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
if (cantwrite (fp)) {
@@ -801,7 +801,6 @@ reswitch: switch (ch) {
case 'e':
case 'E':
case 'f':
- case 'F':
case 'g':
case 'G':
if (prec == -1) {
@@ -821,18 +820,12 @@ reswitch: switch (ch) {
if (isinf (_fpvalue)) {
if (_fpvalue < 0)
sign = '-';
- if (ch == 'E' || ch == 'F' || ch == 'G')
- cp = "INF";
- else
- cp = "inf";
+ cp = "Inf";
size = 3;
break;
}
if (isnan (_fpvalue)) {
- if (ch == 'E' || ch == 'F' || ch == 'G')
- cp = "NAN";
- else
- cp = "nan";
+ cp = "NaN";
size = 3;
break;
}
@@ -850,18 +843,12 @@ reswitch: switch (ch) {
if (tmp == 2) {
if (_fpvalue < 0)
sign = '-';
- if (ch == 'E' || ch == 'F' || ch == 'G')
- cp = "INF";
- else
- cp = "inf";
+ cp = "Inf";
size = 3;
break;
}
if (tmp == 1) {
- if (ch == 'E' || ch == 'F' || ch == 'G')
- cp = "NAN";
- else
- cp = "nan";
+ cp = "NaN";
size = 3;
break;
}
@@ -1274,11 +1261,7 @@ _DEFUN(cvt, (data, value, ndigits, flags, sign, decpt, ch, length),
#ifdef _NO_LONGDBL
union double_union tmp;
#else
- union
- {
- struct ldieee ieee;
- _LONG_DOUBLE val;
- } ld;
+ struct ldieee *ldptr;
#endif
if (ch == 'f') {
@@ -1305,8 +1288,8 @@ _DEFUN(cvt, (data, value, ndigits, flags, sign, decpt, ch, length),
digits = _dtoa_r (data, value, mode, ndigits, decpt, &dsgn, &rve);
#else /* !_NO_LONGDBL */
- ld.val = value;
- if (ld.ieee.sign) { /* this will check for < 0 and -0.0 */
+ ldptr = (struct ldieee *)&value;
+ if (ldptr->sign) { /* this will check for < 0 and -0.0 */
value = -value;
*sign = '-';
} else
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 4788938c9..76561fe4a 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -37,8 +37,8 @@ ANSI_SYNOPSIS
va_list <[list]>);
int _vfscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>,
va_list <[list]>);
- int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>,
- const char *<[fmt]>, va_list <[list]>);
+ int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>, const char *<[fmt]>,
+ va_list <[list]>);
TRAD_SYNOPSIS
#include <stdio.h>
@@ -119,23 +119,11 @@ Supporting OS subroutines required:
#endif
#include "local.h"
-#ifdef INTEGER_ONLY
-#define VFSCANF vfiscanf
-#define _VFSCANF_R _vfiscanf_r
-#define __SVFSCANF __svfiscanf
-#define __SVFSCANF_R __svfiscanf_r
-#else
-#define VFSCANF vfscanf
-#define _VFSCANF_R _vfscanf_r
-#define __SVFSCANF __svfscanf
-#define __SVFSCANF_R __svfscanf_r
-#ifndef NO_FLOATING_POINT
+#ifndef NO_FLOATING_POINT
#define FLOATING_POINT
#endif
-#endif
#ifdef FLOATING_POINT
-#include <math.h>
#include <float.h>
/* Currently a test is made to see if long double processing is warranted.
@@ -226,40 +214,39 @@ typedef unsigned long long u_long_long;
#ifndef _REENT_ONLY
int
-_DEFUN(VFSCANF, (fp, fmt, ap),
+_DEFUN(vfscanf, (fp, fmt, ap),
register FILE *fp _AND
_CONST char *fmt _AND
va_list ap)
{
- CHECK_INIT(_REENT);
- return __SVFSCANF_R (_REENT, fp, fmt, ap);
+ CHECK_INIT(fp);
+ return __svfscanf_r (_REENT, fp, fmt, ap);
}
int
-_DEFUN(__SVFSCANF, (fp, fmt0, ap),
+_DEFUN(__svfscanf, (fp, fmt0, ap),
register FILE *fp _AND
char _CONST *fmt0 _AND
va_list ap)
{
- return __SVFSCANF_R (_REENT, fp, fmt0, ap);
+ return __svfscanf_r (_REENT, fp, fmt0, ap);
}
#endif /* !_REENT_ONLY */
int
-_DEFUN(_VFSCANF_R, (data, fp, fmt, ap),
+_DEFUN(_vfscanf_r, (data, fp, fmt, ap),
struct _reent *data _AND
register FILE *fp _AND
_CONST char *fmt _AND
va_list ap)
{
- CHECK_INIT(data);
- return __SVFSCANF_R (data, fp, fmt, ap);
+ return __svfscanf_r (data, fp, fmt, ap);
}
int
-_DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
+_DEFUN(__svfscanf_r, (rptr, fp, fmt0, ap),
struct _reent *rptr _AND
register FILE *fp _AND
char _CONST *fmt0 _AND
@@ -778,7 +765,6 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
{
/* scan an integer as if by strtol/strtoul */
unsigned width_left = 0;
- int skips = 0;
#ifdef hardway
if (width == 0 || width > sizeof (buf) - 1)
#else
@@ -827,7 +813,6 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
width_left--;
width++;
}
- ++skips;
goto skip;
/* 1 through 7 always legal */
@@ -972,7 +957,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
}
nassigned++;
}
- nread += p - buf + skips;
+ nread += p - buf;
break;
}
#ifdef FLOATING_POINT
@@ -987,7 +972,6 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
long zeroes, exp_adjust;
char *exp_start = NULL;
unsigned width_left = 0;
- int nancount = 0;
#ifdef hardway
if (width == 0 || width > sizeof (buf) - 1)
#else
@@ -1010,6 +994,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
*/
switch (c)
{
+
case '0':
if (flags & NDIGITS)
{
@@ -1032,12 +1017,8 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
case '7':
case '8':
case '9':
- if (nancount == 0)
- {
- flags &= ~(SIGNOK | NDIGITS);
- goto fok;
- }
- break;
+ flags &= ~(SIGNOK | NDIGITS);
+ goto fok;
case '+':
case '-':
@@ -1047,30 +1028,6 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
goto fok;
}
break;
- case 'n':
- case 'N':
- if (nancount == 0
- && (flags & (SIGNOK | NDIGITS | DPTOK | EXPOK)) ==
- (SIGNOK | NDIGITS | DPTOK | EXPOK))
- {
- flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS);
- nancount = 1;
- goto fok;
- }
- else if (nancount == 2)
- {
- nancount = 3;
- goto fok;
- }
- break;
- case 'a':
- case 'A':
- if (nancount == 1)
- {
- nancount = 2;
- goto fok;
- }
- break;
case '.':
if (flags & DPTOK)
{
@@ -1112,24 +1069,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
}
if (zeroes)
flags &= ~NDIGITS;
- /* We may have a 'N' or possibly even a 'Na' as the start of 'NaN',
- only to run out of chars before it was complete (or having
- encountered a non- matching char). So check here if we have an
- outstanding nancount, and if so put back the chars we did
- swallow and treat as a failed match. */
- if (nancount && nancount != 3)
- {
- /* Ok... what are we supposed to do in the event that the
- __srefill call above was triggered in the middle of the partial
- 'NaN' and so we can't put it all back? */
- while (nancount-- && (p > buf))
- {
- ungetc (*(u_char *)--p, fp);
- --nread;
- }
- goto match_failure;
- }
- /*
+ /*
* If no digits, might be missing exponent digits
* (just give back the exponent) or might be missing
* regular digits, but had sign and/or decimal point.
@@ -1141,7 +1081,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
/* no digits at all */
while (p > buf)
{
- ungetc (*(u_char *)--p, fp);
+ ungetc (*(u_char *)-- p, fp);
--nread;
}
goto match_failure;
@@ -1210,10 +1150,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
else
{
flp = va_arg (ap, float *);
- if (isnan (res))
- *flp = nanf (NULL);
- else
- *flp = res;
+ *flp = res;
}
nassigned++;
}
@@ -1230,3 +1167,107 @@ all_done:
_funlockfile (fp);
return nassigned;
}
+
+/*
+ * Fill in the given table from the scanset at the given format
+ * (just after `['). Return a pointer to the character past the
+ * closing `]'. The table has a 1 wherever characters should be
+ * considered part of the scanset.
+ */
+
+/*static*/
+u_char *
+_DEFUN(__sccl, (tab, fmt),
+ register char *tab _AND
+ register u_char *fmt)
+{
+ register int c, n, v;
+
+ /* first `clear' the whole table */
+ c = *fmt++; /* first char hat => negated scanset */
+ if (c == '^')
+ {
+ v = 1; /* default => accept */
+ c = *fmt++; /* get new first char */
+ }
+ else
+ v = 0; /* default => reject */
+ /* should probably use memset here */
+ for (n = 0; n < 256; n++)
+ tab[n] = v;
+ if (c == 0)
+ return fmt - 1; /* format ended before closing ] */
+
+ /*
+ * Now set the entries corresponding to the actual scanset to the
+ * opposite of the above.
+ *
+ * The first character may be ']' (or '-') without being special; the
+ * last character may be '-'.
+ */
+
+ v = 1 - v;
+ for (;;)
+ {
+ tab[c] = v; /* take character c */
+ doswitch:
+ n = *fmt++; /* and examine the next */
+ switch (n)
+ {
+
+ case 0: /* format ended too soon */
+ return fmt - 1;
+
+ case '-':
+ /*
+ * A scanset of the form [01+-] is defined as `the digit 0, the
+ * digit 1, the character +, the character -', but the effect of a
+ * scanset such as [a-zA-Z0-9] is implementation defined. The V7
+ * Unix scanf treats `a-z' as `the letters a through z', but treats
+ * `a-a' as `the letter a, the character -, and the letter a'.
+ *
+ * For compatibility, the `-' is not considerd to define a range if
+ * the character following it is either a close bracket (required by
+ * ANSI) or is not numerically greater than the character we just
+ * stored in the table (c).
+ */
+ n = *fmt;
+ if (n == ']' || n < c)
+ {
+ c = '-';
+ break; /* resume the for(;;) */
+ }
+ fmt++;
+ do
+ { /* fill in the range */
+ tab[++c] = v;
+ }
+ while (c < n);
+#if 1 /* XXX another disgusting compatibility hack */
+ /*
+ * Alas, the V7 Unix scanf also treats formats such
+ * as [a-c-e] as `the letters a through e'. This too
+ * is permitted by the standard....
+ */
+ goto doswitch;
+#else
+ c = *fmt++;
+ if (c == 0)
+ return fmt - 1;
+ if (c == ']')
+ return fmt;
+#endif
+
+ break;
+
+
+ case ']': /* end of scanset */
+ return fmt;
+
+ default: /* just another character */
+ c = n;
+ break;
+ }
+ }
+ /* NOTREACHED */
+}
diff --git a/newlib/libc/stdio/viprintf.c b/newlib/libc/stdio/viprintf.c
deleted file mode 100644
index cea96d3db..000000000
--- a/newlib/libc/stdio/viprintf.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
-FUNCTION
-<<viprintf>>, <<vfiprintf>>, <<vsiprintf>>---format argument list
-
-INDEX
- viprintf
-INDEX
- vfiprintf
-INDEX
- vsiprintf
-INDEX
- vsniprintf
-
-ANSI_SYNOPSIS
- #include <stdio.h>
- #include <stdarg.h>
- int viprintf(const char *<[fmt]>, va_list <[list]>);
- int vfiprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>);
- int vsiprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>);
- int vasiprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>);
- int vsniprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>,
- va_list <[list]>);
-
- int _viprintf_r(struct _reent *<[reent]>, const char *<[fmt]>,
- va_list <[list]>);
- int _vfiprintf_r(struct _reent *<[reent]>, FILE *<[fp]>,
- const char *<[fmt]>, va_list <[list]>);
- int _vasiprintf_r(struct _reent *<[reent]>, char **<[str]>,
- const char *<[fmt]>, va_list <[list]>);
- int _vsiprintf_r(struct _reent *<[reent]>, char *<[str]>,
- const char *<[fmt]>, va_list <[list]>);
- int _vsniprintf_r(struct _reent *<[reent]>, char *<[str]>, size_t <[size]>,
- const char *<[fmt]>, va_list <[list]>);
-
-TRAD_SYNOPSIS
- #include <stdio.h>
- #include <varargs.h>
- int viprintf( <[fmt]>, <[list]>)
- char *<[fmt]>;
- va_list <[list]>;
-
- int vfiprintf(<[fp]>, <[fmt]>, <[list]>)
- FILE *<[fp]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int vasiprintf(<[strp]>, <[fmt]>, <[list]>)
- char **<[strp]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int vsiprintf(<[str]>, <[fmt]>, <[list]>)
- char *<[str]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int vsniprintf(<[str]>, <[size]>, <[fmt]>, <[list]>)
- char *<[str]>;
- size_t <[size]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _viprintf_r(<[reent]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _vfiprintf_r(<[reent]>, <[fp]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- FILE *<[fp]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _vasiprintf_r(<[reent]>, <[strp]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- char **<[strp]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _vsiprintf_r(<[reent]>, <[str]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- char *<[str]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _vsniprintf_r(<[reent]>, <[str]>, <[size]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- char *<[str]>;
- size_t <[size]>;
- char *<[fmt]>;
- va_list <[list]>;
-
-DESCRIPTION
-<<viprintf>>, <<vfiprintf>>, <<vasiprintf>>, <<vsiprintf>> and
-<<vsniprintf>> are (respectively) variants of <<iprintf>>, <<fiprintf>>,
-<<asiprintf>>, <<siprintf>>, and <<sniprintf>>. They differ only in
-restricting the caller to use non-floating-point format specifiers.
-
-RETURNS
-The return values are consistent with the corresponding functions:
-<<vasiprintf>>/<<vsiprintf>> returns the number of bytes in the output string,
-save that the concluding <<NULL>> is not counted.
-<<viprintf>> and <<vfiprintf>> return the number of characters transmitted.
-If an error occurs, <<viprintf>> and <<vfiprintf>> return <<EOF>> and
-<<vasiprintf>> returns -1. No error returns occur for <<vsiprintf>>.
-
-PORTABILITY
-<<viprintf>>, <<vfiprintf>>, <<vasiprintf>>, <<vsiprintf>> and <<vsniprintf>>
-are newlib extensions.
-
-Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
-<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
-*/
-
-#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
-
-int
-_DEFUN(viprintf, (fmt, ap),
- _CONST char *fmt _AND
- va_list ap)
-{
- _REENT_SMALL_CHECK_INIT (_REENT);
- return _vfiprintf_r (_REENT, _stdout_r (_REENT), fmt, ap);
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-_DEFUN(_viprintf_r, (ptr, fmt, ap),
- struct _reent *ptr _AND
- _CONST char *fmt _AND
- va_list ap)
-{
- _REENT_SMALL_CHECK_INIT (ptr);
- return _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap);
-}
diff --git a/newlib/libc/stdio/viscanf.c b/newlib/libc/stdio/viscanf.c
deleted file mode 100644
index f335f69ff..000000000
--- a/newlib/libc/stdio/viscanf.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * Code created by modifying iscanf.c which has following copyright.
- *
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
-FUNCTION
-<<viscanf>>, <<vfiscanf>>, <<vsiscanf>>---format argument list
-
-INDEX
- viscanf
-INDEX
- vfiscanf
-INDEX
- vsiscanf
-
-ANSI_SYNOPSIS
- #include <stdio.h>
- #include <stdarg.h>
- int viscanf(const char *<[fmt]>, va_list <[list]>);
- int vfiscanf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>);
- int vsiscanf(const char *<[str]>, const char *<[fmt]>, va_list <[list]>);
-
- int _viscanf_r(struct _reent *<[reent]>, const char *<[fmt]>,
- va_list <[list]>);
- int _vfiscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>,
- va_list <[list]>);
- int _vsiscanf_r(struct _reent *<[reent]>, const char *<[str]>,
- const char *<[fmt]>, va_list <[list]>);
-
-TRAD_SYNOPSIS
- #include <stdio.h>
- #include <varargs.h>
- int viscanf( <[fmt]>, <[ist]>)
- char *<[fmt]>;
- va_list <[list]>;
-
- int vfiscanf( <[fp]>, <[fmt]>, <[list]>)
- FILE *<[fp]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int vsiscanf( <[str]>, <[fmt]>, <[list]>)
- char *<[str]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _viscanf_r( <[reent]>, <[fmt]>, <[ist]>)
- struct _reent *<[reent]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _vfiscanf_r( <[reent]>, <[fp]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- FILE *<[fp]>;
- char *<[fmt]>;
- va_list <[list]>;
-
- int _vsiscanf_r( <[reent]>, <[str]>, <[fmt]>, <[list]>)
- struct _reent *<[reent]>;
- char *<[str]>;
- char *<[fmt]>;
- va_list <[list]>;
-
-DESCRIPTION
-<<viscanf>>, <<vfiscanf>>, and <<vsiscanf>> are (respectively) variants
-of <<iscanf>>, <<fiscanf>>, and <<siscanf>>. They differ only in
-allowing their caller to pass the variable argument list as a
-<<va_list>> object (initialized by <<va_start>>) rather than
-directly accepting a variable number of arguments.
-
-RETURNS
-The return values are consistent with the corresponding functions:
-<<viscanf>> returns the number of input fields successfully scanned,
-converted, and stored; the return value does not include scanned
-fields which were not stored.
-
-If <<viscanf>> attempts to read at end-of-file, the return value
-is <<EOF>>.
-
-If no fields were stored, the return value is <<0>>.
-
-The routines <<_viscanf_r>>, <<_vfiscanf_f>>, and <<_vsiscanf_r>> are
-reentrant versions which take an additional first parameter which points to the
-reentrancy structure.
-
-PORTABILITY
-These are newlib extensions.
-
-Supporting OS subroutines required:
-*/
-
-#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
-
-int
-_DEFUN(viscanf, (fmt, ap),
- _CONST char *fmt _AND
- va_list ap)
-{
- _REENT_SMALL_CHECK_INIT (_REENT);
- return __svfiscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-_DEFUN(_viscanf_r, (ptr, fmt, ap),
- struct _reent *ptr _AND
- _CONST char *fmt _AND
- va_list ap)
-{
- _REENT_SMALL_CHECK_INIT (ptr);
- return __svfiscanf_r (ptr, _stdin_r (ptr), fmt, ap);
-}
-
diff --git a/newlib/libc/stdio/vprintf.c b/newlib/libc/stdio/vprintf.c
index 69edc87ae..8a1faaed1 100644
--- a/newlib/libc/stdio/vprintf.c
+++ b/newlib/libc/stdio/vprintf.c
@@ -33,7 +33,7 @@ _DEFUN(vprintf, (fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- _REENT_SMALL_CHECK_INIT (_REENT);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (_REENT));
return _vfprintf_r (_REENT, _stdout_r (_REENT), fmt, ap);
}
@@ -45,6 +45,6 @@ _DEFUN(_vprintf_r, (ptr, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdout_r (ptr));
return _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
}
diff --git a/newlib/libc/stdio/vscanf.c b/newlib/libc/stdio/vscanf.c
index e559b77a8..a62b0a8c3 100644
--- a/newlib/libc/stdio/vscanf.c
+++ b/newlib/libc/stdio/vscanf.c
@@ -34,7 +34,7 @@ _DEFUN(vscanf, (fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- _REENT_SMALL_CHECK_INIT (_REENT);
+ _REENT_SMALL_CHECK_INIT (_stdin_r (_REENT));
return __svfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap);
}
@@ -46,7 +46,7 @@ _DEFUN(_vscanf_r, (ptr, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- _REENT_SMALL_CHECK_INIT (ptr);
+ _REENT_SMALL_CHECK_INIT (_stdin_r (ptr));
return __svfscanf_r (ptr, _stdin_r (ptr), fmt, ap);
}
diff --git a/newlib/libc/stdio/vsiprintf.c b/newlib/libc/stdio/vsiprintf.c
deleted file mode 100644
index c9d263803..000000000
--- a/newlib/libc/stdio/vsiprintf.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-/* doc in vfiprintf.c */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "%W% (Berkeley) %G%";
-#endif /* LIBC_SCCS and not lint */
-
-#include <_ansi.h>
-#include <reent.h>
-#include <stdio.h>
-#include <limits.h>
-#ifdef _HAVE_STDC
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifndef _REENT_ONLY
-
-int
-_DEFUN(vsiprintf, (str, fmt, ap),
- char *str _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;
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-_DEFUN(_vsiprintf_r, (ptr, str, fmt, ap),
- struct _reent *ptr _AND
- char *str _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 (ptr, &f, fmt, ap);
- *f._p = 0;
- return ret;
-}
-
diff --git a/newlib/libc/stdio/vsiscanf.c b/newlib/libc/stdio/vsiscanf.c
deleted file mode 100644
index c6201847a..000000000
--- a/newlib/libc/stdio/vsiscanf.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Code created by modifying iscanf.c which has following copyright.
- *
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <_ansi.h>
-#include <reent.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef _HAVE_STDC
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "local.h"
-
-static _READ_WRITE_RETURN_TYPE
-_DEFUN(eofread1, (cookie, buf, len),
- _PTR cookie _AND
- char *buf _AND
- int len)
-{
- return 0;
-}
-
-/*
- * vsiscanf
- */
-
-#ifndef _REENT_ONLY
-
-int
-_DEFUN(vsiscanf, (str, fmt, ap),
- _CONST char *str _AND
- _CONST char *fmt _AND
- va_list ap)
-{
- return _vsiscanf_r (_REENT, str, fmt, ap);
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-_DEFUN(_vsiscanf_r, (ptr, str, fmt, ap),
- struct _reent *ptr _AND
- _CONST char *str _AND
- _CONST char *fmt _AND
- va_list ap)
-{
- FILE f;
-
- f._flags = __SRD | __SSTR;
- f._bf._base = f._p = (unsigned char *) str;
- f._bf._size = f._r = strlen (str);
- f._read = eofread1;
- f._ub._base = NULL;
- f._lb._base = NULL;
- f._file = -1; /* No file. */
- return __svfiscanf_r (ptr, &f, fmt, ap);
-}
diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c
deleted file mode 100644
index 6a5bd45bb..000000000
--- a/newlib/libc/stdio/vsniprintf.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
-FUNCTION
-<<vsniprintf>>---write formatted output (integer only)
-
-INDEX
- vsniprintf
-
-ANSI_SYNOPSIS
- #include <stdio.h>
-
- int vsniprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, va_list <[list]>);
-
-TRAD_SYNOPSIS
- #include <stdio.h>
-
- int vsnprintf(<[str]>, <[size]>, <[fmt]>, <[list]>)
- char *<[str]>;
- size_t <[size]>;
- char *<[fmt]>;
- va_list <[list]>;
-
-DESCRIPTION
-<<vsniprintf>> is a restricted version of <<vsnprintf>>: it has the same
-arguments and behavior, save that it cannot perform any floating-point
-formatting: the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers
-are not recognized.
-
-RETURNS
- <<vsniprintf>> returns the number of bytes in the output string,
- save that the concluding <<NULL>> is not counted.
- <<vsniprintf>> returns when the end of the format string is
- encountered.
-
-PORTABILITY
-<<vsniprintf>> is not required by ANSI C.
-
-Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
-<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
-*/
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "%W% (Berkeley) %G%";
-#endif /* LIBC_SCCS and not lint */
-
-#include <_ansi.h>
-#include <reent.h>
-#include <stdio.h>
-#include <limits.h>
-#ifdef _HAVE_STDC
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifndef _REENT_ONLY
-
-int
-_DEFUN(vsniprintf, (str, size, fmt, ap),
- char *str _AND
- size_t size _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 = (size > 0 ? size - 1 : 0);
- f._file = -1; /* No file. */
- ret = _vfiprintf_r (_REENT, &f, fmt, ap);
- if (size > 0)
- *f._p = 0;
- return ret;
-}
-
-#endif /* !_REENT_ONLY */
-
-int
-_DEFUN(_vsniprintf_r, (ptr, str, size, fmt, ap),
- struct _reent *ptr _AND
- char *str _AND
- size_t size _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 = (size > 0 ? size - 1 : 0);
- f._file = -1; /* No file. */
- ret = _vfiprintf_r (ptr, &f, fmt, ap);
- if (size > 0)
- *f._p = 0;
- return ret;
-}
diff --git a/newlib/libc/stdio/wbuf.c b/newlib/libc/stdio/wbuf.c
index e7ddb4913..29dd03e37 100644
--- a/newlib/libc/stdio/wbuf.c
+++ b/newlib/libc/stdio/wbuf.c
@@ -40,7 +40,7 @@ _DEFUN(__swbuf, (c, fp),
/* Ensure stdio has been initialized. */
- CHECK_INIT (_REENT);
+ CHECK_INIT (fp);
/*
* In case we cannot write, or longjmp takes us out early,
diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c
index cf56c2abc..c1641dbe5 100644
--- a/newlib/libc/stdio/wsetup.c
+++ b/newlib/libc/stdio/wsetup.c
@@ -34,7 +34,7 @@ _DEFUN(__swsetup, (fp),
{
/* Make sure stdio is set up. */
- CHECK_INIT (_REENT);
+ CHECK_INIT (fp);
/*
* If we are not writing, we had better be reading and writing.
@@ -58,11 +58,9 @@ _DEFUN(__swsetup, (fp),
/*
* Make a buffer if necessary, then set _w.
- * A string I/O file should not explicitly allocate a buffer
- * unless asprintf is being used.
*/
- if (fp->_bf._base == NULL
- && (!(fp->_flags & __SSTR) || (fp->_flags & __SMBF)))
+ /* NOT NEEDED FOR CYGNUS SPRINTF ONLY jpg */
+ if (fp->_bf._base == NULL)
__smakebuf (fp);
if (fp->_flags & __SLBF)