diff options
Diffstat (limited to 'newlib/libc/stdio')
33 files changed, 65 insertions, 394 deletions
diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index b50b87188..4d3daaefb 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -128,8 +128,6 @@ endif !ELIX_LEVEL_2 endif !ELIX_LEVEL_1 LIBADD_OBJS = \ - $(lpfx)svfiprintf.$(oext) $(lpfx)svfprintf.$(oext) \ - $(lpfx)svfiscanf.$(oext) $(lpfx)svfscanf.$(oext) \ $(lpfx)vfiprintf.$(oext) $(lpfx)vfprintf.$(oext) \ $(lpfx)vfscanf.$(oext) $(lpfx)vfiscanf.$(oext) @@ -163,24 +161,12 @@ $(lpfx)vfprintf.$(oext): vfprintf.c $(lpfx)vfiprintf.$(oext): vfprintf.c $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@ -$(lpfx)svfprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -fshort-enums -DSTRING_ONLY -c $(srcdir)/vfprintf.c -o $@ - -$(lpfx)svfiprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfprintf.c -o $@ - $(lpfx)vfscanf.$(oext): vfscanf.c $(LIB_COMPILE) -c $(srcdir)/vfscanf.c -o $@ $(lpfx)vfiscanf.$(oext): vfscanf.c $(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfscanf.c -o $@ -$(lpfx)svfscanf.$(oext): vfscanf.c - $(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/vfscanf.c -o $@ - -$(lpfx)svfiscanf.$(oext): vfscanf.c - $(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfscanf.c -o $@ - CHEWOUT_FILES = \ clearerr.def \ diprintf.def \ @@ -288,10 +274,6 @@ $(lpfx)sprintf.$(oext): local.h $(lpfx)siscanf.$(oext): local.h $(lpfx)sscanf.$(oext): local.h $(lpfx)stdio.$(oext): local.h -$(lpfx)svfiprintf.$(oext): local.h -$(lpfx)svfiscanf.$(oext): local.h floatio.h -$(lpfx)svfprintf.$(oext): local.h -$(lpfx)svfscanf.$(oext): local.h floatio.h $(lpfx)ungetc.$(oext): local.h $(lpfx)vfiprintf.$(oext): local.h $(lpfx)vfprintf.$(oext): local.h diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index be8cd4554..3b80e35bc 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -54,11 +54,8 @@ CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru lib_a_AR = $(AR) $(ARFLAGS) -am__DEPENDENCIES_1 = $(lpfx)svfiprintf.$(oext) \ - $(lpfx)svfprintf.$(oext) $(lpfx)svfiscanf.$(oext) \ - $(lpfx)svfscanf.$(oext) $(lpfx)vfiprintf.$(oext) \ - $(lpfx)vfprintf.$(oext) $(lpfx)vfscanf.$(oext) \ - $(lpfx)vfiscanf.$(oext) +am__DEPENDENCIES_1 = $(lpfx)vfiprintf.$(oext) $(lpfx)vfprintf.$(oext) \ + $(lpfx)vfscanf.$(oext) $(lpfx)vfiscanf.$(oext) am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-fclose.$(OBJEXT) \ lib_a-fdopen.$(OBJEXT) lib_a-feof.$(OBJEXT) \ lib_a-ferror.$(OBJEXT) lib_a-fflush.$(OBJEXT) \ @@ -441,8 +438,6 @@ GENERAL_SOURCES = \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ELIX_4_SOURCES = @ELIX_LEVEL_1_TRUE@ELIX_4_SOURCES = LIBADD_OBJS = \ - $(lpfx)svfiprintf.$(oext) $(lpfx)svfprintf.$(oext) \ - $(lpfx)svfiscanf.$(oext) $(lpfx)svfscanf.$(oext) \ $(lpfx)vfiprintf.$(oext) $(lpfx)vfprintf.$(oext) \ $(lpfx)vfscanf.$(oext) $(lpfx)vfiscanf.$(oext) @@ -1350,24 +1345,12 @@ $(lpfx)vfprintf.$(oext): vfprintf.c $(lpfx)vfiprintf.$(oext): vfprintf.c $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@ -$(lpfx)svfprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -fshort-enums -DSTRING_ONLY -c $(srcdir)/vfprintf.c -o $@ - -$(lpfx)svfiprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfprintf.c -o $@ - $(lpfx)vfscanf.$(oext): vfscanf.c $(LIB_COMPILE) -c $(srcdir)/vfscanf.c -o $@ $(lpfx)vfiscanf.$(oext): vfscanf.c $(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfscanf.c -o $@ -$(lpfx)svfscanf.$(oext): vfscanf.c - $(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/vfscanf.c -o $@ - -$(lpfx)svfiscanf.$(oext): vfscanf.c - $(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfscanf.c -o $@ - .c.def: $(CHEW) < $< > $*.def 2> $*.ref touch stmp-def @@ -1405,10 +1388,6 @@ $(lpfx)sprintf.$(oext): local.h $(lpfx)siscanf.$(oext): local.h $(lpfx)sscanf.$(oext): local.h $(lpfx)stdio.$(oext): local.h -$(lpfx)svfiprintf.$(oext): local.h -$(lpfx)svfiscanf.$(oext): local.h floatio.h -$(lpfx)svfprintf.$(oext): local.h -$(lpfx)svfscanf.$(oext): local.h floatio.h $(lpfx)ungetc.$(oext): local.h $(lpfx)vfiprintf.$(oext): local.h $(lpfx)vfprintf.$(oext): local.h diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c index 97474fd1a..aab3b4410 100644 --- a/newlib/libc/stdio/asiprintf.c +++ b/newlib/libc/stdio/asiprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1990 The Regents of the University of California. + * Copyright (c) 1990, 2007 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -40,7 +40,7 @@ _DEFUN(_asiprintf_r, (ptr, strp, fmt), f._bf._size = f._w = 0; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret >= 0) { @@ -67,7 +67,7 @@ _DEFUN(asiprintf, (strp, fmt), f._bf._size = f._w = 0; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfiprintf_r (_REENT, &f, fmt, ap); + ret = _vfiprintf_r (_REENT, &f, fmt, ap); va_end (ap); if (ret >= 0) { diff --git a/newlib/libc/stdio/asniprintf.c b/newlib/libc/stdio/asniprintf.c index d4ff901e8..dd74b7c8c 100644 --- a/newlib/libc/stdio/asniprintf.c +++ b/newlib/libc/stdio/asniprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007, 2008 Eric Blake +/* Copyright (C) 2007 Eric Blake * Permission to use, copy, modify, and distribute this software * is freely granted, provided that this notice is preserved. */ @@ -48,7 +48,7 @@ _DEFUN(_asniprintf_r, (ptr, buf, lenp, fmt), f._bf._size = f._w = len; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < 0) return NULL; @@ -95,7 +95,7 @@ _DEFUN(asniprintf, (buf, lenp, fmt), f._bf._size = f._w = len; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < 0) return NULL; diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.c index bb7057a34..ef9bd8900 100644 --- a/newlib/libc/stdio/asnprintf.c +++ b/newlib/libc/stdio/asnprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007, 2008 Eric Blake +/* Copyright (C) 2007 Eric Blake * Permission to use, copy, modify, and distribute this software * is freely granted, provided that this notice is preserved. */ @@ -48,7 +48,7 @@ _DEFUN(_asnprintf_r, (ptr, buf, lenp, fmt), f._bf._size = f._w = len; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < 0) return NULL; @@ -95,7 +95,7 @@ _DEFUN(asnprintf, (buf, lenp, fmt), f._bf._size = f._w = len; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < 0) return NULL; diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 59a08c808..d72a4a7e9 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -40,7 +40,7 @@ _DEFUN(_asprintf_r, (ptr, strp, fmt), f._bf._size = f._w = 0; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret >= 0) { @@ -67,7 +67,7 @@ _DEFUN(asprintf, (strp, fmt), f._bf._size = f._w = 0; f._file = -1; /* No file. */ va_start (ap, fmt); - ret = _svfprintf_r (_REENT, &f, fmt, ap); + ret = _vfprintf_r (_REENT, &f, fmt, ap); va_end (ap); if (ret >= 0) { diff --git a/newlib/libc/stdio/dprintf.c b/newlib/libc/stdio/dprintf.c index b0eb19192..53bb50bfa 100644 --- a/newlib/libc/stdio/dprintf.c +++ b/newlib/libc/stdio/dprintf.c @@ -45,7 +45,6 @@ Supporting OS subroutines required: <<sbrk>>, <<write>>. #include <stdio.h> #include <unistd.h> #include <stdarg.h> -#include "local.h" int _DEFUN(_dprintf_r, (ptr, fd, format), diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index 33e2e7b26..24bd6c10e 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -164,8 +164,6 @@ _DEFUN(_fflush_r, (ptr, fp), fp->_p = fp->_bf._base; if (fp->_flags & __SOFF) fp->_offset = curoff; - if (HASUB (fp)) - FREEUB (ptr, fp); } else { diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 2a0d36247..247f8c6ad 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -167,7 +167,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), /* * F_SETFL doesn't change textmode. Don't mess with modes of ttys. */ - if (0 <= f && ! _isatty_r (ptr, f) + if (0 <= f && ! isatty (f) && setmode (f, oflags & (O_BINARY | O_TEXT)) == -1) f = -1; #endif diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index 816cafa76..2aa10b2c7 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -118,12 +118,9 @@ _DEFUN(_ftell_r, (ptr, fp), return -1L; } - /* Find offset of underlying I/O object, then adjust for buffered - bytes. Flush a write stream, since the offset may be altered if - the stream is appending. Do not flush a read stream, since we - must not lose the ungetc buffer. */ - if (fp->_flags & __SWR) - _fflush_r (ptr, fp); + /* Find offset of underlying I/O object, then + adjust for buffered bytes. */ + _fflush_r (ptr, fp); /* may adjust seek offset on append stream */ if (fp->_flags & __SOFF) pos = fp->_offset; else diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 5dc2e6223..f02f91d57 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -34,15 +34,7 @@ extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); -extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); -extern int _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); -int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *, - va_list) - _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); -int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *, - va_list) - _ATTRIBUTE ((__format__ (__printf__, 3, 0)))); extern FILE *_EXFUN(__sfp,(struct _reent *)); extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); extern int _EXFUN(__srefill_r,(struct _reent *,FILE *)); diff --git a/newlib/libc/stdio/makebuf.c b/newlib/libc/stdio/makebuf.c index a3f47e2f7..d13f162b2 100644 --- a/newlib/libc/stdio/makebuf.c +++ b/newlib/libc/stdio/makebuf.c @@ -107,7 +107,7 @@ _DEFUN(__smakebuf_r, (ptr, fp), fp->_flags |= __SMBF; fp->_bf._base = fp->_p = (unsigned char *) p; fp->_bf._size = size; - if (couldbetty && _isatty_r (ptr, fp->_file)) + if (couldbetty && isatty (fp->_file)) fp->_flags |= __SLBF; } } diff --git a/newlib/libc/stdio/rget.c b/newlib/libc/stdio/rget.c index 9474bd9f6..0444acee3 100644 --- a/newlib/libc/stdio/rget.c +++ b/newlib/libc/stdio/rget.c @@ -36,10 +36,6 @@ _DEFUN(__srget_r, (ptr, fp), struct _reent *ptr _AND register FILE *fp) { - /* Ensure that any fake std stream is resolved before - we call __srefill_r so we may access the true read buffer. */ - CHECK_INIT(ptr, fp); - if (__srefill_r (ptr, fp) == 0) { fp->_r--; diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index d6a0e1983..296a16ee0 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -119,7 +119,7 @@ _siprintf_r(ptr, str, fmt, va_alist) #else va_start (ap); #endif - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); va_end (ap); *f._p = 0; return (ret); @@ -152,7 +152,7 @@ siprintf(str, fmt, va_alist) #else va_start (ap); #endif - ret = _svfiprintf_r (_REENT, &f, fmt, ap); + ret = _vfiprintf_r (_REENT, &f, fmt, ap); va_end (ap); *f._p = 0; return (ret); diff --git a/newlib/libc/stdio/siscanf.c b/newlib/libc/stdio/siscanf.c index a64e2a891..15b25c196 100644 --- a/newlib/libc/stdio/siscanf.c +++ b/newlib/libc/stdio/siscanf.c @@ -152,7 +152,7 @@ siscanf(str, fmt, va_alist) #else va_start (ap); #endif - ret = __ssvfiscanf_r (_REENT, &f, fmt, ap); + ret = __svfiscanf_r (_REENT, &f, fmt, ap); va_end (ap); return ret; } @@ -190,7 +190,7 @@ _siscanf_r(ptr, str, fmt, va_alist) #else va_start (ap); #endif - ret = __ssvfiscanf_r (ptr, &f, fmt, ap); + 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 index 98a2c2509..8cd06ce86 100644 --- a/newlib/libc/stdio/sniprintf.c +++ b/newlib/libc/stdio/sniprintf.c @@ -64,7 +64,7 @@ _sniprintf_r (ptr, str, size, fmt, va_alist) #else va_start (ap); #endif - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) ptr->_errno = EOVERFLOW; @@ -108,7 +108,7 @@ sniprintf (str, size, fmt, va_alist) #else va_start (ap); #endif - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) ptr->_errno = EOVERFLOW; diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index 13414e3d1..52db2dd2c 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -63,7 +63,7 @@ _snprintf_r(ptr, str, size, fmt, va_alist) #else va_start (ap); #endif - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) ptr->_errno = EOVERFLOW; @@ -107,7 +107,7 @@ snprintf(str, size, fmt, va_alist) #else va_start (ap); #endif - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); va_end (ap); if (ret < EOF) ptr->_errno = EOVERFLOW; diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index 48d811cf6..bdff0797d 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -583,7 +583,7 @@ _sprintf_r(ptr, str, fmt, va_alist) #else va_start (ap); #endif - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); va_end (ap); *f._p = 0; return (ret); @@ -616,7 +616,7 @@ sprintf(str, fmt, va_alist) #else va_start (ap); #endif - ret = _svfprintf_r (_REENT, &f, fmt, ap); + ret = _vfprintf_r (_REENT, &f, fmt, ap); va_end (ap); *f._p = 0; return (ret); diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index b09390380..c0921e1e1 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -433,7 +433,7 @@ sscanf(str, fmt, va_alist) #else va_start (ap); #endif - ret = __ssvfscanf_r (_REENT, &f, fmt, ap); + ret = __svfscanf_r (_REENT, &f, fmt, ap); va_end (ap); return ret; } @@ -471,7 +471,7 @@ _sscanf_r(ptr, str, fmt, va_alist) #else va_start (ap); #endif - ret = __ssvfscanf_r (ptr, &f, fmt, ap); + ret = __svfscanf_r (ptr, &f, fmt, ap); va_end (ap); return ret; } diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c index 671bbdb08..b16efe794 100644 --- a/newlib/libc/stdio/vasiprintf.c +++ b/newlib/libc/stdio/vasiprintf.c @@ -53,7 +53,7 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap), f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); if (ret >= 0) { *f._p = 0; diff --git a/newlib/libc/stdio/vasniprintf.c b/newlib/libc/stdio/vasniprintf.c index bf9b7c5eb..1e5d600c7 100644 --- a/newlib/libc/stdio/vasniprintf.c +++ b/newlib/libc/stdio/vasniprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007, 2008 Eric Blake +/* Copyright (C) 2007 Eric Blake * Permission to use, copy, modify, and distribute this software * is freely granted, provided that this notice is preserved. */ @@ -47,7 +47,7 @@ _DEFUN(_vasniprintf_r, (ptr, buf, lenp, fmt, ap), } f._bf._size = f._w = len; f._file = -1; /* No file. */ - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); if (ret < 0) return NULL; *lenp = ret; diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprintf.c index 2dda30a7a..740aa0700 100644 --- a/newlib/libc/stdio/vasnprintf.c +++ b/newlib/libc/stdio/vasnprintf.c @@ -47,7 +47,7 @@ _DEFUN(_vasnprintf_r, (ptr, buf, lenp, fmt, ap), } f._bf._size = f._w = len; f._file = -1; /* No file. */ - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); if (ret < 0) return NULL; *lenp = ret; diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index 525c6963a..90539d1d8 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -53,7 +53,7 @@ _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap), f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); if (ret >= 0) { *f._p = 0; diff --git a/newlib/libc/stdio/vdiprintf.c b/newlib/libc/stdio/vdiprintf.c index 51bdb000e..b9b94735c 100644 --- a/newlib/libc/stdio/vdiprintf.c +++ b/newlib/libc/stdio/vdiprintf.c @@ -10,7 +10,6 @@ #include <stdlib.h> #include <unistd.h> #include <stdarg.h> -#include "local.h" int _DEFUN(_vdiprintf_r, (ptr, fd, format, ap), diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c index bfb19c95b..8a20235ef 100644 --- a/newlib/libc/stdio/vdprintf.c +++ b/newlib/libc/stdio/vdprintf.c @@ -10,7 +10,6 @@ #include <stdlib.h> #include <unistd.h> #include <stdarg.h> -#include "local.h" int _DEFUN(_vdprintf_r, (ptr, fd, format, ap), diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 1846d7c1e..e9c7c9e1a 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -116,18 +116,10 @@ static char *rcsid = "$Id$"; #ifdef INTEGER_ONLY # define VFPRINTF vfiprintf -# ifdef STRING_ONLY -# define _VFPRINTF_R _svfiprintf_r -# else -# define _VFPRINTF_R _vfiprintf_r -# endif +# define _VFPRINTF_R _vfiprintf_r #else # define VFPRINTF vfprintf -# ifdef STRING_ONLY -# define _VFPRINTF_R _svfprintf_r -# else -# define _VFPRINTF_R _vfprintf_r -# endif +# define _VFPRINTF_R _vfprintf_r # ifndef NO_FLOATING_POINT # define FLOATING_POINT # endif @@ -166,100 +158,6 @@ static char *rcsid = "$Id$"; # undef _NO_LONGLONG #endif -#ifdef STRING_ONLY -static int -_DEFUN(__sprint_r, (ptr, fp, uio), - struct _reent *ptr _AND - FILE *fp _AND - register struct __suio *uio) -{ - register size_t len; - register int w; - register struct __siov *iov; - register _CONST char *p = NULL; - - iov = uio->uio_iov; - len = 0; - - if (uio->uio_resid == 0) { - uio->uio_iovcnt = 0; - return (0); - } - - do { - while (len == 0) { - p = iov->iov_base; - len = iov->iov_len; - iov++; - } - w = fp->_w; - if (len >= w && fp->_flags & (__SMBF | __SOPT)) { - /* must be asprintf family */ - unsigned char *str; - int curpos = (fp->_p - fp->_bf._base); - /* Choose a geometric growth factor to avoid - * quadratic realloc behavior, but use a rate less - * than (1+sqrt(5))/2 to accomodate malloc - * overhead. asprintf EXPECTS us to overallocate, so - * that it can add a trailing \0 without - * reallocating. The new allocation should thus be - * max(prev_size*1.5, curpos+len+1). */ - int newsize = fp->_bf._size * 3 / 2; - if (newsize < curpos + len + 1) - newsize = curpos + len + 1; - if (fp->_flags & __SOPT) - { - /* asnprintf leaves original buffer alone. */ - str = (unsigned char *)_malloc_r (ptr, newsize); - if (!str) - { - ptr->_errno = ENOMEM; - goto err; - } - memcpy (str, fp->_bf._base, curpos); - fp->_flags = (fp->_flags & ~__SOPT) | __SMBF; - } - else - { - str = (unsigned char *)_realloc_r (ptr, fp->_bf._base, - newsize); - if (!str) { - /* Free unneeded buffer. */ - _free_r (ptr, fp->_bf._base); - /* Ensure correct errno, even if free - * changed it. */ - ptr->_errno = ENOMEM; - goto err; - } - } - fp->_bf._base = str; - fp->_p = str + curpos; - fp->_bf._size = newsize; - w = len; - fp->_w = newsize - curpos; - } - if (len < w) - w = len; - (void)memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (w)); - fp->_w -= w; - fp->_p += w; - w = len; /* pretend we copied all */ - p += w; - len -= w; - } while ((uio->uio_resid -= w) != 0); - - uio->uio_resid = 0; - uio->uio_iovcnt = 0; - return 0; - -err: - fp->_flags |= __SERR; - uio->uio_resid = 0; - uio->uio_iovcnt = 0; - return EOF; -} - -#else /* !STRING_ONLY */ /* * Flush out all the vectors defined by the given uio, * then reset it so that it can be reused. @@ -324,7 +222,6 @@ _DEFUN(__sbprintf, (rptr, fp, fmt, ap), #endif return (ret); } -#endif /* !STRING_ONLY */ #ifdef FLOATING_POINT @@ -425,8 +322,8 @@ union arg_val }; static union arg_val * -_EXFUN(get_arg, (struct _reent *data, int n, char *fmt, - va_list *ap, int *numargs, union arg_val *args, +_EXFUN(get_arg, (struct _reent *data, int n, char *fmt, + va_list *ap, int *numargs, union arg_val *args, int *arg_type, char **last_fmt)); #endif /* !_NO_POS_ARGS */ @@ -463,8 +360,7 @@ _EXFUN(get_arg, (struct _reent *data, int n, char *fmt, int _EXFUN(_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); -#ifndef STRING_ONLY -int +int _DEFUN(VFPRINTF, (fp, fmt0, ap), FILE * fp _AND _CONST char *fmt0 _AND @@ -474,9 +370,8 @@ _DEFUN(VFPRINTF, (fp, fmt0, ap), result = _VFPRINTF_R (_REENT, fp, fmt0, ap); return result; } -#endif /* STRING_ONLY */ -int +int _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), struct _reent *data _AND FILE * fp _AND @@ -622,14 +517,12 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), (u_long)GET_ARG (N, ap, u_int)) #endif -#ifndef STRING_ONLY - /* Initialize std streams if not dealing with sprintf family. */ CHECK_INIT (data, fp); _flockfile (fp); /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ if (cantwrite (data, fp)) { - _funlockfile (fp); + _funlockfile (fp); return (EOF); } @@ -639,19 +532,6 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), _funlockfile (fp); return (__sbprintf (data, fp, fmt0, ap)); } -#else /* STRING_ONLY */ - /* Create initial buffer if we are called by asprintf family. */ - if (fp->_flags & __SMBF && !fp->_bf._base) - { - fp->_bf._base = fp->_p = _malloc_r (data, 64); - if (!fp->_p) - { - data->_errno = ENOMEM; - return EOF; - } - fp->_bf._size = 64; - } -#endif /* STRING_ONLY */ fmt = (char *)fmt0; uio.uio_iov = iovp = iov; @@ -930,7 +810,7 @@ reswitch: switch (ch) { (wchar_t)GET_ARG (N, ap, wint_t), &ps)) == -1) { fp->_flags |= __SERR; - goto error; + goto error; } } else @@ -1108,7 +988,7 @@ reswitch: switch (ch) { #ifndef _NO_LONGLONG if (flags & QUADINT) *GET_ARG (N, ap, quad_ptr_t) = ret; - else + else #endif if (flags & LONGINT) *GET_ARG (N, ap, long_ptr_t) = ret; @@ -1450,9 +1330,7 @@ done: error: if (malloc_buf != NULL) _free_r (data, malloc_buf); -#ifndef STRING_ONLY _funlockfile (fp); -#endif return (__sferror (fp) ? EOF : ret); /* NOTREACHED */ } @@ -1614,7 +1492,7 @@ exponent(char *p0, int exp, int fmtch) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. @@ -1639,24 +1517,24 @@ typedef enum { DOT, /* '.' */ STAR, /* '*' */ FLAG, /* format flag */ - OTHER, /* all other chars */ + OTHER, /* all other chars */ MAX_CH_CLASS /* place-holder */ } CH_CLASS; -typedef enum { +typedef enum { START, /* start */ SFLAG, /* seen a flag */ WDIG, /* seen digits in width area */ WIDTH, /* processed width */ SMOD, /* seen spec modifier */ - SDOT, /* seen dot */ + SDOT, /* seen dot */ VARW, /* have variable width specifier */ VARP, /* have variable precision specifier */ PREC, /* processed precision */ VWDIG, /* have digits in variable width specification */ VPDIG, /* have digits in variable precision specification */ - DONE, /* done */ - MAX_STATE, /* place-holder */ + DONE, /* done */ + MAX_STATE, /* place-holder */ } STATE; typedef enum { @@ -1681,7 +1559,7 @@ _CONST static CH_CLASS chclass[256] = { /* 30-37 */ ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, /* 38-3f */ DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, /* 40-47 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, - /* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC, + /* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC, /* 50-57 */ OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER, /* 58-5f */ SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, /* 60-67 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, @@ -1707,7 +1585,7 @@ _CONST static CH_CLASS chclass[256] = { }; _CONST static STATE state_table[MAX_STATE][MAX_CH_CLASS] = { - /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ + /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ /* START */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, /* SFLAG */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, /* WDIG */ { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE }, @@ -1722,7 +1600,7 @@ _CONST static STATE state_table[MAX_STATE][MAX_CH_CLASS] = { }; _CONST static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = { - /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ + /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ /* START */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, /* SFLAG */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, /* WDIG */ { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, @@ -1778,10 +1656,10 @@ _DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), while (*fmt && n >= numargs) { # ifdef _MB_CAPABLE - while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0) + while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0) { fmt += nbytes; - if (wc == '%') + if (wc == '%') break; } diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index f56681eaa..68b55f426 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -121,35 +121,17 @@ Supporting OS subroutines required: #define VFSCANF vfiscanf #define _VFSCANF_R _vfiscanf_r #define __SVFSCANF __svfiscanf -#ifdef STRING_ONLY -# define __SVFSCANF_R __ssvfiscanf_r -#else -# define __SVFSCANF_R __svfiscanf_r -#endif +#define __SVFSCANF_R __svfiscanf_r #else #define VFSCANF vfscanf #define _VFSCANF_R _vfscanf_r #define __SVFSCANF __svfscanf -#ifdef STRING_ONLY -# define __SVFSCANF_R __ssvfscanf_r -#else -# define __SVFSCANF_R __svfscanf_r -#endif +#define __SVFSCANF_R __svfscanf_r #ifndef NO_FLOATING_POINT #define FLOATING_POINT #endif #endif -#ifdef STRING_ONLY -#undef _flockfile -#undef _funlockfile -#define _flockfile(x) {} -#define _funlockfile(x) {} -#define _ungetc_r _sungetc_r -#define __srefill_r __ssrefill_r -#define _fread_r _sfread_r -#endif - #ifdef FLOATING_POINT #include <math.h> #include <float.h> @@ -252,8 +234,6 @@ typedef unsigned long long u_long_long; #define BufferEmpty (fp->_r <= 0 && __srefill_r(rptr, fp)) -#ifndef STRING_ONLY - #ifndef _REENT_ONLY int @@ -287,135 +267,7 @@ _DEFUN(_VFSCANF_R, (data, fp, fmt, ap), CHECK_INIT(data, fp); return __SVFSCANF_R (data, fp, fmt, ap); } -#endif /* !STRING_ONLY */ - -#ifdef STRING_ONLY -/* When dealing with the sscanf family, we don't want to use the - * regular ungetc which will drag in file I/O items we don't need. - * So, we create our own trimmed-down version. */ -static int -_DEFUN(_sungetc_r, (data, fp, ch), - struct _reent *data _AND - int c _AND - register FILE *fp) -{ - if (c == EOF) - return (EOF); - /* After ungetc, we won't be at eof anymore */ - fp->_flags &= ~__SEOF; - c = (unsigned char) c; - - /* - * If we are in the middle of ungetc'ing, just continue. - * This may require expanding the current ungetc buffer. - */ - - if (HASUB (fp)) - { - if (fp->_r >= fp->_ub._size && __submore (data, fp)) - { - return EOF; - } - *--fp->_p = c; - fp->_r++; - return c; - } - - /* - * If we can handle this by simply backing up, do so, - * but never replace the original character. - * (This makes sscanf() work when scanning `const' data.) - */ - - if (fp->_bf._base != NULL && fp->_p > fp->_bf._base && fp->_p[-1] == c) - { - fp->_p--; - fp->_r++; - return c; - } - - /* - * Create an ungetc buffer. - * Initially, we will use the `reserve' buffer. - */ - - fp->_ur = fp->_r; - fp->_up = fp->_p; - fp->_ub._base = fp->_ubuf; - fp->_ub._size = sizeof (fp->_ubuf); - fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; - fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; - fp->_r = 1; - return c; -} - -/* String only version of __srefill_r for sscanf family. */ -static int -_DEFUN(__ssrefill_r, (ptr, fp), - struct _reent * ptr _AND - register FILE * fp) -{ - /* - * Our only hope of further input is the ungetc buffer. - * If there is anything in that buffer to read, return. - */ - if (HASUB (fp)) - { - FREEUB (ptr, fp); - if ((fp->_r = fp->_ur) != 0) - { - fp->_p = fp->_up; - return 0; - } - } - - /* Otherwise we are out of character input. */ - fp->_p = fp->_bf._base; - fp->_r = 0; - fp->_flags &= ~__SMOD; /* buffer contents are again pristine */ - fp->_flags |= __SEOF; - return EOF; -} - -static size_t -_DEFUN(_sfread_r, (ptr, buf, size, count, fp), - struct _reent * ptr _AND - _PTR buf _AND - size_t size _AND - size_t count _AND - FILE * fp) -{ - register size_t resid; - register char *p; - register int r; - size_t total; - - if ((resid = count * size) == 0) - return 0; - - total = resid; - p = buf; - - while (resid > (r = fp->_r)) - { - _CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, (size_t) r); - fp->_p += r; - fp->_r = 0; - p += r; - resid -= r; - if (__ssrefill_r (ptr, fp)) - { - /* no more input: return partial result */ - return (total - resid) / size; - } - } - _CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); - fp->_r -= resid; - fp->_p += resid; - return count; -} -#endif /* STRING_ONLY */ int _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), @@ -889,7 +741,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), } else { - size_t r = _fread_r (rptr, (_PTR) GET_ARG (N, ap, char *), 1, width, fp); + size_t r = fread ((_PTR) GET_ARG (N, ap, char *), 1, width, fp); if (r == 0) goto input_failure; diff --git a/newlib/libc/stdio/vsiprintf.c b/newlib/libc/stdio/vsiprintf.c index 05d009d72..967c178e4 100644 --- a/newlib/libc/stdio/vsiprintf.c +++ b/newlib/libc/stdio/vsiprintf.c @@ -53,7 +53,7 @@ _DEFUN(_vsiprintf_r, (ptr, str, fmt, ap), f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ - ret = _svfiprintf_r (ptr, &f, fmt, ap); + 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 index c26171acf..ffbf22e97 100644 --- a/newlib/libc/stdio/vsiscanf.c +++ b/newlib/libc/stdio/vsiscanf.c @@ -71,5 +71,5 @@ _DEFUN(_vsiscanf_r, (ptr, str, fmt, ap), f._ub._base = NULL; f._lb._base = NULL; f._file = -1; /* No file. */ - return __ssvfiscanf_r (ptr, &f, fmt, ap); + return __svfiscanf_r (ptr, &f, fmt, ap); } diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c index f7c60e280..d1c318576 100644 --- a/newlib/libc/stdio/vsniprintf.c +++ b/newlib/libc/stdio/vsniprintf.c @@ -61,7 +61,7 @@ _DEFUN(_vsniprintf_r, (ptr, str, size, fmt, ap), f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ - ret = _svfiprintf_r (ptr, &f, fmt, ap); + ret = _vfiprintf_r (ptr, &f, fmt, ap); if (ret < EOF) ptr->_errno = EOVERFLOW; if (size > 0) diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index 641047dd3..6a26f8bea 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1990 The Regents of the University of California. + * Copyright (c) 1990, 2007 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -61,7 +61,7 @@ _DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap), f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); if (ret < EOF) ptr->_errno = EOVERFLOW; if (size > 0) diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c index fd052cd95..5c2600411 100644 --- a/newlib/libc/stdio/vsprintf.c +++ b/newlib/libc/stdio/vsprintf.c @@ -53,7 +53,7 @@ _DEFUN(_vsprintf_r, (ptr, str, fmt, ap), f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ - ret = _svfprintf_r (ptr, &f, fmt, ap); + ret = _vfprintf_r (ptr, &f, fmt, ap); *f._p = 0; return ret; } diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index 566823add..9bb7c0c3e 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -71,5 +71,5 @@ _DEFUN(_vsscanf_r, (ptr, str, fmt, ap), f._ub._base = NULL; f._lb._base = NULL; f._file = -1; /* No file. */ - return __ssvfscanf_r (ptr, &f, fmt, ap); + return __svfscanf_r (ptr, &f, fmt, ap); } |