diff --git a/newlib/ChangeLog b/newlib/ChangeLog index ab21c37be..9f4b56869 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,43 @@ +2014-07-04 Bin Cheng + + * README (--enable-newlib-nano-formatted-io): Describe. + * acconfig.h (_NANO_FORMATTED_IO): Undef. + * newlib.hin (_NANO_FORMATTED_IO): Undef. + * configure.in (--enable-newlib-nano-formatted-io): New option. + * configure: Regenerated. + * libc/configure.in (--enable-newlib-nano-formatted-io): New option. + * libc/configure: Regenerated. + * libc/stdio/Makefile.am (NEWLIB_NANO_FORMATTED_IO): Support new + configuration option. + * libc/stdio/Makefile.in: Regenerated. + * libc/stdio/asnprintf.c (_asniprintf_r, asniprintf): Use + _NANO_FORMATTED_IO to declare alias prototypes. + * libc/stdio/asprintf.c (_asiprintf_r, asiprintf): Ditto. + * libc/stdio/dprintf.c (_diprintf_r, diprintf): Ditto. + * libc/stdio/fprintf.c (_fiprintf_r, fiprintf): Ditto. + * libc/stdio/fscanf.c (fiscanf, _fiscanf_r): Ditto. + * libc/stdio/printf.c (_iprintf_r, iprintf): Ditto. + * libc/stdio/scanf.c (iscanf, _iscanf_r): Ditto. + * libc/stdio/snprintf.c (_sniprintf_r, sniprintf): Ditto. + * libc/stdio/sprintf.c (_siprintf_r, siprintf): Ditto. + * libc/stdio/sscanf.c (siscanf, _siscanf_r): Ditto. + * libc/stdio/vasnprintf.c (_vasniprintf_r, vasniprintf): Ditto. + * libc/stdio/vasprintf.c (vasiprintf, _vasiprintf_r): Ditto. + * libc/stdio/vdprintf.c (_vdiprintf_r, vdiprintf): Ditto. + * libc/stdio/vprintf.c (viprintf, _viprintf_r): Ditto. + * libc/stdio/vscanf.c (viscanf, _viscanf_r): Ditto. + * libc/stdio/vsnprintf.c (vsniprintf, _vsniprintf_r): Ditto. + * libc/stdio/vsprintf.c (vsiprintf, _vsiprintf_r): Ditto. + * libc/stdio/vsscanf.c (vsiscanf, _vsiscanf_r): Ditto. + * libc/stdio/nano-vfprintf.c: New file. + * libc/stdio/nano-vfprintf_float.c: New file. + * libc/stdio/nano-vfprintf_i.c: New file. + * libc/stdio/nano-vfprintf_local.h: New file. + * libc/stdio/nano-vfscanf.c: New file. + * libc/stdio/nano-vfscanf_float.c: New file. + * libc/stdio/nano-vfscanf_i.c: New file. + * libc/stdio/nano-vfscanf_local.h: New file. + 2014-06-23 Corinna Vinschen * libc/argz/envz_merge.c (envz_merge): Fix memory leak (Cygwin Coverity diff --git a/newlib/README b/newlib/README index adad87111..a3d915dda 100644 --- a/newlib/README +++ b/newlib/README @@ -372,6 +372,73 @@ One feature can be enabled by specifying `--enable-FEATURE=yes' or invoke clean-up functions such as _fini or global destructors. Disabled by default. +`--enable-newlib-nano-formatted-io' + This builds NEWLIB with a special implementation of formatted I/O + functions, designed to lower the size of application on small systems + with size constraint issues. This option does not affect wide-char + formatted I/O functions. Some notes about the feature: + 1) The non-wide-char formatted I/O functions only support the C89 + standard. The only exception is the configuration option provides + limited support for long double. Internally, the nano formatted I/O + functions use double so accuracy is only guaranteed to double + precision. + 2) Floating-point support is split out of the formatted I/O code into + weak functions which are not linked by default. Programs that need + floating-point I/O support must explicitly request linking of one or + both of the floating-point functions: _printf_float or _scanf_float. + This can be done at link time using the -u option which can be passed + to either gcc or ld. The -u option forces the link to resolve those + function references. Floating-point format specifiers are recognized + by default, but if the floating-point functions are not explicitly + linked in, this may result in undefined behavior for programs that + need floating-point I/O support. + 3) Integer-only versions of the formatted I/O functions (the iprintf/ + iscanf family) simply alias their regular counter-parts. + The affected functions are: + + diprintf vdiprintf + + siprintf fiprintf iprintf sniprintf asiprintf asniprintf + + siscanf fiscanf iscanf + + viprintf vfiprintf vsiprintf vsniprintf vasiprintf vasniprintf + + viscanf vfiscanf vsiscanf + + _diprintf_r _vdiprintf_r + + _siprintf_r _fiprintf_r _iprintf_r _sniprintf_r _asiprintf_r + _asniprintf_r + + _siscanf_r _fiscanf_r _iscanf_r + + _viprintf_r _vfiprintf_r _vsiprintf_r _asniprintf_r _vasiprintf_r + _vasniprintf_r + + _viscanf_r _vfiscanf_r _vsiscanf_r + + 4) As mentioned, the option does not affect wide-char formatted I/O. + The following configuration options are ignored for non-wide-char + formatted I/O functions, and can be thought of as disabled. + + enable-newlib-io-pos-args + enable-newlib-io-c99-formats + enable-newlib-io-long-long + enable-newlib-io-long-double + enable-newlib-mb + + Additionally, "enable/disable-newlib-io-float" is supported in + this specific implementation, one can use "disable-newlib-io-float" + to further reduce code size. In this case, the floating-point + specifiers will not be recognized or handled, and the -u option + will not work either. + + 5) As a rule, no features from outside of C89 standard will be + considered in this implementation. + + Disabled by default. + Running the Testsuite ===================== diff --git a/newlib/acconfig.h b/newlib/acconfig.h index 055bbdfe8..de26c5ef3 100644 --- a/newlib/acconfig.h +++ b/newlib/acconfig.h @@ -73,6 +73,9 @@ /* Define if enable lite version of exit. */ #undef _LITE_EXIT +/* Define if nano version formatted IO is used. */ +#undef _NANO_FORMATTED_IO + @BOTTOM@ /* * Iconv encodings enabled ("to" direction) diff --git a/newlib/configure b/newlib/configure index 4d39bb5a1..991f9e6b5 100755 --- a/newlib/configure +++ b/newlib/configure @@ -817,6 +817,7 @@ enable_newlib_wide_orient enable_newlib_nano_malloc enable_newlib_unbuf_stream_opt enable_lite_exit +enable_newlib_nano_formatted_io enable_multilib enable_target_optspace enable_malloc_debugging @@ -1485,6 +1486,7 @@ Optional Features: --enable-newlib-nano-malloc use small-footprint nano-malloc implementation --disable-newlib-unbuf-stream-opt disable unbuffered stream optimization in streamio --enable-lite-exit enable light weight exit + --enable-newlib-nano-formatted-io Use nano version formatted IO --enable-multilib build many library versions (default) --enable-target-optspace optimize for space --enable-malloc-debugging indicate malloc debugging requested @@ -2474,6 +2476,18 @@ else lite_exit=no fi +# Check whether --enable-newlib_nano_formatted_io was given. +if test "${enable_newlib_nano_formatted_io+set}" = set; then : + enableval=$enable_newlib_nano_formatted_io; case "${enableval}" in + yes) newlib_nano_formatted_io=yes ;; + no) newlib_nano_formatted_io=no ;; + *) as_fn_error $? "bad value ${enableval} for newlib-nano-formatted-io" "$LINENO" 5 ;; + esac +else + newlib_nano_formatted_io=yes +fi + + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || @@ -12409,6 +12423,13 @@ _ACEOF fi +if test "${newlib_nano_formatted_io}" = "yes"; then +cat >>confdefs.h <<_ACEOF +#define _NANO_FORMATTED_IO 1 +_ACEOF + +fi + if test "x${iconv_encodings}" != "x" \ || test "x${iconv_to_encodings}" != "x" \ diff --git a/newlib/configure.in b/newlib/configure.in index 32b8eac39..e1b3efaa7 100644 --- a/newlib/configure.in +++ b/newlib/configure.in @@ -207,6 +207,17 @@ AC_ARG_ENABLE(lite-exit, esac fi], [lite_exit=no])dnl +dnl Support --enable-newlib-nano-formatted-io +dnl This option is also read in libc/configure.in. It is repeated +dnl here so that it shows up in the help text. +AC_ARG_ENABLE(newlib_nano_formatted_io, +[ --enable-newlib-nano-formatted-io Use nano version formatted IO], +[case "${enableval}" in + yes) newlib_nano_formatted_io=yes ;; + no) newlib_nano_formatted_io=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-nano-formatted-io) ;; + esac],[newlib_nano_formatted_io=yes]) + NEWLIB_CONFIGURE(.) dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and @@ -424,6 +435,10 @@ if test "${lite_exit}" = "yes"; then AC_DEFINE_UNQUOTED(_LITE_EXIT) fi +if test "${newlib_nano_formatted_io}" = "yes"; then +AC_DEFINE_UNQUOTED(_NANO_FORMATTED_IO) +fi + dnl dnl Parse --enable-newlib-iconv-encodings option argument dnl diff --git a/newlib/libc/configure b/newlib/libc/configure index 074de7510..df1a817db 100755 --- a/newlib/libc/configure +++ b/newlib/libc/configure @@ -751,6 +751,8 @@ build newlib_basedir MAY_SUPPLY_SYSCALLS_FALSE MAY_SUPPLY_SYSCALLS_TRUE +NEWLIB_NANO_FORMATTED_IO_FALSE +NEWLIB_NANO_FORMATTED_IO_TRUE target_alias host_alias build_alias @@ -794,6 +796,7 @@ ac_user_opts=' enable_option_checking enable_newlib_io_pos_args enable_newlib_nano_malloc +enable_newlib_nano_formatted_io enable_multilib enable_target_optspace enable_malloc_debugging @@ -1444,6 +1447,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-newlib-io-pos-args enable printf-family positional arg support --enable-newlib-nano-malloc Use small-footprint nano-malloc implementation + --enable-newlib-nano-formatted-io Use small-footprint nano-formatted-IO implementation --enable-multilib build many library versions (default) --enable-target-optspace optimize for space --enable-malloc-debugging indicate malloc debugging requested @@ -2228,6 +2232,26 @@ else fi +# Check whether --enable-newlib_nano_formatted_io was given. +if test "${enable_newlib_nano_formatted_io+set}" = set; then : + enableval=$enable_newlib_nano_formatted_io; case "${enableval}" in + yes) newlib_nano_formatted_io=yes ;; + no) newlib_nano_formatted_io=no ;; + *) as_fn_error $? "bad value ${enableval} for newlib-nano-formatted-io" "$LINENO" 5 ;; + esac +else + newlib_nano_formatted_io=no +fi + + if test x$newlib_nano_formatted_io = xyes; then + NEWLIB_NANO_FORMATTED_IO_TRUE= + NEWLIB_NANO_FORMATTED_IO_FALSE='#' +else + NEWLIB_NANO_FORMATTED_IO_TRUE='#' + NEWLIB_NANO_FORMATTED_IO_FALSE= +fi + + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || @@ -12220,6 +12244,10 @@ LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs +if test -z "${NEWLIB_NANO_FORMATTED_IO_TRUE}" && test -z "${NEWLIB_NANO_FORMATTED_IO_FALSE}"; then + as_fn_error $? "conditional \"NEWLIB_NANO_FORMATTED_IO\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MAY_SUPPLY_SYSCALLS_TRUE}" && test -z "${MAY_SUPPLY_SYSCALLS_FALSE}"; then as_fn_error $? "conditional \"MAY_SUPPLY_SYSCALLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/newlib/libc/configure.in b/newlib/libc/configure.in index 8a6b81d85..0a7bb8815 100644 --- a/newlib/libc/configure.in +++ b/newlib/libc/configure.in @@ -26,6 +26,16 @@ AC_ARG_ENABLE(newlib_nano_malloc, *) AC_MSG_ERROR(bad value ${enableval} for newlib-nano-malloc) ;; esac],[newlib_nano_malloc=]) +dnl Support --enable-newlib-nano-formatted-io used by libc/stdio +AC_ARG_ENABLE(newlib_nano_formatted_io, +[ --enable-newlib-nano-formatted-io Use small-footprint nano-formatted-IO implementation], +[case "${enableval}" in + yes) newlib_nano_formatted_io=yes ;; + no) newlib_nano_formatted_io=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-nano-formatted-io) ;; + esac],[newlib_nano_formatted_io=no]) +AM_CONDITIONAL(NEWLIB_NANO_FORMATTED_IO, test x$newlib_nano_formatted_io = xyes) + NEWLIB_CONFIGURE(..) AM_CONDITIONAL(NEWLIB_NANO_MALLOC, test x$newlib_nano_malloc = xyes) diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index a1ba475df..1d459b250 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -4,7 +4,27 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) +if NEWLIB_NANO_FORMATTED_IO +GENERAL_INT_FORMATTED_IO_SOURCES = +else +GENERAL_INT_FORMATTED_IO_SOURCES = \ + fiprintf.c \ + fiscanf.c \ + iprintf.c \ + iscanf.c \ + siprintf.c \ + siscanf.c \ + sniprintf.c \ + vdiprintf.c \ + viprintf.c \ + viscanf.c \ + vsiprintf.c \ + vsiscanf.c \ + vsniprintf.c +endif + GENERAL_SOURCES = \ + $(GENERAL_INT_FORMATTED_IO_SOURCES) \ clearerr.c \ fclose.c \ fdopen.c \ @@ -16,7 +36,6 @@ GENERAL_SOURCES = \ fgets.c \ fileno.c \ findfp.c \ - fiprintf.c \ flags.c \ fopen.c \ fprintf.c \ @@ -25,7 +44,6 @@ GENERAL_SOURCES = \ fread.c \ freopen.c \ fscanf.c \ - fiscanf.c \ fseek.c \ fsetpos.c \ ftell.c \ @@ -39,8 +57,6 @@ GENERAL_SOURCES = \ getdelim.c \ getline.c \ gets.c \ - iprintf.c \ - iscanf.c \ makebuf.c \ perror.c \ printf.c \ @@ -60,9 +76,6 @@ GENERAL_SOURCES = \ setbuffer.c \ setlinebuf.c \ setvbuf.c \ - siprintf.c \ - siscanf.c \ - sniprintf.c \ snprintf.c \ sprintf.c \ sscanf.c \ @@ -70,16 +83,10 @@ GENERAL_SOURCES = \ tmpfile.c \ tmpnam.c \ ungetc.c \ - vdiprintf.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 \ @@ -89,8 +96,16 @@ GENERAL_SOURCES = \ if ELIX_LEVEL_1 ELIX_2_SOURCES = else -ELIX_2_SOURCES = \ +if NEWLIB_NANO_FORMATTED_IO +ELIX_2_INT_FORMATTED_IO_SOURCES = +else +ELIX_2_INT_FORMATTED_IO_SOURCES = \ asiprintf.c \ + vasiprintf.c + +endif !NEWLIB_NANO_FORMATTED_IO +ELIX_2_SOURCES = \ + $(ELIX_2_INT_FORMATTED_IO_SOURCES) \ asprintf.c \ fcloseall.c \ fseeko.c \ @@ -98,9 +113,8 @@ ELIX_2_SOURCES = \ getw.c \ mktemp.c \ putw.c \ - vasiprintf.c \ vasprintf.c -endif +endif !ELIX_LEVEL_1 ## The following are EL/IX level 2 interfaces if ELIX_LEVEL_1 @@ -112,10 +126,18 @@ else if ELIX_LEVEL_3 ELIX_4_SOURCES = else -ELIX_4_SOURCES = \ +if NEWLIB_NANO_FORMATTED_IO +ELIX_4_INT_FORMATTED_IO_SOURCES = +else +ELIX_4_INT_FORMATTED_IO_SOURCES = \ asniprintf.c \ - asnprintf.c \ diprintf.c \ + vasniprintf.c + +endif !NEWLIB_NANO_FORMATTED_IO +ELIX_4_SOURCES = \ + $(ELIX_4_INT_FORMATTED_IO_SOURCES) \ + asnprintf.c \ dprintf.c \ fgetwc.c \ fgetws.c \ @@ -136,7 +158,6 @@ ELIX_4_SOURCES = \ swprintf.c \ swscanf.c \ ungetwc.c \ - vasniprintf.c \ vasnprintf.c \ vfwscanf.c \ vswprintf.c \ @@ -150,6 +171,25 @@ endif !ELIX_LEVEL_3 endif !ELIX_LEVEL_2 endif !ELIX_LEVEL_1 +if NEWLIB_NANO_FORMATTED_IO +LIBADD_OBJS = \ + $(lpfx)nano-vfprintf_float.$(oext) \ + $(lpfx)nano-svfprintf.$(oext) \ + $(lpfx)nano-svfscanf.$(oext) \ + $(lpfx)nano-vfprintf.$(oext) \ + $(lpfx)nano-vfprintf_i.$(oext) \ + $(lpfx)nano-vfscanf.$(oext) \ + $(lpfx)nano-vfscanf_i.$(oext) \ + $(lpfx)nano-vfscanf_float.$(oext) \ + $(lpfx)svfiwprintf.$(oext) \ + $(lpfx)svfwprintf.$(oext) \ + $(lpfx)vfiwprintf.$(oext) \ + $(lpfx)vfwprintf.$(oext) \ + $(lpfx)svfiwscanf.$(oext) \ + $(lpfx)svfwscanf.$(oext) \ + $(lpfx)vfiwscanf.$(oext) \ + $(lpfx)vfwscanf.$(oext) +else LIBADD_OBJS = \ $(lpfx)svfiprintf.$(oext) $(lpfx)svfprintf.$(oext) \ $(lpfx)svfiscanf.$(oext) $(lpfx)svfscanf.$(oext) \ @@ -159,6 +199,7 @@ LIBADD_OBJS = \ $(lpfx)vfiwprintf.$(oext) $(lpfx)vfwprintf.$(oext) \ $(lpfx)svfiwscanf.$(oext) $(lpfx)svfwscanf.$(oext) \ $(lpfx)vfiwscanf.$(oext) $(lpfx)vfwscanf.$(oext) +endif libstdio_la_LDFLAGS = -Xcompiler -nostdlib @@ -181,8 +222,31 @@ endif # USE_LIBTOOL include $(srcdir)/../../Makefile.shared -# This rule is needed so that libtool compiles vfiprintf before vfprintf. Otherwise -# libtool moves vfprintf.o and subsequently can't find it. + +# Though small footprint nano-formatted-IO implementation is used +# when NEWLIB_NANO_FORMATTED_IO is enabled, we keep all rules for +# the other implementation of formatted IO including all i-family +# functions. The object files in !NEWLIB_NANO_FORMATTED_IO version +# implementation will be neither compiled nor archived into final +# library, because they are not depended on by final makefile target. + +if NEWLIB_NANO_FORMATTED_IO +# Rules compiling small-footprint nano-formatted-io implementation. +$(lpfx)nano-vfprintf.$(oext): nano-vfprintf.c + $(LIB_COMPILE) -fshort-enums -c $(srcdir)/nano-vfprintf.c -o $@ + +$(lpfx)nano-vfprintf_i.$(oext): nano-vfprintf_i.c + $(LIB_COMPILE) -fshort-enums -c $(srcdir)/nano-vfprintf_i.c -o $@ + +$(lpfx)nano-vfprintf_float.$(oext): nano-vfprintf_float.c + $(LIB_COMPILE) -fshort-enums -c $(srcdir)/nano-vfprintf_float.c -o $@ + +$(lpfx)nano-svfprintf.$(oext): nano-vfprintf.c + $(LIB_COMPILE) -fshort-enums -DSTRING_ONLY -c $(srcdir)/nano-vfprintf.c -o $@ +endif + +# This rule is needed so that libtool compiles vfiprintf before vfprintf. +# Otherwise libtool moves vfprintf.o and subsequently can't find it. $(lpfx)vfprintf.$(oext): vfprintf.c $(LIB_COMPILE) -fshort-enums -c $(srcdir)/vfprintf.c -o $@ @@ -208,6 +272,21 @@ $(lpfx)svfwprintf.$(oext): vfwprintf.c $(lpfx)svfiwprintf.$(oext): vfwprintf.c $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfwprintf.c -o $@ +if NEWLIB_NANO_FORMATTED_IO +# Rules compiling small-footprint nano-formatted-io implementation. +$(lpfx)nano-vfscanf.$(oext): nano-vfscanf.c + $(LIB_COMPILE) -c $(srcdir)/nano-vfscanf.c -o $@ + +$(lpfx)nano-vfscanf_i.$(oext): nano-vfscanf_i.c + $(LIB_COMPILE) -c $(srcdir)/nano-vfscanf_i.c -o $@ + +$(lpfx)nano-vfscanf_float.$(oext): nano-vfscanf_float.c + $(LIB_COMPILE) -c $(srcdir)/nano-vfscanf_float.c -o $@ + +$(lpfx)nano-svfscanf.$(oext): nano-vfscanf.c + $(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/nano-vfscanf.c -o $@ +endif + $(lpfx)vfscanf.$(oext): vfscanf.c $(LIB_COMPILE) -c $(srcdir)/vfscanf.c -o $@ @@ -232,9 +311,27 @@ $(lpfx)svfwscanf.$(oext): vfwscanf.c $(lpfx)svfiwscanf.$(oext): vfwscanf.c $(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfwscanf.c -o $@ -CHEWOUT_FILES = \ - clearerr.def \ +if NEWLIB_NANO_FORMATTED_IO +CHEWOUT_INT_FORMATTED_IO_FILES =\ + nano-vfprintf.def \ + nano-vfprintf_i.def \ + nano-vfprintf_float.def \ + nano-vfscanf.def \ + nano-vfscanf_i.def \ + nano-vfscanf_float.def +else +CHEWOUT_INT_FORMATTED_IO_FILES =\ diprintf.def \ + siprintf.def \ + siscanf.def \ + vfprintf.def \ + vfscanf.def \ + viprintf.def \ + viscanf.def +endif +CHEWOUT_FILES = \ + $(CHEWOUT_INT_FORMATTED_IO_FILES) \ + clearerr.def \ dprintf.def \ fclose.def \ fcloseall.def \ @@ -292,8 +389,6 @@ CHEWOUT_FILES = \ setbuffer.def \ setlinebuf.def \ setvbuf.def \ - siprintf.def \ - siscanf.def \ sprintf.def \ sscanf.def \ swprintf.def \ @@ -302,12 +397,8 @@ CHEWOUT_FILES = \ tmpnam.def \ ungetc.def \ ungetwc.def \ - vfprintf.def \ - vfscanf.def \ vfwprintf.def \ - vfwscanf.def \ - viprintf.def \ - viscanf.def + vfwscanf.def SUFFIXES = .def @@ -366,6 +457,10 @@ $(lpfx)sniprintf.$(oext): local.h $(lpfx)sprintf.$(oext): local.h $(lpfx)sscanf.$(oext): local.h $(lpfx)stdio.$(oext): local.h +if NEWLIB_NANO_FORMATTED_IO +$(lpfx)nano-svfprintf.$(oext): local.h nano-vfprintf_local.h +$(lpfx)nano-svfscanf.$(oext): local.h nano-vfscanf_local.h +endif $(lpfx)svfiprintf.$(oext): local.h $(lpfx)svfiscanf.$(oext): local.h floatio.h $(lpfx)svfprintf.$(oext): local.h @@ -374,6 +469,14 @@ $(lpfx)swprintf.$(oext): local.h $(lpfx)swscanf.$(oext): local.h $(lpfx)ungetc.$(oext): local.h $(lpfx)ungetwc.$(oext): local.h +if NEWLIB_NANO_FORMATTED_IO +$(lpfx)nano-vfprintf.$(oext): local.h nano-vfprintf_local.h +$(lpfx)nano-vfprintf_i.$(oext): local.h nano-vfprintf_local.h +$(lpfx)nano-vfprintf_float.$(oext): local.h floatio.h nano-vfprintf_local.h +$(lpfx)nano-vfscanf.$(oext): local.h nano-vfscanf_local.h +$(lpfx)nano-vfscanf_i.$(oext): local.h nano-vfscanf_local.h +$(lpfx)nano-vfscanf_float.$(oext): local.h floatio.h nano-vfscanf_local.h +endif $(lpfx)vfiprintf.$(oext): local.h $(lpfx)vfiscanf.$(oext): local.h floatio.h $(lpfx)vfprintf.$(oext): local.h diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index a42b0e66d..3a14d1772 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -71,47 +71,57 @@ CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru lib_a_AR = $(AR) $(ARFLAGS) -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) \ - lib_a-fgetc.$(OBJEXT) lib_a-fgetpos.$(OBJEXT) \ - lib_a-fgets.$(OBJEXT) lib_a-fileno.$(OBJEXT) \ - lib_a-findfp.$(OBJEXT) lib_a-fiprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_1 = \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-fiprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-fiscanf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-iprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-iscanf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-siprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-siscanf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-sniprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vdiprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-viprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-viscanf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vsiprintf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vsiscanf.$(OBJEXT) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vsniprintf.$(OBJEXT) +am__objects_2 = $(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) lib_a-fgetc.$(OBJEXT) \ + lib_a-fgetpos.$(OBJEXT) lib_a-fgets.$(OBJEXT) \ + lib_a-fileno.$(OBJEXT) lib_a-findfp.$(OBJEXT) \ lib_a-flags.$(OBJEXT) lib_a-fopen.$(OBJEXT) \ lib_a-fprintf.$(OBJEXT) lib_a-fputc.$(OBJEXT) \ lib_a-fputs.$(OBJEXT) lib_a-fread.$(OBJEXT) \ lib_a-freopen.$(OBJEXT) lib_a-fscanf.$(OBJEXT) \ - lib_a-fiscanf.$(OBJEXT) lib_a-fseek.$(OBJEXT) \ - lib_a-fsetpos.$(OBJEXT) lib_a-ftell.$(OBJEXT) \ - lib_a-fvwrite.$(OBJEXT) lib_a-fwalk.$(OBJEXT) \ - lib_a-fwrite.$(OBJEXT) lib_a-getc.$(OBJEXT) \ - lib_a-getchar.$(OBJEXT) lib_a-getc_u.$(OBJEXT) \ - lib_a-getchar_u.$(OBJEXT) lib_a-getdelim.$(OBJEXT) \ - lib_a-getline.$(OBJEXT) lib_a-gets.$(OBJEXT) \ - lib_a-iprintf.$(OBJEXT) lib_a-iscanf.$(OBJEXT) \ - lib_a-makebuf.$(OBJEXT) lib_a-perror.$(OBJEXT) \ - lib_a-printf.$(OBJEXT) lib_a-putc.$(OBJEXT) \ - lib_a-putchar.$(OBJEXT) lib_a-putc_u.$(OBJEXT) \ - lib_a-putchar_u.$(OBJEXT) lib_a-puts.$(OBJEXT) \ - lib_a-refill.$(OBJEXT) lib_a-remove.$(OBJEXT) \ - lib_a-rename.$(OBJEXT) lib_a-rewind.$(OBJEXT) \ - lib_a-rget.$(OBJEXT) lib_a-scanf.$(OBJEXT) \ - lib_a-sccl.$(OBJEXT) lib_a-setbuf.$(OBJEXT) \ - lib_a-setbuffer.$(OBJEXT) lib_a-setlinebuf.$(OBJEXT) \ - lib_a-setvbuf.$(OBJEXT) lib_a-siprintf.$(OBJEXT) \ - lib_a-siscanf.$(OBJEXT) lib_a-sniprintf.$(OBJEXT) \ + lib_a-fseek.$(OBJEXT) lib_a-fsetpos.$(OBJEXT) \ + lib_a-ftell.$(OBJEXT) lib_a-fvwrite.$(OBJEXT) \ + lib_a-fwalk.$(OBJEXT) lib_a-fwrite.$(OBJEXT) \ + lib_a-getc.$(OBJEXT) lib_a-getchar.$(OBJEXT) \ + lib_a-getc_u.$(OBJEXT) lib_a-getchar_u.$(OBJEXT) \ + lib_a-getdelim.$(OBJEXT) lib_a-getline.$(OBJEXT) \ + lib_a-gets.$(OBJEXT) lib_a-makebuf.$(OBJEXT) \ + lib_a-perror.$(OBJEXT) lib_a-printf.$(OBJEXT) \ + lib_a-putc.$(OBJEXT) lib_a-putchar.$(OBJEXT) \ + lib_a-putc_u.$(OBJEXT) lib_a-putchar_u.$(OBJEXT) \ + lib_a-puts.$(OBJEXT) lib_a-refill.$(OBJEXT) \ + lib_a-remove.$(OBJEXT) lib_a-rename.$(OBJEXT) \ + lib_a-rewind.$(OBJEXT) lib_a-rget.$(OBJEXT) \ + lib_a-scanf.$(OBJEXT) lib_a-sccl.$(OBJEXT) \ + lib_a-setbuf.$(OBJEXT) lib_a-setbuffer.$(OBJEXT) \ + lib_a-setlinebuf.$(OBJEXT) lib_a-setvbuf.$(OBJEXT) \ lib_a-snprintf.$(OBJEXT) lib_a-sprintf.$(OBJEXT) \ lib_a-sscanf.$(OBJEXT) lib_a-stdio.$(OBJEXT) \ lib_a-tmpfile.$(OBJEXT) lib_a-tmpnam.$(OBJEXT) \ - lib_a-ungetc.$(OBJEXT) lib_a-vdiprintf.$(OBJEXT) \ - lib_a-vdprintf.$(OBJEXT) lib_a-viprintf.$(OBJEXT) \ - lib_a-viscanf.$(OBJEXT) lib_a-vprintf.$(OBJEXT) \ - lib_a-vscanf.$(OBJEXT) lib_a-vsiprintf.$(OBJEXT) \ - lib_a-vsiscanf.$(OBJEXT) lib_a-vsnprintf.$(OBJEXT) \ - lib_a-vsniprintf.$(OBJEXT) lib_a-vsprintf.$(OBJEXT) \ + lib_a-ungetc.$(OBJEXT) lib_a-vdprintf.$(OBJEXT) \ + lib_a-vprintf.$(OBJEXT) lib_a-vscanf.$(OBJEXT) \ + lib_a-vsnprintf.$(OBJEXT) lib_a-vsprintf.$(OBJEXT) \ lib_a-vsscanf.$(OBJEXT) lib_a-wbuf.$(OBJEXT) \ lib_a-wsetup.$(OBJEXT) -@ELIX_LEVEL_1_FALSE@am__objects_2 = lib_a-asiprintf.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_3 = lib_a-asiprintf.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vasiprintf.$(OBJEXT) +@ELIX_LEVEL_1_FALSE@am__objects_4 = $(am__objects_3) \ @ELIX_LEVEL_1_FALSE@ lib_a-asprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@ lib_a-fcloseall.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@ lib_a-fseeko.$(OBJEXT) \ @@ -119,11 +129,12 @@ am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-fclose.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@ lib_a-getw.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@ lib_a-mktemp.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@ lib_a-putw.$(OBJEXT) \ -@ELIX_LEVEL_1_FALSE@ lib_a-vasiprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@ lib_a-vasprintf.$(OBJEXT) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_3 = lib_a-asniprintf.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_5 = lib_a-asniprintf.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-diprintf.$(OBJEXT) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ lib_a-vasniprintf.$(OBJEXT) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_6 = $(am__objects_5) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-asnprintf.$(OBJEXT) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-diprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-dprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetwc.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-fgetws.$(OBJEXT) \ @@ -144,7 +155,6 @@ am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-fclose.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swscanf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-ungetwc.$(OBJEXT) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vasniprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vasnprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vfwscanf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vswprintf.$(OBJEXT) \ @@ -153,32 +163,40 @@ am__objects_1 = lib_a-clearerr.$(OBJEXT) lib_a-fclose.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-vwscanf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-wprintf.$(OBJEXT) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-wscanf.$(OBJEXT) -@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ -@USE_LIBTOOL_FALSE@ $(am__objects_2) $(am__objects_3) +@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_2) \ +@USE_LIBTOOL_FALSE@ $(am__objects_4) $(am__objects_6) lib_a_OBJECTS = $(am_lib_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) -am__objects_4 = clearerr.lo fclose.lo fdopen.lo feof.lo ferror.lo \ - fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \ - fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo fputs.lo \ - fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_7 = fiprintf.lo fiscanf.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ iprintf.lo iscanf.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ siprintf.lo siscanf.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ sniprintf.lo vdiprintf.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ viprintf.lo viscanf.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vsiprintf.lo vsiscanf.lo \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vsniprintf.lo +am__objects_8 = $(am__objects_7) clearerr.lo fclose.lo fdopen.lo \ + feof.lo ferror.lo fflush.lo fgetc.lo fgetpos.lo fgets.lo \ + fileno.lo findfp.lo flags.lo fopen.lo fprintf.lo fputc.lo \ + fputs.lo fread.lo freopen.lo fscanf.lo fseek.lo fsetpos.lo \ ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \ getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \ - iprintf.lo iscanf.lo makebuf.lo perror.lo printf.lo putc.lo \ - putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \ - rename.lo rewind.lo rget.lo scanf.lo sccl.lo setbuf.lo \ - setbuffer.lo setlinebuf.lo setvbuf.lo siprintf.lo siscanf.lo \ - sniprintf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \ - tmpfile.lo tmpnam.lo ungetc.lo vdiprintf.lo vdprintf.lo \ - viprintf.lo viscanf.lo vprintf.lo vscanf.lo vsiprintf.lo \ - vsiscanf.lo vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \ - wbuf.lo wsetup.lo -@ELIX_LEVEL_1_FALSE@am__objects_5 = asiprintf.lo asprintf.lo \ + makebuf.lo perror.lo printf.lo putc.lo putchar.lo putc_u.lo \ + putchar_u.lo puts.lo refill.lo remove.lo rename.lo rewind.lo \ + rget.lo scanf.lo sccl.lo setbuf.lo setbuffer.lo setlinebuf.lo \ + setvbuf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \ + tmpfile.lo tmpnam.lo ungetc.lo vdprintf.lo vprintf.lo \ + vscanf.lo vsnprintf.lo vsprintf.lo vsscanf.lo wbuf.lo \ + wsetup.lo +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_9 = asiprintf.lo \ +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ vasiprintf.lo +@ELIX_LEVEL_1_FALSE@am__objects_10 = $(am__objects_9) asprintf.lo \ @ELIX_LEVEL_1_FALSE@ fcloseall.lo fseeko.lo ftello.lo getw.lo \ -@ELIX_LEVEL_1_FALSE@ mktemp.lo putw.lo vasiprintf.lo \ -@ELIX_LEVEL_1_FALSE@ vasprintf.lo -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_6 = asniprintf.lo \ +@ELIX_LEVEL_1_FALSE@ mktemp.lo putw.lo vasprintf.lo +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_11 = asniprintf.lo \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ diprintf.lo \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ vasniprintf.lo +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_12 = $(am__objects_11) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ asnprintf.lo \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ diprintf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ dprintf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetwc.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetws.lo \ @@ -199,7 +217,6 @@ am__objects_4 = clearerr.lo fclose.lo fdopen.lo feof.lo ferror.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swprintf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ungetwc.lo \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vasniprintf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vasnprintf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vfwscanf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vswprintf.lo \ @@ -208,8 +225,8 @@ am__objects_4 = clearerr.lo fclose.lo fdopen.lo feof.lo ferror.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vwscanf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wprintf.lo \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wscanf.lo -@USE_LIBTOOL_TRUE@am_libstdio_la_OBJECTS = $(am__objects_4) \ -@USE_LIBTOOL_TRUE@ $(am__objects_5) $(am__objects_6) +@USE_LIBTOOL_TRUE@am_libstdio_la_OBJECTS = $(am__objects_8) \ +@USE_LIBTOOL_TRUE@ $(am__objects_10) $(am__objects_12) libstdio_la_OBJECTS = $(am_libstdio_la_OBJECTS) libstdio_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -382,7 +399,24 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) +@NEWLIB_NANO_FORMATTED_IO_FALSE@GENERAL_INT_FORMATTED_IO_SOURCES = \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ fiprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ fiscanf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ iprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ iscanf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ siprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ siscanf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ sniprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vdiprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ viprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ viscanf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vsiprintf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vsiscanf.c \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vsniprintf.c + +@NEWLIB_NANO_FORMATTED_IO_TRUE@GENERAL_INT_FORMATTED_IO_SOURCES = GENERAL_SOURCES = \ + $(GENERAL_INT_FORMATTED_IO_SOURCES) \ clearerr.c \ fclose.c \ fdopen.c \ @@ -394,7 +428,6 @@ GENERAL_SOURCES = \ fgets.c \ fileno.c \ findfp.c \ - fiprintf.c \ flags.c \ fopen.c \ fprintf.c \ @@ -403,7 +436,6 @@ GENERAL_SOURCES = \ fread.c \ freopen.c \ fscanf.c \ - fiscanf.c \ fseek.c \ fsetpos.c \ ftell.c \ @@ -417,8 +449,6 @@ GENERAL_SOURCES = \ getdelim.c \ getline.c \ gets.c \ - iprintf.c \ - iscanf.c \ makebuf.c \ perror.c \ printf.c \ @@ -438,9 +468,6 @@ GENERAL_SOURCES = \ setbuffer.c \ setlinebuf.c \ setvbuf.c \ - siprintf.c \ - siscanf.c \ - sniprintf.c \ snprintf.c \ sprintf.c \ sscanf.c \ @@ -448,23 +475,17 @@ GENERAL_SOURCES = \ tmpfile.c \ tmpnam.c \ ungetc.c \ - vdiprintf.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 @ELIX_LEVEL_1_FALSE@ELIX_2_SOURCES = \ -@ELIX_LEVEL_1_FALSE@ asiprintf.c \ +@ELIX_LEVEL_1_FALSE@ $(ELIX_2_INT_FORMATTED_IO_SOURCES) \ @ELIX_LEVEL_1_FALSE@ asprintf.c \ @ELIX_LEVEL_1_FALSE@ fcloseall.c \ @ELIX_LEVEL_1_FALSE@ fseeko.c \ @@ -472,14 +493,17 @@ GENERAL_SOURCES = \ @ELIX_LEVEL_1_FALSE@ getw.c \ @ELIX_LEVEL_1_FALSE@ mktemp.c \ @ELIX_LEVEL_1_FALSE@ putw.c \ -@ELIX_LEVEL_1_FALSE@ vasiprintf.c \ @ELIX_LEVEL_1_FALSE@ vasprintf.c @ELIX_LEVEL_1_TRUE@ELIX_2_SOURCES = +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ELIX_2_INT_FORMATTED_IO_SOURCES = \ +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ asiprintf.c \ +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ vasiprintf.c + +@ELIX_LEVEL_1_FALSE@@NEWLIB_NANO_FORMATTED_IO_TRUE@ELIX_2_INT_FORMATTED_IO_SOURCES = @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ELIX_4_SOURCES = \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ asniprintf.c \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(ELIX_4_INT_FORMATTED_IO_SOURCES) \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ asnprintf.c \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ diprintf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ dprintf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetwc.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ fgetws.c \ @@ -500,7 +524,6 @@ GENERAL_SOURCES = \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swprintf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ungetwc.c \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vasniprintf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vasnprintf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vfwscanf.c \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ vswprintf.c \ @@ -513,15 +536,39 @@ GENERAL_SOURCES = \ @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ELIX_4_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) \ - $(lpfx)svfiwprintf.$(oext) $(lpfx)svfwprintf.$(oext) \ - $(lpfx)vfiwprintf.$(oext) $(lpfx)vfwprintf.$(oext) \ - $(lpfx)svfiwscanf.$(oext) $(lpfx)svfwscanf.$(oext) \ - $(lpfx)vfiwscanf.$(oext) $(lpfx)vfwscanf.$(oext) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ELIX_4_INT_FORMATTED_IO_SOURCES = \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ asniprintf.c \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ diprintf.c \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ vasniprintf.c + +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@NEWLIB_NANO_FORMATTED_IO_TRUE@ELIX_4_INT_FORMATTED_IO_SOURCES = +@NEWLIB_NANO_FORMATTED_IO_FALSE@LIBADD_OBJS = \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)svfiprintf.$(oext) $(lpfx)svfprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)svfiscanf.$(oext) $(lpfx)svfscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)vfiprintf.$(oext) $(lpfx)vfprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)vfscanf.$(oext) $(lpfx)vfiscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)svfiwprintf.$(oext) $(lpfx)svfwprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)vfiwprintf.$(oext) $(lpfx)vfwprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)svfiwscanf.$(oext) $(lpfx)svfwscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ $(lpfx)vfiwscanf.$(oext) $(lpfx)vfwscanf.$(oext) + +@NEWLIB_NANO_FORMATTED_IO_TRUE@LIBADD_OBJS = \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-vfprintf_float.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-svfprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-svfscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-vfprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-vfprintf_i.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-vfscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-vfscanf_i.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)nano-vfscanf_float.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)svfiwprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)svfwprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)vfiwprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)vfwprintf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)svfiwscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)svfwscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)vfiwscanf.$(oext) \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(lpfx)vfwscanf.$(oext) libstdio_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libstdio.la @@ -537,9 +584,26 @@ libstdio_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIBADD_OBJS) @USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS) @USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIBADD_OBJS) +@NEWLIB_NANO_FORMATTED_IO_FALSE@CHEWOUT_INT_FORMATTED_IO_FILES = \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ diprintf.def \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ siprintf.def \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ siscanf.def \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vfprintf.def \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ vfscanf.def \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ viprintf.def \ +@NEWLIB_NANO_FORMATTED_IO_FALSE@ viscanf.def + +@NEWLIB_NANO_FORMATTED_IO_TRUE@CHEWOUT_INT_FORMATTED_IO_FILES = \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ nano-vfprintf.def \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ nano-vfprintf_i.def \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ nano-vfprintf_float.def \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ nano-vfscanf.def \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ nano-vfscanf_i.def \ +@NEWLIB_NANO_FORMATTED_IO_TRUE@ nano-vfscanf_float.def + CHEWOUT_FILES = \ + $(CHEWOUT_INT_FORMATTED_IO_FILES) \ clearerr.def \ - diprintf.def \ dprintf.def \ fclose.def \ fcloseall.def \ @@ -597,8 +661,6 @@ CHEWOUT_FILES = \ setbuffer.def \ setlinebuf.def \ setvbuf.def \ - siprintf.def \ - siscanf.def \ sprintf.def \ sscanf.def \ swprintf.def \ @@ -607,12 +669,8 @@ CHEWOUT_FILES = \ tmpnam.def \ ungetc.def \ ungetwc.def \ - vfprintf.def \ - vfscanf.def \ vfwprintf.def \ - vfwscanf.def \ - viprintf.def \ - viscanf.def + vfwscanf.def SUFFIXES = .def CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str @@ -687,6 +745,84 @@ distclean-compile: .c.lo: $(LTCOMPILE) -c -o $@ $< +lib_a-fiprintf.o: fiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiprintf.o `test -f 'fiprintf.c' || echo '$(srcdir)/'`fiprintf.c + +lib_a-fiprintf.obj: fiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiprintf.obj `if test -f 'fiprintf.c'; then $(CYGPATH_W) 'fiprintf.c'; else $(CYGPATH_W) '$(srcdir)/fiprintf.c'; fi` + +lib_a-fiscanf.o: fiscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiscanf.o `test -f 'fiscanf.c' || echo '$(srcdir)/'`fiscanf.c + +lib_a-fiscanf.obj: fiscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiscanf.obj `if test -f 'fiscanf.c'; then $(CYGPATH_W) 'fiscanf.c'; else $(CYGPATH_W) '$(srcdir)/fiscanf.c'; fi` + +lib_a-iprintf.o: iprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iprintf.o `test -f 'iprintf.c' || echo '$(srcdir)/'`iprintf.c + +lib_a-iprintf.obj: iprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iprintf.obj `if test -f 'iprintf.c'; then $(CYGPATH_W) 'iprintf.c'; else $(CYGPATH_W) '$(srcdir)/iprintf.c'; fi` + +lib_a-iscanf.o: iscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iscanf.o `test -f 'iscanf.c' || echo '$(srcdir)/'`iscanf.c + +lib_a-iscanf.obj: iscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iscanf.obj `if test -f 'iscanf.c'; then $(CYGPATH_W) 'iscanf.c'; else $(CYGPATH_W) '$(srcdir)/iscanf.c'; fi` + +lib_a-siprintf.o: siprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siprintf.o `test -f 'siprintf.c' || echo '$(srcdir)/'`siprintf.c + +lib_a-siprintf.obj: siprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siprintf.obj `if test -f 'siprintf.c'; then $(CYGPATH_W) 'siprintf.c'; else $(CYGPATH_W) '$(srcdir)/siprintf.c'; fi` + +lib_a-siscanf.o: siscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siscanf.o `test -f 'siscanf.c' || echo '$(srcdir)/'`siscanf.c + +lib_a-siscanf.obj: siscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siscanf.obj `if test -f 'siscanf.c'; then $(CYGPATH_W) 'siscanf.c'; else $(CYGPATH_W) '$(srcdir)/siscanf.c'; fi` + +lib_a-sniprintf.o: sniprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sniprintf.o `test -f 'sniprintf.c' || echo '$(srcdir)/'`sniprintf.c + +lib_a-sniprintf.obj: sniprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sniprintf.obj `if test -f 'sniprintf.c'; then $(CYGPATH_W) 'sniprintf.c'; else $(CYGPATH_W) '$(srcdir)/sniprintf.c'; fi` + +lib_a-vdiprintf.o: vdiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdiprintf.o `test -f 'vdiprintf.c' || echo '$(srcdir)/'`vdiprintf.c + +lib_a-vdiprintf.obj: vdiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdiprintf.obj `if test -f 'vdiprintf.c'; then $(CYGPATH_W) 'vdiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vdiprintf.c'; fi` + +lib_a-viprintf.o: viprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viprintf.o `test -f 'viprintf.c' || echo '$(srcdir)/'`viprintf.c + +lib_a-viprintf.obj: viprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viprintf.obj `if test -f 'viprintf.c'; then $(CYGPATH_W) 'viprintf.c'; else $(CYGPATH_W) '$(srcdir)/viprintf.c'; fi` + +lib_a-viscanf.o: viscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viscanf.o `test -f 'viscanf.c' || echo '$(srcdir)/'`viscanf.c + +lib_a-viscanf.obj: viscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viscanf.obj `if test -f 'viscanf.c'; then $(CYGPATH_W) 'viscanf.c'; else $(CYGPATH_W) '$(srcdir)/viscanf.c'; fi` + +lib_a-vsiprintf.o: vsiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiprintf.o `test -f 'vsiprintf.c' || echo '$(srcdir)/'`vsiprintf.c + +lib_a-vsiprintf.obj: vsiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiprintf.obj `if test -f 'vsiprintf.c'; then $(CYGPATH_W) 'vsiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vsiprintf.c'; fi` + +lib_a-vsiscanf.o: vsiscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiscanf.o `test -f 'vsiscanf.c' || echo '$(srcdir)/'`vsiscanf.c + +lib_a-vsiscanf.obj: vsiscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiscanf.obj `if test -f 'vsiscanf.c'; then $(CYGPATH_W) 'vsiscanf.c'; else $(CYGPATH_W) '$(srcdir)/vsiscanf.c'; fi` + +lib_a-vsniprintf.o: vsniprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsniprintf.o `test -f 'vsniprintf.c' || echo '$(srcdir)/'`vsniprintf.c + +lib_a-vsniprintf.obj: vsniprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsniprintf.obj `if test -f 'vsniprintf.c'; then $(CYGPATH_W) 'vsniprintf.c'; else $(CYGPATH_W) '$(srcdir)/vsniprintf.c'; fi` + lib_a-clearerr.o: clearerr.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-clearerr.o `test -f 'clearerr.c' || echo '$(srcdir)/'`clearerr.c @@ -753,12 +889,6 @@ lib_a-findfp.o: findfp.c lib_a-findfp.obj: findfp.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-findfp.obj `if test -f 'findfp.c'; then $(CYGPATH_W) 'findfp.c'; else $(CYGPATH_W) '$(srcdir)/findfp.c'; fi` -lib_a-fiprintf.o: fiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiprintf.o `test -f 'fiprintf.c' || echo '$(srcdir)/'`fiprintf.c - -lib_a-fiprintf.obj: fiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiprintf.obj `if test -f 'fiprintf.c'; then $(CYGPATH_W) 'fiprintf.c'; else $(CYGPATH_W) '$(srcdir)/fiprintf.c'; fi` - lib_a-flags.o: flags.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-flags.o `test -f 'flags.c' || echo '$(srcdir)/'`flags.c @@ -807,12 +937,6 @@ lib_a-fscanf.o: fscanf.c lib_a-fscanf.obj: fscanf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fscanf.obj `if test -f 'fscanf.c'; then $(CYGPATH_W) 'fscanf.c'; else $(CYGPATH_W) '$(srcdir)/fscanf.c'; fi` -lib_a-fiscanf.o: fiscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiscanf.o `test -f 'fiscanf.c' || echo '$(srcdir)/'`fiscanf.c - -lib_a-fiscanf.obj: fiscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiscanf.obj `if test -f 'fiscanf.c'; then $(CYGPATH_W) 'fiscanf.c'; else $(CYGPATH_W) '$(srcdir)/fiscanf.c'; fi` - lib_a-fseek.o: fseek.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fseek.o `test -f 'fseek.c' || echo '$(srcdir)/'`fseek.c @@ -891,18 +1015,6 @@ lib_a-gets.o: gets.c lib_a-gets.obj: gets.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gets.obj `if test -f 'gets.c'; then $(CYGPATH_W) 'gets.c'; else $(CYGPATH_W) '$(srcdir)/gets.c'; fi` -lib_a-iprintf.o: iprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iprintf.o `test -f 'iprintf.c' || echo '$(srcdir)/'`iprintf.c - -lib_a-iprintf.obj: iprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iprintf.obj `if test -f 'iprintf.c'; then $(CYGPATH_W) 'iprintf.c'; else $(CYGPATH_W) '$(srcdir)/iprintf.c'; fi` - -lib_a-iscanf.o: iscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iscanf.o `test -f 'iscanf.c' || echo '$(srcdir)/'`iscanf.c - -lib_a-iscanf.obj: iscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iscanf.obj `if test -f 'iscanf.c'; then $(CYGPATH_W) 'iscanf.c'; else $(CYGPATH_W) '$(srcdir)/iscanf.c'; fi` - lib_a-makebuf.o: makebuf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-makebuf.o `test -f 'makebuf.c' || echo '$(srcdir)/'`makebuf.c @@ -1017,24 +1129,6 @@ lib_a-setvbuf.o: setvbuf.c lib_a-setvbuf.obj: setvbuf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setvbuf.obj `if test -f 'setvbuf.c'; then $(CYGPATH_W) 'setvbuf.c'; else $(CYGPATH_W) '$(srcdir)/setvbuf.c'; fi` -lib_a-siprintf.o: siprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siprintf.o `test -f 'siprintf.c' || echo '$(srcdir)/'`siprintf.c - -lib_a-siprintf.obj: siprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siprintf.obj `if test -f 'siprintf.c'; then $(CYGPATH_W) 'siprintf.c'; else $(CYGPATH_W) '$(srcdir)/siprintf.c'; fi` - -lib_a-siscanf.o: siscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siscanf.o `test -f 'siscanf.c' || echo '$(srcdir)/'`siscanf.c - -lib_a-siscanf.obj: siscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siscanf.obj `if test -f 'siscanf.c'; then $(CYGPATH_W) 'siscanf.c'; else $(CYGPATH_W) '$(srcdir)/siscanf.c'; fi` - -lib_a-sniprintf.o: sniprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sniprintf.o `test -f 'sniprintf.c' || echo '$(srcdir)/'`sniprintf.c - -lib_a-sniprintf.obj: sniprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sniprintf.obj `if test -f 'sniprintf.c'; then $(CYGPATH_W) 'sniprintf.c'; else $(CYGPATH_W) '$(srcdir)/sniprintf.c'; fi` - lib_a-snprintf.o: snprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-snprintf.o `test -f 'snprintf.c' || echo '$(srcdir)/'`snprintf.c @@ -1077,30 +1171,12 @@ lib_a-ungetc.o: ungetc.c lib_a-ungetc.obj: ungetc.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ungetc.obj `if test -f 'ungetc.c'; then $(CYGPATH_W) 'ungetc.c'; else $(CYGPATH_W) '$(srcdir)/ungetc.c'; fi` -lib_a-vdiprintf.o: vdiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdiprintf.o `test -f 'vdiprintf.c' || echo '$(srcdir)/'`vdiprintf.c - -lib_a-vdiprintf.obj: vdiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdiprintf.obj `if test -f 'vdiprintf.c'; then $(CYGPATH_W) 'vdiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vdiprintf.c'; fi` - lib_a-vdprintf.o: vdprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdprintf.o `test -f 'vdprintf.c' || echo '$(srcdir)/'`vdprintf.c lib_a-vdprintf.obj: vdprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vdprintf.obj `if test -f 'vdprintf.c'; then $(CYGPATH_W) 'vdprintf.c'; else $(CYGPATH_W) '$(srcdir)/vdprintf.c'; fi` -lib_a-viprintf.o: viprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viprintf.o `test -f 'viprintf.c' || echo '$(srcdir)/'`viprintf.c - -lib_a-viprintf.obj: viprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viprintf.obj `if test -f 'viprintf.c'; then $(CYGPATH_W) 'viprintf.c'; else $(CYGPATH_W) '$(srcdir)/viprintf.c'; fi` - -lib_a-viscanf.o: viscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viscanf.o `test -f 'viscanf.c' || echo '$(srcdir)/'`viscanf.c - -lib_a-viscanf.obj: viscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-viscanf.obj `if test -f 'viscanf.c'; then $(CYGPATH_W) 'viscanf.c'; else $(CYGPATH_W) '$(srcdir)/viscanf.c'; fi` - lib_a-vprintf.o: vprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vprintf.o `test -f 'vprintf.c' || echo '$(srcdir)/'`vprintf.c @@ -1113,30 +1189,12 @@ lib_a-vscanf.o: vscanf.c lib_a-vscanf.obj: vscanf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vscanf.obj `if test -f 'vscanf.c'; then $(CYGPATH_W) 'vscanf.c'; else $(CYGPATH_W) '$(srcdir)/vscanf.c'; fi` -lib_a-vsiprintf.o: vsiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiprintf.o `test -f 'vsiprintf.c' || echo '$(srcdir)/'`vsiprintf.c - -lib_a-vsiprintf.obj: vsiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiprintf.obj `if test -f 'vsiprintf.c'; then $(CYGPATH_W) 'vsiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vsiprintf.c'; fi` - -lib_a-vsiscanf.o: vsiscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiscanf.o `test -f 'vsiscanf.c' || echo '$(srcdir)/'`vsiscanf.c - -lib_a-vsiscanf.obj: vsiscanf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsiscanf.obj `if test -f 'vsiscanf.c'; then $(CYGPATH_W) 'vsiscanf.c'; else $(CYGPATH_W) '$(srcdir)/vsiscanf.c'; fi` - lib_a-vsnprintf.o: vsnprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsnprintf.o `test -f 'vsnprintf.c' || echo '$(srcdir)/'`vsnprintf.c lib_a-vsnprintf.obj: vsnprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsnprintf.obj `if test -f 'vsnprintf.c'; then $(CYGPATH_W) 'vsnprintf.c'; else $(CYGPATH_W) '$(srcdir)/vsnprintf.c'; fi` -lib_a-vsniprintf.o: vsniprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsniprintf.o `test -f 'vsniprintf.c' || echo '$(srcdir)/'`vsniprintf.c - -lib_a-vsniprintf.obj: vsniprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsniprintf.obj `if test -f 'vsniprintf.c'; then $(CYGPATH_W) 'vsniprintf.c'; else $(CYGPATH_W) '$(srcdir)/vsniprintf.c'; fi` - lib_a-vsprintf.o: vsprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsprintf.o `test -f 'vsprintf.c' || echo '$(srcdir)/'`vsprintf.c @@ -1167,6 +1225,12 @@ lib_a-asiprintf.o: asiprintf.c lib_a-asiprintf.obj: asiprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asiprintf.obj `if test -f 'asiprintf.c'; then $(CYGPATH_W) 'asiprintf.c'; else $(CYGPATH_W) '$(srcdir)/asiprintf.c'; fi` +lib_a-vasiprintf.o: vasiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasiprintf.o `test -f 'vasiprintf.c' || echo '$(srcdir)/'`vasiprintf.c + +lib_a-vasiprintf.obj: vasiprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasiprintf.obj `if test -f 'vasiprintf.c'; then $(CYGPATH_W) 'vasiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vasiprintf.c'; fi` + lib_a-asprintf.o: asprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asprintf.o `test -f 'asprintf.c' || echo '$(srcdir)/'`asprintf.c @@ -1209,12 +1273,6 @@ lib_a-putw.o: putw.c lib_a-putw.obj: putw.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putw.obj `if test -f 'putw.c'; then $(CYGPATH_W) 'putw.c'; else $(CYGPATH_W) '$(srcdir)/putw.c'; fi` -lib_a-vasiprintf.o: vasiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasiprintf.o `test -f 'vasiprintf.c' || echo '$(srcdir)/'`vasiprintf.c - -lib_a-vasiprintf.obj: vasiprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasiprintf.obj `if test -f 'vasiprintf.c'; then $(CYGPATH_W) 'vasiprintf.c'; else $(CYGPATH_W) '$(srcdir)/vasiprintf.c'; fi` - lib_a-vasprintf.o: vasprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasprintf.o `test -f 'vasprintf.c' || echo '$(srcdir)/'`vasprintf.c @@ -1227,18 +1285,24 @@ lib_a-asniprintf.o: asniprintf.c lib_a-asniprintf.obj: asniprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asniprintf.obj `if test -f 'asniprintf.c'; then $(CYGPATH_W) 'asniprintf.c'; else $(CYGPATH_W) '$(srcdir)/asniprintf.c'; fi` -lib_a-asnprintf.o: asnprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asnprintf.o `test -f 'asnprintf.c' || echo '$(srcdir)/'`asnprintf.c - -lib_a-asnprintf.obj: asnprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asnprintf.obj `if test -f 'asnprintf.c'; then $(CYGPATH_W) 'asnprintf.c'; else $(CYGPATH_W) '$(srcdir)/asnprintf.c'; fi` - lib_a-diprintf.o: diprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-diprintf.o `test -f 'diprintf.c' || echo '$(srcdir)/'`diprintf.c lib_a-diprintf.obj: diprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-diprintf.obj `if test -f 'diprintf.c'; then $(CYGPATH_W) 'diprintf.c'; else $(CYGPATH_W) '$(srcdir)/diprintf.c'; fi` +lib_a-vasniprintf.o: vasniprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasniprintf.o `test -f 'vasniprintf.c' || echo '$(srcdir)/'`vasniprintf.c + +lib_a-vasniprintf.obj: vasniprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasniprintf.obj `if test -f 'vasniprintf.c'; then $(CYGPATH_W) 'vasniprintf.c'; else $(CYGPATH_W) '$(srcdir)/vasniprintf.c'; fi` + +lib_a-asnprintf.o: asnprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asnprintf.o `test -f 'asnprintf.c' || echo '$(srcdir)/'`asnprintf.c + +lib_a-asnprintf.obj: asnprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asnprintf.obj `if test -f 'asnprintf.c'; then $(CYGPATH_W) 'asnprintf.c'; else $(CYGPATH_W) '$(srcdir)/asnprintf.c'; fi` + lib_a-dprintf.o: dprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dprintf.o `test -f 'dprintf.c' || echo '$(srcdir)/'`dprintf.c @@ -1359,12 +1423,6 @@ lib_a-ungetwc.o: ungetwc.c lib_a-ungetwc.obj: ungetwc.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ungetwc.obj `if test -f 'ungetwc.c'; then $(CYGPATH_W) 'ungetwc.c'; else $(CYGPATH_W) '$(srcdir)/ungetwc.c'; fi` -lib_a-vasniprintf.o: vasniprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasniprintf.o `test -f 'vasniprintf.c' || echo '$(srcdir)/'`vasniprintf.c - -lib_a-vasniprintf.obj: vasniprintf.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasniprintf.obj `if test -f 'vasniprintf.c'; then $(CYGPATH_W) 'vasniprintf.c'; else $(CYGPATH_W) '$(srcdir)/vasniprintf.c'; fi` - lib_a-vasnprintf.o: vasnprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vasnprintf.o `test -f 'vasnprintf.c' || echo '$(srcdir)/'`vasnprintf.c @@ -1597,8 +1655,28 @@ objectlist.awk.in: $(noinst_LTLIBRARIES) echo $$i `pwd`/$$i >> objectlist.awk.in ; \ done -# This rule is needed so that libtool compiles vfiprintf before vfprintf. Otherwise -# libtool moves vfprintf.o and subsequently can't find it. +# Though small footprint nano-formatted-IO implementation is used +# when NEWLIB_NANO_FORMATTED_IO is enabled, we keep all rules for +# the other implementation of formatted IO including all i-family +# functions. The object files in !NEWLIB_NANO_FORMATTED_IO version +# implementation will be neither compiled nor archived into final +# library, because they are not depended on by final makefile target. + +# Rules compiling small-footprint nano-formatted-io implementation. +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfprintf.$(oext): nano-vfprintf.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -fshort-enums -c $(srcdir)/nano-vfprintf.c -o $@ + +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfprintf_i.$(oext): nano-vfprintf_i.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -fshort-enums -c $(srcdir)/nano-vfprintf_i.c -o $@ + +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfprintf_float.$(oext): nano-vfprintf_float.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -fshort-enums -c $(srcdir)/nano-vfprintf_float.c -o $@ + +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-svfprintf.$(oext): nano-vfprintf.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -fshort-enums -DSTRING_ONLY -c $(srcdir)/nano-vfprintf.c -o $@ + +# This rule is needed so that libtool compiles vfiprintf before vfprintf. +# Otherwise libtool moves vfprintf.o and subsequently can't find it. $(lpfx)vfprintf.$(oext): vfprintf.c $(LIB_COMPILE) -fshort-enums -c $(srcdir)/vfprintf.c -o $@ @@ -1624,6 +1702,19 @@ $(lpfx)svfwprintf.$(oext): vfwprintf.c $(lpfx)svfiwprintf.$(oext): vfwprintf.c $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfwprintf.c -o $@ +# Rules compiling small-footprint nano-formatted-io implementation. +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfscanf.$(oext): nano-vfscanf.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -c $(srcdir)/nano-vfscanf.c -o $@ + +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfscanf_i.$(oext): nano-vfscanf_i.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -c $(srcdir)/nano-vfscanf_i.c -o $@ + +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfscanf_float.$(oext): nano-vfscanf_float.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -c $(srcdir)/nano-vfscanf_float.c -o $@ + +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-svfscanf.$(oext): nano-vfscanf.c +@NEWLIB_NANO_FORMATTED_IO_TRUE@ $(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/nano-vfscanf.c -o $@ + $(lpfx)vfscanf.$(oext): vfscanf.c $(LIB_COMPILE) -c $(srcdir)/vfscanf.c -o $@ @@ -1697,6 +1788,8 @@ $(lpfx)sniprintf.$(oext): local.h $(lpfx)sprintf.$(oext): local.h $(lpfx)sscanf.$(oext): local.h $(lpfx)stdio.$(oext): local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-svfprintf.$(oext): local.h nano-vfprintf_local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-svfscanf.$(oext): local.h nano-vfscanf_local.h $(lpfx)svfiprintf.$(oext): local.h $(lpfx)svfiscanf.$(oext): local.h floatio.h $(lpfx)svfprintf.$(oext): local.h @@ -1705,6 +1798,12 @@ $(lpfx)swprintf.$(oext): local.h $(lpfx)swscanf.$(oext): local.h $(lpfx)ungetc.$(oext): local.h $(lpfx)ungetwc.$(oext): local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfprintf.$(oext): local.h nano-vfprintf_local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfprintf_i.$(oext): local.h nano-vfprintf_local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfprintf_float.$(oext): local.h floatio.h nano-vfprintf_local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfscanf.$(oext): local.h nano-vfscanf_local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfscanf_i.$(oext): local.h nano-vfscanf_local.h +@NEWLIB_NANO_FORMATTED_IO_TRUE@$(lpfx)nano-vfscanf_float.$(oext): local.h floatio.h nano-vfscanf_local.h $(lpfx)vfiprintf.$(oext): local.h $(lpfx)vfiscanf.$(oext): local.h floatio.h $(lpfx)vfprintf.$(oext): local.h diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.c index a37c50358..2e8d8aabb 100644 --- a/newlib/libc/stdio/asnprintf.c +++ b/newlib/libc/stdio/asnprintf.c @@ -58,6 +58,12 @@ _DEFUN(_asnprintf_r, (ptr, buf, lenp, fmt), return (char *) f._bf._base; } +#ifdef _NANO_FORMATTED_IO +char * +_EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...) + _ATTRIBUTE ((__alias__("_asnprintf_r")))); +#endif + #ifndef _REENT_ONLY char * @@ -105,4 +111,9 @@ _DEFUN(asnprintf, (buf, lenp, fmt), return (char *) f._bf._base; } +#ifdef _NANO_FORMATTED_IO +char * +_EXFUN(asniprintf, (char *, size_t *, const char *, ...) + _ATTRIBUTE ((__alias__("asnprintf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index d04411251..bf214f9af 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -50,6 +50,12 @@ _DEFUN(_asprintf_r, (ptr, strp, fmt), return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...) + _ATTRIBUTE ((__alias__("_asprintf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -77,4 +83,9 @@ _DEFUN(asprintf, (strp, fmt), return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(asiprintf, (char **, const char *, ...) + _ATTRIBUTE ((__alias__("asprintf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/dprintf.c b/newlib/libc/stdio/dprintf.c index 2271f4b5c..2925ceb31 100644 --- a/newlib/libc/stdio/dprintf.c +++ b/newlib/libc/stdio/dprintf.c @@ -67,6 +67,12 @@ _DEFUN(_dprintf_r, (ptr, fd, format), return n; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...) + _ATTRIBUTE ((__alias__("_dprintf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -85,4 +91,9 @@ _DEFUN(dprintf, (fd, format), return n; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(diprintf, (int, const char *, ...) + _ATTRIBUTE ((__alias__("dprintf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/fprintf.c b/newlib/libc/stdio/fprintf.c index 5ea2fd006..fe92a5b99 100644 --- a/newlib/libc/stdio/fprintf.c +++ b/newlib/libc/stdio/fprintf.c @@ -36,6 +36,12 @@ _DEFUN(_fprintf_r, (ptr, fp, fmt), return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...) + _ATTRIBUTE ((__alias__("_fprintf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -52,4 +58,9 @@ _DEFUN(fprintf, (fp, fmt), return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(fiprintf, (FILE *, const char *, ...) + _ATTRIBUTE ((__alias__("fprintf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/fscanf.c b/newlib/libc/stdio/fscanf.c index 04c9e32f1..87b51dd88 100644 --- a/newlib/libc/stdio/fscanf.c +++ b/newlib/libc/stdio/fscanf.c @@ -50,6 +50,12 @@ fscanf(FILE *fp, fmt, va_alist) return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(fiscanf, (FILE *, const char *, ...) + _ATTRIBUTE ((__alias__("fscanf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -76,3 +82,8 @@ _fscanf_r(ptr, FILE *fp, fmt, va_alist) return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...) + _ATTRIBUTE ((__alias__("_fscanf_r")))); +#endif diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c new file mode 100644 index 000000000..f106a4167 --- /dev/null +++ b/newlib/libc/stdio/nano-vfprintf.c @@ -0,0 +1,665 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 2012-2014 ARM Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* +FUNCTION +<>, <>, <>, <>, <>, <>---format argument list + +INDEX + vfprintf +INDEX + _vfprintf_r +INDEX + vprintf +INDEX + _vprintf_r +INDEX + vsprintf +INDEX + _vsprintf_r +INDEX + vsnprintf +INDEX + _vsnprintf_r +INDEX + vasprintf +INDEX + _vasprintf_r +INDEX + vasnprintf +INDEX + _vasnprintf_r + +ANSI_SYNOPSIS + #include + #include + int vprintf(const char *<[fmt]>, va_list <[list]>); + int vfprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); + int vsprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>); + int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, + va_list <[list]>); + int vasprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>); + char *vasnprintf(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 _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, + const char *<[fmt]>, va_list <[list]>); + int _vasprintf_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]>); + char *_vasnprintf_r(struct _reent *<[reent]>, char *<[str]>, + size_t *<[size]>, const char *<[fmt]>, va_list <[list]>); + +DESCRIPTION +<>, <>, <>, <>, <>, +and <> are (respectively) variants of <>, +<>, <>, <>, <>, and +<>. They differ only in allowing their caller to pass the +variable argument list as a <> object (initialized by +<>) rather than directly accepting a variable number of +arguments. The caller is responsible for calling <>. + +<<_vprintf_r>>, <<_vfprintf_r>>, <<_vasprintf_r>>, <<_vsprintf_r>>, +<<_vsnprintf_r>>, and <<_vasnprintf_r>> are reentrant versions of the +above. + +RETURNS +The return values are consistent with the corresponding functions. + +PORTABILITY +ANSI C requires <>, <>, <>, and +<>. The remaining functions are newlib extensions. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";*/ +static char *rcsid = "$Id$"; +#endif /* LIBC_SCCS and not lint */ + +/* Actual printf innards. + This code is large and complicated... */ +#include + +#define VFPRINTF vfprintf +#ifdef STRING_ONLY +# define _VFPRINTF_R _svfprintf_r +#else +# define _VFPRINTF_R _vfprintf_r +#endif + +#include <_ansi.h> +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "local.h" +#include "../stdlib/local.h" +#include "fvwrite.h" +#include "vfieeefp.h" +#include "nano-vfprintf_local.h" + +/* The __ssputs_r function is shared between all versions of vfprintf + and vfwprintf. */ +#ifdef STRING_ONLY +int +_DEFUN(__ssputs_r, (ptr, fp, buf, len), + struct _reent *ptr _AND + FILE *fp _AND + _CONST char *buf _AND + size_t len) +{ + register int w; + + w = fp->_w; + if (len >= w && fp->_flags & (__SMBF | __SOPT)) + { + /* Must be asprintf family. */ + unsigned char *str; + int curpos = (fp->_p - fp->_bf._base); + /* Choose a geometric growth factor to avoid + * quadratic realloc behavior, but use a rate less + * than (1+sqrt(5))/2 to accomodate malloc + * overhead. asprintf EXPECTS us to overallocate, so + * that it can add a trailing \0 without + * reallocating. The new allocation should thus be + * max(prev_size*1.5, curpos+len+1). */ + int newsize = fp->_bf._size * 3 / 2; + if (newsize < curpos + len + 1) + newsize = curpos + len + 1; + if (fp->_flags & __SOPT) + { + /* asnprintf leaves original buffer alone. */ + str = (unsigned char *)_malloc_r (ptr, newsize); + if (!str) + { + 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) buf, (size_t) (w)); + fp->_w -= w; + fp->_p += w; + return 0; + +err: + fp->_flags |= __SERR; + return EOF; +} +/* __ssprint_r is the original implementation of __SPRINT. In nano + version formatted IO it is reimplemented as __ssputs_r for non-wide + char output, but __ssprint_r cannot be discarded because it is used + by a serial of functions like svfwprintf for wide char output. */ +int +_DEFUN(__ssprint_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; + /* Pretend we copied all. */ + w = len; + 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 +/* As __ssputs_r, __sprint_r is used by output functions for wide char, + like vfwprint. */ +/* Flush out all the vectors defined by the given uio, + then reset it so that it can be reused. */ +int +_DEFUN(__sprint_r, (ptr, fp, uio), + struct _reent *ptr _AND + FILE *fp _AND + register struct __suio *uio) +{ + register int err = 0; + + if (uio->uio_resid == 0) + { + uio->uio_iovcnt = 0; + return 0; + } +#ifdef _WIDE_ORIENT + if (fp->_flags2 & __SWID) + { + struct __siov *iov; + wchar_t *p; + int i, len; + + iov = uio->uio_iov; + for (; uio->uio_resid != 0; + uio->uio_resid -= len * sizeof (wchar_t), iov++) + { + p = (wchar_t *) iov->iov_base; + len = iov->iov_len / sizeof (wchar_t); + for (i = 0; i < len; i++) + { + if (_fputwc_r (ptr, p[i], fp) == WEOF) + { + err = -1; + goto out; + } + } + } + } + else +#endif + err = __sfvwrite_r(ptr, fp, uio); +out: + uio->uio_resid = 0; + uio->uio_iovcnt = 0; + return err; +} + +_NOINLINE_STATIC int +_DEFUN(__sfputc_r, (ptr, c, fp), + struct _reent *ptr _AND + int c _AND + FILE *fp) +{ + if (--fp->_w >= 0 || (fp->_w >= fp->_lbfsize && (char)c != '\n')) + return (*fp->_p++ = c); + else + return (__swbuf_r(ptr, c, fp)); +} + +int +_DEFUN(__sfputs_r, (ptr, fp, buf, len), + struct _reent *ptr _AND + FILE *fp _AND + _CONST char *buf _AND + size_t len) +{ + register int i; + +#ifdef _WIDE_ORIENT + if (fp->_flags2 & __SWID) + { + wchar_t *p; + + p = (wchar_t *) buf; + for (i = 0; i < (len / sizeof (wchar_t)); i++) + { + if (_fputwc_r (ptr, p[i], fp) == WEOF) + return -1; + } + } + else +#endif + { + for (i = 0; i < len; i++) + { + /* Call __sfputc_r to skip _fputc_r. */ + if (__sfputc_r (ptr, (int)buf[i], fp) == EOF) + return -1; + } + } + return (0); +} +#endif /* STRING_ONLY. */ + +int _EXFUN(_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); + +#ifndef STRING_ONLY +int +_DEFUN(VFPRINTF, (fp, fmt0, ap), + FILE * fp _AND + _CONST char *fmt0 _AND + va_list ap) +{ + int result; + result = _VFPRINTF_R (_REENT, fp, fmt0, ap); + return result; +} + +int +_EXFUN(vfiprintf, (FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vfprintf")))); +#endif + +#ifdef STRING_ONLY +# define __SPRINT __ssputs_r +#else +# define __SPRINT __sfputs_r +#endif + +/* Do not need FLUSH for all sprintf functions. */ +#ifdef STRING_ONLY +# define FLUSH() +#else +# define FLUSH() +#endif + +int +_DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), + struct _reent *data _AND + FILE * fp _AND + _CONST char *fmt0 _AND + va_list ap) +{ + register char *fmt; /* Format string. */ + register int n, m; /* Handy integers (short term usage). */ + register char *cp; /* Handy char pointer (short term usage). */ + const char *flag_chars; + struct _prt_data_t prt_data; /* All data for decoding format string. */ + + /* Output function pointer. */ + int (*pfunc)(struct _reent *, FILE *, _CONST char *, size_t len); + + pfunc = __SPRINT; + +#ifndef STRING_ONLY + /* Initialize std streams if not dealing with sprintf family. */ + CHECK_INIT (data, fp); + _newlib_flockfile_start (fp); + + /* Sorry, fprintf(read_only_file, "") returns EOF, not 0. */ + if (cantwrite (data, fp)) + { + _newlib_flockfile_exit (fp); + return (EOF); + } + +#else + /* 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 + + fmt = (char *)fmt0; + prt_data.ret = 0; + prt_data.blank = ' '; + prt_data.zero = '0'; + + /* Scan the format for conversions (`%' character). */ + for (;;) + { + cp = fmt; + while (*fmt != '\0' && *fmt != '%') + fmt += 1; + + if ((m = fmt - cp) != 0) + { + PRINT (cp, m); + prt_data.ret += m; + } + if (*fmt == '\0') + goto done; + + fmt++; /* Skip over '%'. */ + + prt_data.flags = 0; + prt_data.width = 0; + prt_data.prec = -1; + prt_data.dprec = 0; + prt_data.l_buf[0] = '\0'; +#ifdef FLOATING_POINT + prt_data.lead = 0; +#endif + /* The flags. */ + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flag_chars = "#-0+ "; + for (; cp = memchr (flag_chars, *fmt, 5); fmt++) + prt_data.flags |= (1 << (cp - flag_chars)); + + if (prt_data.flags & SPACESGN) + prt_data.l_buf[0] = ' '; + + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (prt_data.flags & PLUSSGN) + prt_data.l_buf[0] = '+'; + + /* The width. */ + if (*fmt == '*') + { + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + prt_data.width = GET_ARG (n, ap, int); + if (prt_data.width < 0) + { + prt_data.width = -prt_data.width; + prt_data.flags |= LADJUST; + } + fmt++; + } + else + { + for (; is_digit (*fmt); fmt++) + prt_data.width = 10 * prt_data.width + to_digit (*fmt); + } + + /* The precision. */ + if (*fmt == '.') + { + fmt++; + if (*fmt == '*') + { + fmt++; + prt_data.prec = GET_ARG (n, ap, int); + if (prt_data.prec < 0) + prt_data.prec = -1; + } + else + { + prt_data.prec = 0; + for (; is_digit (*fmt); fmt++) + prt_data.prec = 10 * prt_data.prec + to_digit (*fmt); + } + } + + /* The length modifiers. */ + flag_chars = "hlL"; + if ((cp = memchr (flag_chars, *fmt, 3)) != NULL) + { + prt_data.flags |= (SHORTINT << (cp - flag_chars)); + fmt++; + } + + /* The conversion specifiers. */ + prt_data.code = *fmt++; + cp = memchr ("efgEFG", prt_data.code, 6); +#ifdef FLOATING_POINT + /* If cp is not NULL, we are facing FLOATING POINT NUMBER. */ + if (cp) + { + /* Consume floating point argument if _printf_float is not + linked. */ + if (_printf_float == NULL) + { + if (prt_data.flags & LONGDBL) + GET_ARG (N, ap, _LONG_DOUBLE); + else + GET_ARG (N, ap, double); + } + else + { + n = _printf_float (data, &prt_data, fp, pfunc, &ap); + } + } + else +#endif + n = _printf_i (data, &prt_data, fp, pfunc, &ap); + + if (n == -1) + goto error; + + prt_data.ret += n; + } +done: + FLUSH (); +error: +#ifndef STRING_ONLY + _newlib_flockfile_end (fp); +#endif + return (__sferror (fp) ? EOF : prt_data.ret); +} + +#ifdef STRING_ONLY +int +_EXFUN(_svfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_svfprintf_r")))); +#else +int +_EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vfprintf_r")))); +#endif diff --git a/newlib/libc/stdio/nano-vfprintf_float.c b/newlib/libc/stdio/nano-vfprintf_float.c new file mode 100644 index 000000000..aca24aec0 --- /dev/null +++ b/newlib/libc/stdio/nano-vfprintf_float.c @@ -0,0 +1,364 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include <_ansi.h> +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "local.h" +#include "../stdlib/local.h" +#include "fvwrite.h" +#include "vfieeefp.h" +#include "nano-vfprintf_local.h" + +char *__cvt (struct _reent *data, _PRINTF_FLOAT_TYPE value, int ndigits, + int flags, char *sign, int *decpt, int ch, int *length, + char *buf); + +int __exponent (char *p0, int exp, int fmtch); + +#ifdef FLOATING_POINT + +/* Using reentrant DATA, convert finite VALUE into a string of digits + with no decimal point, using NDIGITS precision and FLAGS as guides + to whether trailing zeros must be included. Set *SIGN to nonzero + if VALUE was negative. Set *DECPT to the exponent plus one. Set + *LENGTH to the length of the returned string. CH must be one of + [aAeEfFgG]; if it is [aA], then the return string lives in BUF, + otherwise the return value shares the mprec reentrant storage. */ +char * +__cvt (struct _reent *data, _PRINTF_FLOAT_TYPE value, int ndigits, int flags, + char *sign, int *decpt, int ch, int *length, char *buf) +{ + int mode, dsgn; + char *digits, *bp, *rve; + union double_union tmp; + + tmp.d = value; + /* This will check for "< 0" and "-0.0". */ + if (word0 (tmp) & Sign_bit) + { + value = -value; + *sign = '-'; + } + else + *sign = '\000'; + + if (ch == 'f' || ch == 'F') + { + /* Ndigits after the decimal point. */ + mode = 3; + } + else + { + /* To obtain ndigits after the decimal point for the 'e' + and 'E' formats, round to ndigits + 1 significant figures. */ + if (ch == 'e' || ch == 'E') + { + ndigits++; + } + /* Ndigits significant digits. */ + mode = 2; + } + + digits = _DTOA_R (data, value, mode, ndigits, decpt, &dsgn, &rve); + + /* Print trailing zeros. */ + if ((ch != 'g' && ch != 'G') || flags & ALT) + { + bp = digits + ndigits; + if (ch == 'f' || ch == 'F') + { + if (*digits == '0' && value) + *decpt = -ndigits + 1; + bp += *decpt; + } + /* Kludge for __dtoa irregularity. */ + if (value == 0) + rve = bp; + while (rve < bp) + *rve++ = '0'; + } + *length = rve - digits; + return (digits); +} + +/* This function is copied from exponent in vfprintf.c with support for + C99 formats removed. We don't use the original function in order to + decouple nano implementation of formatted IO from the Newlib one. */ +int +__exponent (char *p0, int exp, int fmtch) +{ + register char *p, *t; + char expbuf[MAXEXPLEN]; +#define isa 0 + + p = p0; + *p++ = isa ? 'p' - 'a' + fmtch : fmtch; + if (exp < 0) + { + exp = -exp; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXPLEN; + if (exp > 9) + { + do + { + *--t = to_char (exp % 10); + } + while ((exp /= 10) > 9); + *--t = to_char (exp); + for (; t < expbuf + MAXEXPLEN; *p++ = *t++); + } + else + { + if (!isa) + *p++ = '0'; + *p++ = to_char (exp); + } + return (p - p0); +} + +/* Decode and print floating point number specified by "eEfgG". */ +int +_printf_float (struct _reent *data, + struct _prt_data_t *pdata, + FILE * fp, + int (*pfunc) (struct _reent *, FILE *, _CONST char *, + size_t len), va_list * ap) +{ +#define _fpvalue (pdata->_double_) + + char *decimal_point = _localeconv_r (data)->decimal_point; + size_t decp_len = strlen (decimal_point); + /* Temporary negative sign for floats. */ + char softsign; + /* Integer value of exponent. */ + int expt; + /* Character count for expstr. */ + int expsize = 0; + /* Actual number of digits returned by cvt. */ + int ndig = 0; + char *cp; + int n; + /* Field size expanded by dprec(not for _printf_float). */ + int realsz; + char code = pdata->code; + + if (pdata->flags & LONGDBL) + { + _fpvalue = (double) GET_ARG (N, *ap, _LONG_DOUBLE); + } + else + { + _fpvalue = GET_ARG (N, *ap, double); + } + + /* Do this before tricky precision changes. + + If the output is infinite or NaN, leading + zeros are not permitted. Otherwise, scanf + could not read what printf wrote. */ + if (isinf (_fpvalue)) + { + if (_fpvalue < 0) + pdata->l_buf[0] = '-'; + if (code <= 'G') /* 'A', 'E', 'F', or 'G'. */ + cp = "INF"; + else + cp = "inf"; + pdata->size = 3; + pdata->flags &= ~ZEROPAD; + goto print_float; + } + if (isnan (_fpvalue)) + { + if (code <= 'G') /* 'A', 'E', 'F', or 'G'. */ + cp = "NAN"; + else + cp = "nan"; + pdata->size = 3; + pdata->flags &= ~ZEROPAD; + goto print_float; + } + + if (pdata->prec == -1) + { + pdata->prec = DEFPREC; + } + else if ((code == 'g' || code == 'G') && pdata->prec == 0) + { + pdata->prec = 1; + } + + pdata->flags |= FPT; + + cp = __cvt (data, _fpvalue, pdata->prec, pdata->flags, &softsign, + &expt, code, &ndig, cp); + + if (code == 'g' || code == 'G') + { + if (expt <= -4 || expt > pdata->prec) + /* 'e' or 'E'. */ + code -= 2; + else + code = 'g'; + } + if (code <= 'e') + { + /* 'a', 'A', 'e', or 'E' fmt. */ + --expt; + expsize = __exponent (pdata->expstr, expt, code); + pdata->size = expsize + ndig; + if (ndig > 1 || pdata->flags & ALT) + ++pdata->size; + } + else + { + if (code == 'f') + { + /* 'f' fmt. */ + if (expt > 0) + { + pdata->size = expt; + if (pdata->prec || pdata->flags & ALT) + pdata->size += pdata->prec + 1; + } + else + /* "0.X". */ + pdata->size = (pdata->prec || pdata->flags & ALT) + ? pdata->prec + 2 : 1; + } + else if (expt >= ndig) + { + /* Fixed g fmt. */ + pdata->size = expt; + if (pdata->flags & ALT) + ++pdata->size; + } + else + pdata->size = ndig + (expt > 0 ? 1 : 2 - expt); + pdata->lead = expt; + } + + if (softsign) + pdata->l_buf[0] = '-'; +print_float: + if (_printf_common (data, pdata, &realsz, fp, pfunc) == -1) + goto error; + + if ((pdata->flags & FPT) == 0) + { + PRINT (cp, pdata->size); + } + else + { + /* Glue together f_p fragments. */ + if (code >= 'f') + { + /* 'f' or 'g'. */ + if (_fpvalue == 0) + { + /* Kludge for __dtoa irregularity. */ + PRINT ("0", 1); + if (expt < ndig || pdata->flags & ALT) + { + PRINT (decimal_point, decp_len); + PAD (ndig - 1, pdata->zero); + } + } + else if (expt <= 0) + { + PRINT ("0", 1); + if (expt || ndig || pdata->flags & ALT) + { + PRINT (decimal_point, decp_len); + PAD (-expt, pdata->zero); + PRINT (cp, ndig); + } + } + else + { + char *convbuf = cp; + PRINTANDPAD (cp, convbuf + ndig, pdata->lead, pdata->zero); + cp += pdata->lead; + if (expt < ndig || pdata->flags & ALT) + PRINT (decimal_point, decp_len); + PRINTANDPAD (cp, convbuf + ndig, ndig - expt, pdata->zero); + } + } + else + { + /* 'a', 'A', 'e', or 'E'. */ + if (ndig > 1 || pdata->flags & ALT) + { + PRINT (cp, 1); + cp++; + PRINT (decimal_point, decp_len); + if (_fpvalue) + { + PRINT (cp, ndig - 1); + } + /* "0.[0..]". */ + else + /* __dtoa irregularity. */ + PAD (ndig - 1, pdata->zero); + } + else /* "XeYYY". */ + PRINT (cp, 1); + PRINT (pdata->expstr, expsize); + } + } + + /* Left-adjusting padding (always blank). */ + if (pdata->flags & LADJUST) + PAD (pdata->width - realsz, pdata->blank); + + return (pdata->width > realsz ? pdata->width : realsz); +error: + return -1; + +#undef _fpvalue +} + +#endif diff --git a/newlib/libc/stdio/nano-vfprintf_i.c b/newlib/libc/stdio/nano-vfprintf_i.c new file mode 100644 index 000000000..b1b0d1d67 --- /dev/null +++ b/newlib/libc/stdio/nano-vfprintf_i.c @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2012-2014 ARM Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include <_ansi.h> +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "local.h" +#include "../stdlib/local.h" +#include "fvwrite.h" +#include "vfieeefp.h" +#include "nano-vfprintf_local.h" + +/* Decode and print non-floating point data. */ +int +_printf_common (struct _reent *data, + struct _prt_data_t *pdata, + int *realsz, + FILE *fp, + int (*pfunc)(struct _reent *, FILE *, + _CONST char *, size_t len)) +{ + int n; + /* + * All reasonable formats wind up here. At this point, `cp' + * points to a string which (if not flags&LADJUST) should be + * padded out to `width' places. If flags&ZEROPAD, it should + * first be prefixed by any sign or other prefix; otherwise, + * it should be blank padded before the prefix is emitted. + * After any left-hand padding and prefixing, emit zeroes + * required by a decimal [diouxX] precision, then print the + * string proper, then emit zeroes required by any leftover + * floating precision; finally, if LADJUST, pad with blanks. + * If flags&FPT, ch must be in [aAeEfg]. + * + * Compute actual size, so we know how much to pad. + * size excludes decimal prec; realsz includes it. + */ + *realsz = pdata->dprec > pdata->size ? pdata->dprec : pdata->size; + if (pdata->l_buf[0]) + (*realsz)++; + + if (pdata->flags & HEXPREFIX) + *realsz += 2; + + /* Right-adjusting blank padding. */ + if ((pdata->flags & (LADJUST|ZEROPAD)) == 0) + PAD (pdata->width - *realsz, pdata->blank); + + /* Prefix. */ + n = 0; + if (pdata->l_buf[0]) + n++; + + if (pdata->flags & HEXPREFIX) + { + pdata->l_buf[n++] = '0'; + pdata->l_buf[n++] = pdata->l_buf[2]; + } + + PRINT (pdata->l_buf, n); + n = pdata->width - *realsz; + if ((pdata->flags & (LADJUST|ZEROPAD)) != ZEROPAD || n < 0) + n = 0; + + if (pdata->dprec > pdata->size) + n += pdata->dprec - pdata->size; + + PAD (n, pdata->zero); + return 0; +error: + return -1; +} +int +_printf_i (struct _reent *data, struct _prt_data_t *pdata, FILE *fp, + int (*pfunc)(struct _reent *, FILE *, _CONST char *, size_t len), + va_list *ap) +{ + /* Field size expanded by dprec. */ + int realsz; + u_quad_t _uquad; + int base; + int n; + char *cp = pdata->buf + BUF; + char *xdigs = "0123456789ABCDEF"; + + /* Decoding the conversion specifier. */ + switch (pdata->code) + { + case 'c': + *--cp = GET_ARG (N, *ap, int); + pdata->size = 1; + goto non_number_nosign; + case 'd': + case 'i': + _uquad = SARG (pdata->flags); + if ((long) _uquad < 0) + { + _uquad = -_uquad; + pdata->l_buf[0] = '-'; + } + base = 10; + goto number; + case 'u': + case 'o': + _uquad = UARG (pdata->flags); + base = (pdata->code == 'o') ? 8 : 10; + goto nosign; + case 'X': + pdata->l_buf[2] = 'X'; + goto hex; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT. */ + pdata->flags |= HEXPREFIX; + case 'x': + pdata->l_buf[2] = 'x'; + xdigs = "0123456789abcdef"; +hex: + _uquad = UARG (pdata->flags); + base = 16; + if (pdata->flags & ALT) + pdata->flags |= HEXPREFIX; + + /* Leading 0x/X only if non-zero. */ + if (_uquad == 0) + pdata->flags &= ~HEXPREFIX; + + /* Unsigned conversions. */ +nosign: + pdata->l_buf[0] = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: + if ((pdata->dprec = pdata->prec) >= 0) + pdata->flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + if (_uquad != 0 || pdata->prec != 0) + { + do + { + *--cp = xdigs[_uquad % base]; + _uquad /= base; + } + while (_uquad); + } + /* For 'o' conversion, '#' increases the precision to force the first + digit of the result to be zero. */ + if (base == 8 && (pdata->flags & ALT) && pdata->prec <= pdata->size) + *--cp = '0'; + + pdata->size = pdata->buf + BUF - cp; + break; + case 'n': + if (pdata->flags & LONGINT) + *GET_ARG (N, *ap, long_ptr_t) = pdata->ret; + else if (pdata->flags & SHORTINT) + *GET_ARG (N, *ap, short_ptr_t) = pdata->ret; + else + *GET_ARG (N, *ap, int_ptr_t) = pdata->ret; + case '\0': + pdata->size = 0; + break; + case 's': + cp = GET_ARG (N, *ap, char_ptr_t); + /* Precision gives the maximum number of chars to be written from a + string, and take prec == -1 into consideration. */ + if ((u_int)(pdata->size = strlen (cp)) > (u_int)(pdata->prec)) + pdata->size = pdata->prec; + /* Below code is kept for reading. The check is redundant because + pdata->prec will be set to pdata->size if it is -1 previously. */ +#if 0 + if (pdata->prec > pdata->size) +#endif + pdata->prec = pdata->size; + goto non_number_nosign; + default: + /* "%?" prints ?, unless ? is NUL. */ + /* Pretend it was %c with argument ch. */ + *--cp = pdata->code; + pdata->size = 1; +non_number_nosign: + pdata->l_buf[0] = '\0'; + break; + } + + /* Output. */ + n = _printf_common (data, pdata, &realsz, fp, pfunc); + if (n == -1) + goto error; + + PRINT (cp, pdata->size); + /* Left-adjusting padding (always blank). */ + if (pdata->flags & LADJUST) + PAD (pdata->width - realsz, pdata->blank); + + return (pdata->width > realsz ? pdata->width : realsz); +error: + return -1; +} + diff --git a/newlib/libc/stdio/nano-vfprintf_local.h b/newlib/libc/stdio/nano-vfprintf_local.h new file mode 100644 index 000000000..83b479e56 --- /dev/null +++ b/newlib/libc/stdio/nano-vfprintf_local.h @@ -0,0 +1,234 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 2012-2014 ARM Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef VFPRINTF_LOCAL +#define VFPRINTF_LOCAL + +#ifndef NO_FLOATING_POINT +# define FLOATING_POINT +#endif + +#define _NO_POS_ARGS +#undef _WANT_IO_C99_FORMATS + +/* Currently a test is made to see if long double processing is warranted. + This could be changed in the future should the _ldtoa_r code be + preferred over _dtoa_r. */ +#define _NO_LONGDBL + +#define _NO_LONGLONG + +#define _PRINTF_FLOAT_TYPE double + +#if defined (FLOATING_POINT) +# include +#endif +#ifdef FLOATING_POINT +# include + +/* For %La, an exponent of 15 bits occupies the exponent character, + a sign, and up to 5 digits. */ +# define MAXEXPLEN 7 +# define DEFPREC 6 + +extern char *_dtoa_r _PARAMS((struct _reent *, double, int, + int, int *, int *, char **)); + +# define _DTOA_R _dtoa_r +# define FREXP frexp + +#endif /* FLOATING_POINT. */ + +/* BUF must be big enough for the maximum %#llo (assuming long long is + at most 64 bits, this would be 23 characters), the maximum + multibyte character %C, and the maximum default precision of %La + (assuming long double is at most 128 bits with 113 bits of + mantissa, this would be 29 characters). %e, %f, and %g use + reentrant storage shared with mprec. All other formats that use + buf get by with fewer characters. Making BUF slightly bigger + reduces the need for malloc in %.*a and %S, when large precision or + long strings are processed. + The bigger size of 100 bytes is used on systems which allow number + strings using the locale's grouping character. Since that's a multibyte + value, we should use a conservative value. */ +#define BUF 40 + +#define quad_t long +#define u_quad_t unsigned long + +typedef quad_t * quad_ptr_t; +typedef _PTR void_ptr_t; +typedef char * char_ptr_t; +typedef long * long_ptr_t; +typedef int * int_ptr_t; +typedef short * short_ptr_t; + +/* Macros for converting digits to letters and vice versa. */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit (c) <= 9) +#define to_char(n) ((n) + '0') + +/* Flags used during conversion. */ +#define ALT 0x001 /* Alternate form. */ +#define LADJUST 0x002 /* Left adjustment. */ +#define ZEROPAD 0x004 /* Zero (as opposed to blank) pad. */ +#define PLUSSGN 0x008 /* Plus sign flag. */ +#define SPACESGN 0x010 /* Space flag. */ +#define HEXPREFIX 0x020 /* Add 0x or 0X prefix. */ +#define SHORTINT 0x040 /* Short integer. */ +#define LONGINT 0x080 /* Long integer. */ +#define LONGDBL 0x100 /* Long double. */ +/* ifdef _NO_LONGLONG, make QUADINT equivalent to LONGINT, so + that %lld behaves the same as %ld, not as %d, as expected if: + sizeof (long long) = sizeof long > sizeof int. */ +#define QUADINT LONGINT +#define FPT 0x400 /* Floating point number. */ +/* Define as 0, to make SARG and UARG occupy fewer instructions. */ +# define CHARINT 0 + +/* Macros to support positional arguments. */ +#define GET_ARG(n, ap, type) (va_arg ((ap), type)) + +/* To extend shorts properly, we need both signed and unsigned + argument extraction methods. Also they should be used in nano-vfprintf_i.c + and nano-vfprintf_float.c only, since ap is a pointer to va_list. */ +#define SARG(flags) \ + (flags&LONGINT ? GET_ARG (N, (*ap), long) : \ + flags&SHORTINT ? (long)(short)GET_ARG (N, (*ap), int) : \ + flags&CHARINT ? (long)(signed char)GET_ARG (N, (*ap), int) : \ + (long)GET_ARG (N, (*ap), int)) +#define UARG(flags) \ + (flags&LONGINT ? GET_ARG (N, (*ap), u_long) : \ + flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, (*ap), int) : \ + flags&CHARINT ? (u_long)(unsigned char)GET_ARG (N, (*ap), int) : \ + (u_long)GET_ARG (N, (*ap), u_int)) + +/* BEWARE, these `goto error' on error. And they are used + in more than one functions. + + Following macros are each referred about twice in printf for integer, + so it is not worth to rewrite them into functions. This situation may + change in the future. */ +#define PRINT(ptr, len) { \ + if (pfunc (data, fp, (ptr), (len)) == EOF) \ + goto error; \ +} +#define PAD(howmany, ch) { \ + int temp_i = 0; \ + while (temp_i < (howmany)) \ + { \ + if (pfunc (data, fp, &(ch), 1) == EOF) \ + goto error; \ + temp_i++; \ + } \ +} +#define PRINTANDPAD(p, ep, len, ch) { \ + int temp_n = (ep) - (p); \ + if (temp_n > (len)) \ + temp_n = (len); \ + if (temp_n > 0) \ + PRINT((p), temp_n); \ + PAD((len) - (temp_n > 0 ? temp_n : 0), (ch)); \ +} + +/* All data needed to decode format string are kept in below struct. */ +struct _prt_data_t +{ + int flags; /* Flags. */ + int prec; /* Precision. */ + int dprec; /* Decimal precision. */ + int width; /* Width. */ + int size; /* Size of converted field or string. */ + int ret; /* Return value accumulator. */ + char code; /* Current conversion specifier. */ + char blank; /* Blank character. */ + char zero; /* Zero character. */ + char buf[BUF]; /* Output buffer for non-floating point number. */ + char l_buf[3]; /* Sign&hex_prefix, "+/-" and "0x/X". */ +#ifdef FLOATING_POINT + _PRINTF_FLOAT_TYPE _double_; /* Double value. */ + char expstr[MAXEXPLEN]; /* Buffer for exponent string. */ + int lead; /* The sig figs before decimal or group sep. */ +#endif +}; + +extern int +_printf_common (struct _reent *data, + struct _prt_data_t *pdata, + int *realsz, + FILE *fp, + int (*pfunc)(struct _reent *, FILE *, + _CONST char *, size_t len)); + +extern int +_printf_i (struct _reent *data, struct _prt_data_t *pdata, FILE *fp, + int (*pfunc)(struct _reent *, FILE *, _CONST char *, size_t len), + va_list *ap); + +/* Make _printf_float weak symbol, so it won't be linked in if target program + does not need it. */ +extern int +_printf_float (struct _reent *data, + struct _prt_data_t *pdata, + FILE *fp, + int (*pfunc)(struct _reent *, FILE *, + _CONST char *, size_t len), + va_list *ap) _ATTRIBUTE((__weak__)); +#endif diff --git a/newlib/libc/stdio/nano-vfscanf.c b/newlib/libc/stdio/nano-vfscanf.c new file mode 100644 index 000000000..6a827567a --- /dev/null +++ b/newlib/libc/stdio/nano-vfscanf.c @@ -0,0 +1,497 @@ +/*- + * 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. + */ + +/* + * Copyright (c) 2012-2014 ARM Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* +FUNCTION +<>, <>, <>---format argument list + +INDEX + vfscanf +INDEX + _vfscanf_r +INDEX + vscanf +INDEX + _vscanf_r +INDEX + vsscanf +INDEX + _vsscanf_r + +ANSI_SYNOPSIS + #include + #include + int vscanf(const char *<[fmt]>, va_list <[list]>); + int vfscanf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); + int vsscanf(const char *<[str]>, const char *<[fmt]>, va_list <[list]>); + + int _vscanf_r(struct _reent *<[reent]>, const char *<[fmt]>, + 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]>); + +TRAD_SYNOPSIS + #include + #include + int vscanf( <[fmt]>, <[ist]>) + char *<[fmt]>; + va_list <[list]>; + + int vfscanf( <[fp]>, <[fmt]>, <[list]>) + FILE *<[fp]>; + char *<[fmt]>; + va_list <[list]>; + + int vsscanf( <[str]>, <[fmt]>, <[list]>) + char *<[str]>; + char *<[fmt]>; + va_list <[list]>; + + int _vscanf_r( <[reent]>, <[fmt]>, <[ist]>) + struct _reent *<[reent]>; + char *<[fmt]>; + va_list <[list]>; + + int _vfscanf_r( <[reent]>, <[fp]>, <[fmt]>, <[list]>) + struct _reent *<[reent]>; + FILE *<[fp]>; + char *<[fmt]>; + va_list <[list]>; + + int _vsscanf_r( <[reent]>, <[str]>, <[fmt]>, <[list]>) + struct _reent *<[reent]>; + char *<[str]>; + char *<[fmt]>; + va_list <[list]>; + +DESCRIPTION +<>, <>, and <> are (respectively) variants +of <>, <>, and <>. They differ only in +allowing their caller to pass the variable argument list as a +<> object (initialized by <>) rather than +directly accepting a variable number of arguments. + +RETURNS +The return values are consistent with the corresponding functions: +<> returns the number of input fields successfully scanned, +converted, and stored; the return value does not include scanned +fields which were not stored. + +If <> attempts to read at end-of-file, the return value +is <>. + +If no fields were stored, the return value is <<0>>. + +The routines <<_vscanf_r>>, <<_vfscanf_f>>, and <<_vsscanf_r>> are +reentrant versions which take an additional first parameter which points to the +reentrancy structure. + +PORTABILITY +These are GNU extensions. + +Supporting OS subroutines required: +*/ + +#include <_ansi.h> +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "local.h" +#include "../stdlib/local.h" +#include "nano-vfscanf_local.h" + +#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 + +/* vfscanf. */ + +#ifndef STRING_ONLY + +#ifndef _REENT_ONLY + +int +_DEFUN(VFSCANF, (fp, fmt, ap), + register FILE *fp _AND + _CONST char *fmt _AND + va_list ap) +{ + CHECK_INIT(_REENT, fp); + return __SVFSCANF_R (_REENT, fp, fmt, ap); +} + +int +_EXFUN(vfiscanf, (FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vfscanf")))); + +int +_DEFUN(__SVFSCANF, (fp, fmt0, ap), + register FILE *fp _AND + char _CONST *fmt0 _AND + va_list ap) +{ + return __SVFSCANF_R (_REENT, fp, fmt0, ap); +} + +#endif + +int +_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, fp); + return __SVFSCANF_R (data, fp, fmt, ap); +} + +int +_EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vfscanf_r")))); +#endif /* !STRING_ONLY. */ + +#if defined (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. */ +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. */ +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 |= __SEOF; + return EOF; +} + +#else +int _EXFUN (_sungetc_r, (struct _reent *, int, register FILE *)); +int _EXFUN (__ssrefill_r, (struct _reent *, register FILE *)); +size_t _EXFUN (_sfread_r, (struct _reent *, _PTR buf, size_t, size_t, FILE *)); +#endif /* !STRING_ONLY. */ + +int +_DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), + struct _reent *rptr _AND + register FILE *fp _AND + char _CONST *fmt0 _AND + va_list ap) +{ + register u_char *fmt = (u_char *) fmt0; + register int c; /* Character from format, or conversion. */ + register char *p; /* Points into all kinds of strings. */ + char ccltab[256]; /* Character class table for %[...]. */ + + int ret; + char *cp; + + struct _scan_data_t scan_data; + int (*scan_func)(struct _reent*, struct _scan_data_t*, FILE *, va_list *); + + _newlib_flockfile_start (fp); + + scan_data.nassigned = 0; + scan_data.nread = 0; + scan_data.ccltab = ccltab; + scan_data.pfn_ungetc = _ungetc_r; + scan_data.pfn_refill = __srefill_r; + + for (;;) + { + if (*fmt == 0) + goto all_done; + + if (isspace (*fmt)) + { + while ((fp->_r > 0 || !scan_data.pfn_refill(rptr, fp)) + && isspace (*fp->_p)) + { + scan_data.nread++; + fp->_r--; + fp->_p++; + } + fmt++; + continue; + } + if ((c = *fmt++) != '%') + goto literal; + + scan_data.width = 0; + scan_data.flags = 0; + + if (*fmt == '*') + { + scan_data.flags |= SUPPRESS; + fmt++; + } + + for (; is_digit (*fmt); fmt++) + scan_data.width = 10 * scan_data.width + to_digit (*fmt); + + /* The length modifiers. */ + p = "hlL"; + if ((cp = memchr (p, *fmt, 3)) != NULL) { + scan_data.flags |= (SHORT << (cp - p)); + fmt++; + } + + /* Switch on the format. continue if done; break once format + type is derived. */ + c = *fmt++; + switch (c) + { + case '%': + literal: + if ((fp->_r <= 0 && scan_data.pfn_refill(rptr, fp))) + goto input_failure; + if (*fp->_p != c) + goto match_failure; + fp->_r--, fp->_p++; + scan_data.nread++; + continue; + + case 'p': + scan_data.flags |= POINTER; + case 'x': + scan_data.flags |= PFXOK; + scan_data.base = 16; + goto number; + case 'd': + case 'u': + scan_data.base = 10; + goto number; + case 'i': + scan_data.base = 0; + goto number; + case 'o': + scan_data.base = 8; + number: + scan_data.code = (c < 'o') ? CT_INT : CT_UINT; + break; + + case '[': + fmt = (u_char *) __sccl (ccltab, (unsigned char *) fmt); + scan_data.flags |= NOSKIP; + scan_data.code = CT_CCL; + break; + case 'c': + scan_data.flags |= NOSKIP; + scan_data.code = CT_CHAR; + break; + case 's': + scan_data.code = CT_STRING; + break; + + case 'n': + if (scan_data.flags & SUPPRESS) /* ??? */ + continue; + + if (scan_data.flags & SHORT) + *GET_ARG (N, ap, short *) = scan_data.nread; + else if (scan_data.flags & LONG) + *GET_ARG (N, ap, long *) = scan_data.nread; + else + *GET_ARG (N, ap, int *) = scan_data.nread; + + continue; + + /* Disgusting backwards compatibility hacks. XXX. */ + case '\0': /* compat. */ + _newlib_flockfile_exit (fp); + return EOF; + +#ifdef FLOATING_POINT + case 'e': + case 'f': + case 'g': + scan_data.code = CT_FLOAT; + break; +#endif + default: /* compat. */ + scan_data.code = CT_INT; + scan_data.base = 10; + break; + } + + /* We have a conversion that requires input. */ + if ((fp->_r <= 0 && scan_data.pfn_refill (rptr, fp))) + goto input_failure; + + /* Consume leading white space, except for formats that + suppress this. */ + if ((scan_data.flags & NOSKIP) == 0) + { + while (isspace (*fp->_p)) + { + scan_data.nread++; + if (--fp->_r > 0) + fp->_p++; + else if (scan_data.pfn_refill (rptr, fp)) + goto input_failure; + } + /* Note that there is at least one character in the + buffer, so conversions that do not set NOSKIP ca + no longer result in an input failure. */ + } + ret = 0; + if (scan_data.code < CT_INT) + ret = _scanf_chars (rptr, &scan_data, fp, &ap); + else if (scan_data.code < CT_FLOAT) + ret = _scanf_i (rptr, &scan_data, fp, &ap); +#ifdef FLOATING_POINT + else if (_scanf_float) + ret = _scanf_float (rptr, &scan_data, fp, &ap); +#endif + + if (ret == MATCH_FAILURE) + goto match_failure; + else if (ret == INPUT_FAILURE) + goto input_failure; + } +input_failure: + /* On read failure, return EOF failure regardless of matches; errno + should have been set prior to here. On EOF failure (including + invalid format string), return EOF if no matches yet, else number + of matches made prior to failure. */ + _newlib_flockfile_exit (fp); + return scan_data.nassigned && !(fp->_flags & __SERR) ? scan_data.nassigned + : EOF; +match_failure: +all_done: + /* Return number of matches, which can be 0 on match failure. */ + _newlib_flockfile_end (fp); + return scan_data.nassigned; +} + +#ifdef STRING_ONLY +int +_EXFUN(__ssvfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("__ssvfscanf_r")))); +#else +int +_EXFUN(__svfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("__svfscanf_r")))); +#endif + diff --git a/newlib/libc/stdio/nano-vfscanf_float.c b/newlib/libc/stdio/nano-vfscanf_float.c new file mode 100644 index 000000000..a81fe7f70 --- /dev/null +++ b/newlib/libc/stdio/nano-vfscanf_float.c @@ -0,0 +1,342 @@ +/*- + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "local.h" +#include "../stdlib/local.h" +#include "nano-vfscanf_local.h" + +#ifdef FLOATING_POINT +int +_scanf_float (struct _reent *rptr, + struct _scan_data_t *pdata, + FILE *fp, va_list *ap) +{ + int c; + char *p; + float *flp; + _LONG_DOUBLE *ldp; + + /* Scan a floating point number as if by strtod. */ + /* This code used to assume that the number of digits is reasonable. + However, ANSI / ISO C makes no such stipulation; we have to get + exact results even when there is an unreasonable amount of leading + zeroes. */ + long leading_zeroes = 0; + long zeroes, exp_adjust; + char *exp_start = NULL; + unsigned width_left = 0; + char nancount = 0; + char infcount = 0; +#ifdef hardway + if (pdata->width == 0 || pdata->width > BUF - 1) +#else + /* size_t is unsigned, hence this optimisation. */ + if (pdata->width - 1 > BUF - 2) +#endif + { + width_left = pdata->width - (BUF - 1); + pdata->width = BUF - 1; + } + pdata->flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; + zeroes = 0; + exp_adjust = 0; + for (p = pdata->buf; pdata->width; ) + { + c = *fp->_p; + /* This code mimicks the integer conversion code, + but is much simpler. */ + switch (c) + { + case '0': + if (pdata->flags & NDIGITS) + { + pdata->flags &= ~SIGNOK; + zeroes++; + if (width_left) + { + width_left--; + pdata->width++; + } + goto fskip; + } + /* Fall through. */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (nancount + infcount == 0) + { + pdata->flags &= ~(SIGNOK | NDIGITS); + goto fok; + } + break; + + case '+': + case '-': + if (pdata->flags & SIGNOK) + { + pdata->flags &= ~SIGNOK; + goto fok; + } + break; + case 'n': + case 'N': + if (nancount == 0 && zeroes == 0 + && (pdata->flags & (NDIGITS | DPTOK | EXPOK)) == + (NDIGITS | DPTOK | EXPOK)) + { + pdata->flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS); + nancount = 1; + goto fok; + } + if (nancount == 2) + { + nancount = 3; + goto fok; + } + if (infcount == 1 || infcount == 4) + { + infcount++; + goto fok; + } + break; + case 'a': + case 'A': + if (nancount == 1) + { + nancount = 2; + goto fok; + } + break; + case 'i': + case 'I': + if (infcount == 0 && zeroes == 0 + && (pdata->flags & (NDIGITS | DPTOK | EXPOK)) == + (NDIGITS | DPTOK | EXPOK)) + { + pdata->flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS); + infcount = 1; + goto fok; + } + if (infcount == 3 || infcount == 5) + { + infcount++; + goto fok; + } + break; + case 'f': + case 'F': + if (infcount == 2) + { + infcount = 3; + goto fok; + } + break; + case 't': + case 'T': + if (infcount == 6) + { + infcount = 7; + goto fok; + } + break; + case 'y': + case 'Y': + if (infcount == 7) + { + infcount = 8; + goto fok; + } + break; + case '.': + if (pdata->flags & DPTOK) + { + pdata->flags &= ~(SIGNOK | DPTOK); + leading_zeroes = zeroes; + goto fok; + } + break; + case 'e': + case 'E': + /* No exponent without some digits. */ + if ((pdata->flags & (NDIGITS | EXPOK)) == EXPOK + || ((pdata->flags & EXPOK) && zeroes)) + { + if (! (pdata->flags & DPTOK)) + { + exp_adjust = zeroes - leading_zeroes; + exp_start = p; + } + pdata->flags = + (pdata->flags & ~(EXPOK | DPTOK)) | SIGNOK | NDIGITS; + zeroes = 0; + goto fok; + } + break; + } + break; +fok: + *p++ = c; +fskip: + pdata->width--; + ++pdata->nread; + if (--fp->_r > 0) + fp->_p++; + else if (pdata->pfn_refill (rptr, fp)) + /* "EOF". */ + break; + } + if (zeroes) + pdata->flags &= ~NDIGITS; + /* We may have a 'N' or possibly even [sign] 'N' 'a' 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. + + FIXME - we still don't handle NAN([0xdigits]). */ + if (nancount - 1U < 2U) + { + /* "nancount && nancount < 3". */ + /* Newlib's ungetc works even if we called __srefill in + the middle of a partial parse, but POSIX does not + guarantee that in all implementations of ungetc. */ + while (p > pdata->buf) + { + pdata->pfn_ungetc (rptr, *--p, fp); /* "[-+nNaA]". */ + --pdata->nread; + } + return MATCH_FAILURE; + } + /* Likewise for 'inf' and 'infinity'. But be careful that + 'infinite' consumes only 3 characters, leaving the stream + at the second 'i'. */ + if (infcount - 1U < 7U) + { + /* "infcount && infcount < 8". */ + if (infcount >= 3) /* valid 'inf', but short of 'infinity'. */ + while (infcount-- > 3) + { + pdata->pfn_ungetc (rptr, *--p, fp); /* "[iInNtT]". */ + --pdata->nread; + } + else + { + while (p > pdata->buf) + { + pdata->pfn_ungetc (rptr, *--p, fp); /* "[-+iInN]". */ + --pdata->nread; + } + return 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. */ + if (pdata->flags & NDIGITS) + { + if (pdata->flags & EXPOK) + { + /* No digits at all. */ + while (p > pdata->buf) + { + pdata->pfn_ungetc (rptr, *--p, fp); /* "[-+.]". */ + --pdata->nread; + } + return MATCH_FAILURE; + } + /* Just a bad exponent (e and maybe sign). */ + c = *--p; + --pdata->nread; + if (c != 'e' && c != 'E') + { + pdata->pfn_ungetc (rptr, c, fp); /* "[-+]". */ + c = *--p; + --pdata->nread; + } + pdata->pfn_ungetc (rptr, c, fp); /* "[eE]". */ + } + if ((pdata->flags & SUPPRESS) == 0) + { + double fp; + long new_exp = 0; + + *p = 0; + if ((pdata->flags & (DPTOK | EXPOK)) == EXPOK) + { + exp_adjust = zeroes - leading_zeroes; + new_exp = -exp_adjust; + exp_start = p; + } + else if (exp_adjust) + new_exp = _strtol_r (rptr, (exp_start + 1), NULL, 10) - exp_adjust; + + if (exp_adjust) + { + /* If there might not be enough space for the new exponent, + truncate some trailing digits to make room. */ + if (exp_start >= pdata->buf + BUF - MAX_LONG_LEN) + exp_start = pdata->buf + BUF - MAX_LONG_LEN - 1; + sprintf (exp_start, "e%ld", new_exp); + } + + /* Current _strtold routine is markedly slower than + _strtod_r. Only use it if we have a long double + result. */ + fp = _strtod_r (rptr, pdata->buf, NULL); + + /* Do not support long double. */ + if (pdata->flags & LONG) + *GET_ARG (N, *ap, double *) = fp; + else if (pdata->flags & LONGDBL) + { + ldp = GET_ARG (N, *ap, _LONG_DOUBLE *); + *ldp = fp; + } + else + { + flp = GET_ARG (N, *ap, float *); + if (isnan (fp)) + *flp = nanf (NULL); + else + *flp = fp; + } + pdata->nassigned++; + } + return 0; +} +#endif + diff --git a/newlib/libc/stdio/nano-vfscanf_i.c b/newlib/libc/stdio/nano-vfscanf_i.c new file mode 100644 index 000000000..aba74b0d8 --- /dev/null +++ b/newlib/libc/stdio/nano-vfscanf_i.c @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2012-2014 ARM Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <_ansi.h> +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "local.h" +#include "../stdlib/local.h" + +#include "nano-vfscanf_local.h" + +int +_scanf_chars (struct _reent *rptr, + struct _scan_data_t *pdata, + FILE *fp, va_list *ap) +{ + int n; + char *p; + + if (pdata->width == 0) + pdata->width = (pdata->code == CT_CHAR) ? 1 : (size_t)~0; + + n = 0; + if ((pdata->flags & SUPPRESS) == 0) + p = GET_ARG (N, *ap, char *); + + /* It's impossible to have EOF when we get here. */ + while ((pdata->code == CT_CHAR) + || (pdata->code == CT_CCL && pdata->ccltab[*fp->_p]) + || (pdata->code == CT_STRING && !isspace (*fp->_p))) + { + n++; + if ((pdata->flags & SUPPRESS) == 0) + *p++ = *fp->_p; + + fp->_r--, fp->_p++; + if (--pdata->width == 0) + break; + + if ((fp->_r <= 0 && pdata->pfn_refill (rptr, fp))) + break; + } + /* For CT_CHAR, it is impossible to have input_failure(n == 0) here. + For CT_CCL, it is impossible to have input_failure here. + For CT_STRING, it is possible to have empty string. */ + if (n == 0 && pdata->code == CT_CCL) + return MATCH_FAILURE; + + if ((pdata->flags & SUPPRESS) == 0) + { + pdata->nassigned++; + if (pdata->code != CT_CHAR) + *p = 0; + } + pdata->nread += n; + return 0; +} +int +_scanf_i (struct _reent *rptr, + struct _scan_data_t *pdata, + FILE *fp, va_list *ap) +{ +#define CCFN_PARAMS _PARAMS((struct _reent *, const char *, char **, int)) + /* Conversion function (strtol/strtoul). */ + u_long (*ccfn)CCFN_PARAMS=0; + char *p; + int n; + char *xdigits = "A-Fa-f8901234567]"; + char *prefix_chars[3] = {"+-", "00", "xX"}; + + /* Scan an integer as if by strtol/strtoul. */ + unsigned width_left = 0; + int skips = 0; + + ccfn = (pdata->code == CT_INT) ? (u_long (*)CCFN_PARAMS)_strtol_r : _strtoul_r; +#ifdef hardway + if (pdata->width == 0 || pdata->width > BUF - 1) +#else + /* size_t is unsigned, hence this optimisation. */ + if (pdata->width - 1 > BUF - 2) +#endif + { + width_left = pdata->width - (BUF - 1); + pdata->width = BUF - 1; + } + p = pdata->buf; + pdata->flags |= NDIGITS | NZDIGITS | NNZDIGITS; + + /* Process [sign] [0] [xX] prefixes sequently. */ + for (n = 0; n < 3; n++) + { + if (!memchr (prefix_chars[n], *fp->_p, 2)) + continue; + + if (n == 1) + { + if (pdata->base == 0) + { + pdata->base = 8; + pdata->flags |= PFXOK; + } + pdata->flags &= ~(NZDIGITS | NDIGITS); + } + else if (n == 2) + { + if ((pdata->flags & (PFXOK | NZDIGITS)) != PFXOK) + continue; + pdata->base = 16; + + /* We must reset the NZDIGITS and NDIGITS + flags that would have been unset by seeing + the zero that preceded the X or x. + + ??? It seems unnecessary to reset the NZDIGITS. */ + pdata->flags |= NDIGITS; + } + if (pdata->width-- > 0) + { + *p++ = *fp->_p++; + fp->_r--; + if ((fp->_r <= 0 && pdata->pfn_refill (rptr, fp))) + goto match_end; + } + } + + if (pdata->base == 0) + pdata->base = 10; + + /* The check is un-necessary if xdigits points to exactly the string: + "A-Fa-f8901234567]". The code is kept only for reading's sake. */ +#if 0 + if (pdata->base != 16) +#endif + xdigits = xdigits + 16 - pdata->base; + + /* Initilize ccltab according to pdata->base. */ + __sccl (pdata->ccltab, (unsigned char *) xdigits); + for (; pdata->width; pdata->width--) + { + n = *fp->_p; + if (pdata->ccltab[n] == 0) + break; + else if (n == '0' && (pdata->flags & NNZDIGITS)) + { + ++skips; + if (width_left) + { + width_left--; + pdata->width++; + } + goto skip; + } + pdata->flags &= ~(NDIGITS | NNZDIGITS); + /* Char is legal: store it and look at the next. */ + *p++ = *fp->_p; +skip: + if (--fp->_r > 0) + fp->_p++; + else if (pdata->pfn_refill (rptr, fp)) + /* "EOF". */ + break; + } + /* If we had only a sign, it is no good; push back the sign. + If the number ends in `x', it was [sign] '0' 'x', so push back + the x and treat it as [sign] '0'. + Use of ungetc here and below assumes ASCII encoding; we are only + pushing back 7-bit characters, so casting to unsigned char is + not necessary. */ +match_end: + if (pdata->flags & NDIGITS) + { + if (p > pdata->buf) + pdata->pfn_ungetc (rptr, *--p, fp); /* "[-+xX]". */ + + if (p == pdata->buf) + return MATCH_FAILURE; + } + if ((pdata->flags & SUPPRESS) == 0) + { + u_long ul; + *p = 0; + ul = (*ccfn) (rptr, pdata->buf, (char **) NULL, pdata->base); + if (pdata->flags & POINTER) + *GET_ARG (N, *ap, void **) = (void *) (uintptr_t) ul; + else if (pdata->flags & SHORT) + *GET_ARG (N, *ap, short *) = ul; + else if (pdata->flags & LONG) + *GET_ARG (N, *ap, long *) = ul; + else + *GET_ARG (N, *ap, int *) = ul; + + pdata->nassigned++; + } + pdata->nread += p - pdata->buf + skips; + return 0; +} + diff --git a/newlib/libc/stdio/nano-vfscanf_local.h b/newlib/libc/stdio/nano-vfscanf_local.h new file mode 100644 index 000000000..7fbd964ed --- /dev/null +++ b/newlib/libc/stdio/nano-vfscanf_local.h @@ -0,0 +1,178 @@ +/*- + * 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. + */ + +/* + * Copyright (c) 2012-2014 ARM Ltd + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. The name of the company may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef VFSCANF_LOCAL +#define VFSCANF_LOCAL + +#ifndef NO_FLOATING_POINT +#define FLOATING_POINT +#endif + +#ifdef STRING_ONLY +#undef _newlib_flockfile_start +#undef _newlib_flockfile_exit +#undef _newlib_flockfile_end +#define _newlib_flockfile_start(x) {} +#define _newlib_flockfile_exit(x) {} +#define _newlib_flockfile_end(x) {} +#define _ungetc_r _sungetc_r +#define __srefill_r __ssrefill_r +#endif + +#ifdef FLOATING_POINT +#include +#include + +/* Currently a test is made to see if long double processing is warranted. + This could be changed in the future should the _ldtoa_r code be + preferred over _dtoa_r. */ +#define _NO_LONGDBL + +#include "floatio.h" + +#if ((MAXEXP+MAXFRACT+3) > MB_LEN_MAX) +/* "3 = sign + decimal point + NUL". */ +# define BUF (MAXEXP+MAXFRACT+3) +#else +# define BUF MB_LEN_MAX +#endif + +/* An upper bound for how long a long prints in decimal. 4 / 13 approximates + log (2). Add one char for roundoff compensation and one for the sign. */ +#define MAX_LONG_LEN ((CHAR_BIT * sizeof (long) - 1) * 4 / 13 + 2) +#else +#define BUF 40 +#endif + + +#define _NO_LONGLONG +#undef _WANT_IO_C99_FORMATS +#undef _WANT_IO_POS_ARGS + +#define _NO_POS_ARGS + +/* Macros for converting digits to letters and vice versa. */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit (c) <= 9) +#define to_char(n) ((n) + '0') + +/* + * Flags used during conversion. + */ + +#define SHORT 0x01 /* "h": short. */ +#define LONG 0x02 /* "l": long or double. */ +#define LONGDBL 0x04 /* "L/ll": long double or long long. */ +#define CHAR 0x08 /* "hh": 8 bit integer. */ +#define SUPPRESS 0x10 /* Suppress assignment. */ +#define POINTER 0x20 /* Weird %p pointer (`fake hex'). */ +#define NOSKIP 0x40 /* Do not skip blanks */ + +/* The following are used in numeric conversions only: + SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; + SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. */ + +#define SIGNOK 0x80 /* "+/-" is (still) legal. */ +#define NDIGITS 0x100 /* No digits detected. */ + +#define DPTOK 0x200 /* (Float) decimal point is still legal. */ +#define EXPOK 0x400 /* (Float) exponent (e+3, etc) still legal. */ + +#define PFXOK 0x200 /* "0x" prefix is (still) legal. */ +#define NZDIGITS 0x400 /* No zero digits detected. */ +#define NNZDIGITS 0x800 /* No non-zero digits detected. */ + +/* Conversion types. */ + +#define CT_CHAR 0 /* "%c" conversion. */ +#define CT_CCL 1 /* "%[...]" conversion. */ +#define CT_STRING 2 /* "%s" conversion. */ +#define CT_INT 3 /* Integer, i.e., strtol. */ +#define CT_UINT 4 /* Unsigned integer, i.e., strtoul. */ +#define CT_FLOAT 5 /* Floating, i.e., strtod. */ + +#define u_char unsigned char +#define u_long unsigned long + +/* Macro to support positional arguments. */ +#define GET_ARG(n, ap, type) (va_arg ((ap), type)) + +#define MATCH_FAILURE 1 +#define INPUT_FAILURE 2 + + +/* All data needed to decode format string are kept in below struct. */ +struct _scan_data_t +{ + int flags; /* Flags. */ + int base; /* Base. */ + size_t width; /* Width. */ + int nassigned; /* Number of assignments so far. */ + int nread; /* Number of chars read so far. */ + char *ccltab; /* Table used for [ format. */ + int code; /* Current conversion specifier. */ + char buf[BUF]; /* Internal buffer for scan. */ + /* Internal buffer for scan. */ + int (*pfn_ungetc)(struct _reent*, int, FILE*); + /* Internal buffer for scan. */ + int (*pfn_refill)(struct _reent*, FILE*); +}; + +extern int +_scanf_chars (struct _reent *rptr, + struct _scan_data_t *pdata, + FILE *fp, va_list *ap); +extern int +_scanf_i (struct _reent *rptr, + struct _scan_data_t *pdata, + FILE *fp, va_list *ap); +/* Make _scanf_float weak symbol, so it won't be linked in if target program + does not need it. */ +extern int +_scanf_float (struct _reent *rptr, + struct _scan_data_t *pdata, + FILE *fp, va_list *ap) _ATTRIBUTE((__weak__)); + +#endif diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c index b9fd6a498..d5dedf906 100644 --- a/newlib/libc/stdio/printf.c +++ b/newlib/libc/stdio/printf.c @@ -37,6 +37,12 @@ _DEFUN(_printf_r, (ptr, fmt), return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_iprintf_r, (struct _reent *, const char *, ...) + _ATTRIBUTE ((__alias__("_printf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -54,4 +60,9 @@ _DEFUN(printf, (fmt), return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(iprintf, (const char *, ...) + _ATTRIBUTE ((__alias__("printf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/scanf.c b/newlib/libc/stdio/scanf.c index 84992a558..23e97b83d 100644 --- a/newlib/libc/stdio/scanf.c +++ b/newlib/libc/stdio/scanf.c @@ -51,6 +51,12 @@ scanf(fmt, va_alist) return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(iscanf, (const char *, ...) + _ATTRIBUTE ((__alias__("scanf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -77,3 +83,8 @@ _scanf_r(ptr, fmt, va_alist) return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_iscanf_r, (struct _reent *, const char *, ...) + _ATTRIBUTE ((__alias__("_scanf_r")))); +#endif diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index c95e026d5..d2408b2f0 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -72,6 +72,12 @@ _snprintf_r(ptr, str, size, fmt, va_alist) return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...) + _ATTRIBUTE ((__alias__("_snprintf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -116,4 +122,9 @@ snprintf(str, size, fmt, va_alist) return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(sniprintf, (char *, size_t, const char *, ...) + _ATTRIBUTE ((__alias__("snprintf")))); +#endif #endif diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index 65dcc0fde..c3be9b1d2 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -608,6 +608,12 @@ _sprintf_r(ptr, str, fmt, va_alist) return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...) + _ATTRIBUTE ((__alias__("_sprintf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -641,4 +647,9 @@ sprintf(str, fmt, va_alist) return (ret); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(siprintf, (char *, const char *, ...) + _ATTRIBUTE ((__alias__("sprintf")))); +#endif #endif diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index e08002ea2..a32ce5d27 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -430,6 +430,12 @@ sscanf(str, fmt, va_alist) return ret; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(siscanf, (const char *, const char *, ...) + _ATTRIBUTE ((__alias__("sscanf")))); +#endif + #endif /* !_REENT_ONLY */ #ifdef _HAVE_STDC @@ -467,3 +473,9 @@ _sscanf_r(ptr, str, fmt, va_alist) va_end (ap); return ret; } + +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...) + _ATTRIBUTE ((__alias__("_sscanf_r")))); +#endif diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprintf.c index cab89beff..4cb43ce7a 100644 --- a/newlib/libc/stdio/vasnprintf.c +++ b/newlib/libc/stdio/vasnprintf.c @@ -56,6 +56,13 @@ _DEFUN(_vasnprintf_r, (ptr, buf, lenp, fmt, ap), return (char *) f._bf._base; } +#ifdef _NANO_FORMATTED_IO +char * +_EXFUN(_vasniprintf_r, (struct _reent*, char *, size_t *, + const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vasnprintf_r")))); +#endif + #ifndef _REENT_ONLY char * @@ -68,4 +75,9 @@ _DEFUN(vasnprintf, (buf, lenp, fmt, ap), return _vasnprintf_r (_REENT, buf, lenp, fmt, ap); } +#ifdef _NANO_FORMATTED_IO +char * +_EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vasnprintf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index fbb54cbe8..5ba817d7b 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -39,6 +39,12 @@ _DEFUN(vasprintf, (strp, fmt, ap), return _vasprintf_r (_REENT, strp, fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(vasiprintf, (char **, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vasprintf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -63,3 +69,9 @@ _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap), } return ret; } + +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vasprintf_r")))); +#endif diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c index 7e875ac32..c295a3959 100644 --- a/newlib/libc/stdio/vdprintf.c +++ b/newlib/libc/stdio/vdprintf.c @@ -33,6 +33,12 @@ _DEFUN(_vdprintf_r, (ptr, fd, format, ap), return n; } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vdprintf_r")))); +#endif + #ifndef _REENT_ONLY int @@ -44,4 +50,9 @@ _DEFUN(vdprintf, (fd, format, ap), return _vdprintf_r (_REENT, fd, format, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(vdiprintf, (int, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vdprintf")))); +#endif #endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/stdio/vprintf.c b/newlib/libc/stdio/vprintf.c index 581efeb2e..00b8023b7 100644 --- a/newlib/libc/stdio/vprintf.c +++ b/newlib/libc/stdio/vprintf.c @@ -39,6 +39,11 @@ _DEFUN(vprintf, (fmt, ap), return _vfprintf_r (reent, _stdout_r (reent), fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(viprintf, (const char *, __VALIST) _ATTRIBUTE ((__alias__("vprintf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -50,3 +55,9 @@ _DEFUN(_vprintf_r, (ptr, fmt, ap), _REENT_SMALL_CHECK_INIT (ptr); return _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); } + +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vprintf_r")))); +#endif diff --git a/newlib/libc/stdio/vscanf.c b/newlib/libc/stdio/vscanf.c index 74b148d44..4371e23a7 100644 --- a/newlib/libc/stdio/vscanf.c +++ b/newlib/libc/stdio/vscanf.c @@ -40,6 +40,11 @@ _DEFUN(vscanf, (fmt, ap), return __svfscanf_r (reent, _stdin_r (reent), fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(viscanf, (const char *, __VALIST) _ATTRIBUTE ((__alias__("vscanf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -52,3 +57,8 @@ _DEFUN(_vscanf_r, (ptr, fmt, ap), return __svfscanf_r (ptr, _stdin_r (ptr), fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vscanf_r")))); +#endif diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index d9f1e3dfd..e08f267bd 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -41,6 +41,12 @@ _DEFUN(vsnprintf, (str, size, fmt, ap), return _vsnprintf_r (_REENT, str, size, fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vsnprintf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -70,3 +76,9 @@ _DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap), *f._p = 0; return ret; } + +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vsnprintf_r")))); +#endif diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c index 8bc99321e..742cde0df 100644 --- a/newlib/libc/stdio/vsprintf.c +++ b/newlib/libc/stdio/vsprintf.c @@ -39,6 +39,12 @@ _DEFUN(vsprintf, (str, fmt, ap), return _vsprintf_r (_REENT, str, fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(vsiprintf, (char *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vsprintf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -59,3 +65,9 @@ _DEFUN(_vsprintf_r, (ptr, str, fmt, ap), *f._p = 0; return ret; } + +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vsprintf_r")))); +#endif diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index a6d0793b1..1660fa1cf 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -43,6 +43,12 @@ _DEFUN(vsscanf, (str, fmt, ap), return _vsscanf_r (_REENT, str, fmt, ap); } +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(vsiscanf, (const char *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("vsscanf")))); +#endif + #endif /* !_REENT_ONLY */ int @@ -63,3 +69,9 @@ _DEFUN(_vsscanf_r, (ptr, str, fmt, ap), f._file = -1; /* No file. */ return __ssvfscanf_r (ptr, &f, fmt, ap); } + +#ifdef _NANO_FORMATTED_IO +int +_EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST) + _ATTRIBUTE ((__alias__("_vsscanf_r")))); +#endif diff --git a/newlib/newlib.hin b/newlib/newlib.hin index 1892ea280..eadafc8a6 100644 --- a/newlib/newlib.hin +++ b/newlib/newlib.hin @@ -79,6 +79,9 @@ /* Define if declare atexit data as global. */ #undef _REENT_GLOBAL_ATEXIT +/* Define if small footprint nano-formatted-IO implementation used. */ +#undef _NANO_FORMATTED_IO + /* * Iconv encodings enabled ("to" direction) */