diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 297af4a8f..0fe36466f 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,18 @@ +2002-08-09 Jeff Johnston + + * configure.host: Add check for --enable-newlib-io-pos-args + and define WANT_IO_POS_ARGS flag if enabled. Define + the flag by default for x86-linux configurations. + * configure.in: Add support for --enable-newlib-io-pos-args. + * libc/configure.in: Ditto. + * configure: Regenerated. + * libc/configure: Ditto. + * libc/stdio/Makefile.am: Specify -fshort-enums for compiling + vfprintf.c and vfiprintf.c. + * libc/stdio/Makefile.in: Regenerated. + * libc/stdio/vfprintf.c: Add positional argument support that + is enabled by compiling with -DWANT_IO_POS_ARGS. + 2002-08-07 Richard Sandiford * libc/include/machine/setjmp.h: For mips, define _JBLEN based diff --git a/newlib/configure b/newlib/configure index f288c65b3..968287ea0 100755 --- a/newlib/configure +++ b/newlib/configure @@ -11,6 +11,8 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --enable-newlib-io-pos-args enable printf-family positional arg support" ac_help="$ac_help --enable-multilib build many library versions (default)" ac_help="$ac_help @@ -582,6 +584,19 @@ ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +# Check whether --enable-newlib-io-pos-args or --disable-newlib-io-pos-args was given. +if test "${enable_newlib_io_pos_args+set}" = set; then + enableval="$enable_newlib_io_pos_args" + case "${enableval}" in + yes) newlib_io_pos_args=yes ;; + no) newlib_io_pos_args=no ;; + *) { echo "configure: error: bad value ${enableval} for newlib-io-pos-args option" 1>&2; exit 1; } ;; + esac +else + newlib_io_pos_args=no +fi + + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -594,7 +609,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:598: checking for a BSD compatible install" >&5 +echo "configure:613: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -647,7 +662,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:651: checking whether build environment is sane" >&5 +echo "configure:666: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -704,7 +719,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:708: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:723: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -737,12 +752,12 @@ else fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:741: checking for Cygwin environment" >&5 +echo "configure:756: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:772: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -770,19 +785,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:774: checking for mingw32 environment" >&5 +echo "configure:789: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:801: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -914,7 +929,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:918: checking host system type" >&5 +echo "configure:933: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -935,7 +950,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:939: checking target system type" >&5 +echo "configure:954: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -953,7 +968,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:957: checking build system type" >&5 +echo "configure:972: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -996,7 +1011,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:1000: checking for working aclocal" >&5 +echo "configure:1015: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1009,7 +1024,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1013: checking for working autoconf" >&5 +echo "configure:1028: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1022,7 +1037,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1026: checking for working automake" >&5 +echo "configure:1041: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1035,7 +1050,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1039: checking for working autoheader" >&5 +echo "configure:1054: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1048,7 +1063,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1052: checking for working makeinfo" >&5 +echo "configure:1067: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1073,7 +1088,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1077: checking for $ac_word" >&5 +echo "configure:1092: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1103,7 +1118,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1107: checking for $ac_word" >&5 +echo "configure:1122: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1152,7 +1167,7 @@ fi fi echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1156: checking whether we are using GNU C" >&5 +echo "configure:1171: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1161,7 +1176,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1180: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1176,7 +1191,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1180: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1195: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1207,7 +1222,7 @@ fi # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1211: checking for $ac_word" >&5 +echo "configure:1226: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1239,7 +1254,7 @@ fi # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1243: checking for $ac_word" >&5 +echo "configure:1258: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1271,7 +1286,7 @@ fi # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1275: checking for $ac_word" >&5 +echo "configure:1290: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1303,7 +1318,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1307: checking for $ac_word" >&5 +echo "configure:1322: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1348,7 +1363,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1352: checking for a BSD compatible install" >&5 +echo "configure:1367: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1402,7 +1417,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:1406: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:1421: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -1436,7 +1451,7 @@ if false; then echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1440: checking for executable suffix" >&5 +echo "configure:1455: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1446,7 +1461,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj | *.ilk | *.pdb) ;; @@ -1575,7 +1590,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1579: checking for $ac_word" >&5 +echo "configure:1594: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1605,7 +1620,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1609: checking for $ac_word" >&5 +echo "configure:1624: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1656,7 +1671,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1660: checking for $ac_word" >&5 +echo "configure:1675: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1688,7 +1703,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1692: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1707: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1699,12 +1714,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1703 "configure" +#line 1718 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1730,12 +1745,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1734: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1749: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1739: checking whether we are using GNU C" >&5 +echo "configure:1754: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1744,7 +1759,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1748: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1763: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1763,7 +1778,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1767: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1782: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1806,7 +1821,7 @@ ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1810: checking for ld used by GCC" >&5 +echo "configure:1825: checking for ld used by GCC" >&5 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -1836,10 +1851,10 @@ echo "configure:1810: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1840: checking for GNU ld" >&5 +echo "configure:1855: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1843: checking for non-GNU ld" >&5 +echo "configure:1858: checking for non-GNU ld" >&5 fi if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1874,7 +1889,7 @@ else fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1878: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:1893: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1891,7 +1906,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:1895: checking for $LD option to reload object files" >&5 +echo "configure:1910: checking for $LD option to reload object files" >&5 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1903,7 +1918,7 @@ reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1907: checking for BSD-compatible nm" >&5 +echo "configure:1922: checking for BSD-compatible nm" >&5 if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1941,7 +1956,7 @@ NM="$lt_cv_path_NM" echo "$ac_t""$NM" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1945: checking whether ln -s works" >&5 +echo "configure:1960: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1962,7 +1977,7 @@ else fi echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6 -echo "configure:1966: checking how to recognise dependant libraries" >&5 +echo "configure:1981: checking how to recognise dependant libraries" >&5 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2135,13 +2150,13 @@ file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:2139: checking for object suffix" >&5 +echo "configure:2154: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:2145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -2165,7 +2180,7 @@ case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 -echo "configure:2169: checking for ${ac_tool_prefix}file" >&5 +echo "configure:2184: checking for ${ac_tool_prefix}file" >&5 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2227,7 +2242,7 @@ fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then echo $ac_n "checking for file""... $ac_c" 1>&6 -echo "configure:2231: checking for file" >&5 +echo "configure:2246: checking for file" >&5 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2298,7 +2313,7 @@ esac # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2302: checking for $ac_word" >&5 +echo "configure:2317: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2330,7 +2345,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2334: checking for $ac_word" >&5 +echo "configure:2349: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2365,7 +2380,7 @@ fi # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2369: checking for $ac_word" >&5 +echo "configure:2384: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2397,7 +2412,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2401: checking for $ac_word" >&5 +echo "configure:2416: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2464,8 +2479,8 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 2468 "configure"' > conftest.$ac_ext - if { (eval echo configure:2469: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 2483 "configure"' > conftest.$ac_ext + if { (eval echo configure:2484: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" @@ -2484,7 +2499,7 @@ case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext - if { (eval echo configure:2488: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + if { (eval echo configure:2503: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *ELF-32*) HPUX_IA64_MODE="32" @@ -2502,7 +2517,7 @@ ia64-*-hpux*) SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:2506: checking whether the C compiler needs -belf" >&5 +echo "configure:2521: checking whether the C compiler needs -belf" >&5 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2515,14 +2530,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -2552,7 +2567,7 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2556: checking for $ac_word" >&5 +echo "configure:2571: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2584,7 +2599,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2588: checking for $ac_word" >&5 +echo "configure:2603: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2619,7 +2634,7 @@ fi # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2623: checking for $ac_word" >&5 +echo "configure:2638: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2651,7 +2666,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2655: checking for $ac_word" >&5 +echo "configure:2670: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2686,7 +2701,7 @@ fi # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2690: checking for $ac_word" >&5 +echo "configure:2705: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2718,7 +2733,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2722: checking for $ac_word" >&5 +echo "configure:2737: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2754,12 +2769,12 @@ fi # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6 -echo "configure:2758: checking if libtool should supply DllMain function" >&5 +echo "configure:2773: checking if libtool should supply DllMain function" >&5 if eval "test \"`echo '$''{'lt_cv_need_dllmain'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_need_dllmain=no else @@ -2788,19 +2803,19 @@ echo "$ac_t""$lt_cv_need_dllmain" 1>&6 SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mdll" echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6 -echo "configure:2792: checking how to link DLLs" >&5 +echo "configure:2807: checking how to link DLLs" >&5 if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_dll_switch=-mdll else @@ -2914,7 +2929,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2918: checking for $ac_word" >&5 +echo "configure:2933: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else diff --git a/newlib/configure.host b/newlib/configure.host index 47808e21e..6e1e94715 100644 --- a/newlib/configure.host +++ b/newlib/configure.host @@ -239,6 +239,12 @@ if [ "${newlib_io_float}" = "no" ] ; then newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT" fi +# Enable printf positional argument support if requested. + +if [ "${newlib_io_pos_args}" = "yes" ] ; then + newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS" +fi + # Verify if shared newlib support is allowed and set appropriate variables # We don't want to use libtool for platforms that we are not going to # support shared libraries. This is because it adds executable tests which @@ -324,6 +330,7 @@ case "${host}" in newlib_cflags="${newlib_cflags} -Wall" newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS" newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL" + newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS" # --- Required when building a shared library ------------------------ newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION" # --- The three lines below are optional ------------------------------ diff --git a/newlib/configure.in b/newlib/configure.in index 2894d713a..b349237c3 100644 --- a/newlib/configure.in +++ b/newlib/configure.in @@ -7,6 +7,18 @@ AC_INIT(libc) dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. AC_CONFIG_AUX_DIR(..) +dnl Support --enable-newlib-io-pos-args +dnl This option is actually read in libc/configure.in. It is repeated +dnl here so that it shows up in the help text. +AC_ARG_ENABLE(newlib-io-pos-args, +[ --enable-newlib-io-pos-args enable printf-family positional arg support], +[case "${enableval}" in + yes) newlib_io_pos_args=yes ;; + no) newlib_io_pos_args=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-io-pos-args option) ;; + esac], [newlib_io_pos_args=no])dnl + + NEWLIB_CONFIGURE(.) dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and diff --git a/newlib/libc/configure b/newlib/libc/configure index 6800203b3..6de25e63f 100755 --- a/newlib/libc/configure +++ b/newlib/libc/configure @@ -11,6 +11,8 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --enable-newlib-io-pos-args enable printf-family positional arg support" ac_help="$ac_help --enable-multilib build many library versions (default)" ac_help="$ac_help @@ -580,6 +582,18 @@ ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +# Check whether --enable-newlib-io-pos-args or --disable-newlib-io-pos-args was given. +if test "${enable_newlib_io_pos_args+set}" = set; then + enableval="$enable_newlib_io_pos_args" + case "${enableval}" in + yes) newlib_io_pos_args=yes ;; + no) newlib_io_pos_args=no ;; + *) { echo "configure: error: bad value ${enableval} for newlib-io-pos-args option" 1>&2; exit 1; } ;; + esac +else + newlib_io_pos_args=no +fi + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -592,7 +606,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:596: checking for a BSD compatible install" >&5 +echo "configure:610: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -645,7 +659,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:649: checking whether build environment is sane" >&5 +echo "configure:663: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -702,7 +716,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:706: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:720: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -735,12 +749,12 @@ else fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:739: checking for Cygwin environment" >&5 +echo "configure:753: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:769: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -768,19 +782,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:772: checking for mingw32 environment" >&5 +echo "configure:786: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:798: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -912,7 +926,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:916: checking host system type" >&5 +echo "configure:930: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -933,7 +947,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:937: checking target system type" >&5 +echo "configure:951: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -951,7 +965,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:955: checking build system type" >&5 +echo "configure:969: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -994,7 +1008,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:998: checking for working aclocal" >&5 +echo "configure:1012: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1007,7 +1021,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1011: checking for working autoconf" >&5 +echo "configure:1025: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1020,7 +1034,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1024: checking for working automake" >&5 +echo "configure:1038: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1033,7 +1047,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1037: checking for working autoheader" >&5 +echo "configure:1051: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1046,7 +1060,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1050: checking for working makeinfo" >&5 +echo "configure:1064: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1071,7 +1085,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1075: checking for $ac_word" >&5 +echo "configure:1089: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1101,7 +1115,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1105: checking for $ac_word" >&5 +echo "configure:1119: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1150,7 +1164,7 @@ fi fi echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1154: checking whether we are using GNU C" >&5 +echo "configure:1168: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1159,7 +1173,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1163: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1177: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1174,7 +1188,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1178: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1192: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1205,7 +1219,7 @@ fi # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1209: checking for $ac_word" >&5 +echo "configure:1223: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1237,7 +1251,7 @@ fi # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1241: checking for $ac_word" >&5 +echo "configure:1255: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1269,7 +1283,7 @@ fi # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1273: checking for $ac_word" >&5 +echo "configure:1287: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1301,7 +1315,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1305: checking for $ac_word" >&5 +echo "configure:1319: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1346,7 +1360,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1350: checking for a BSD compatible install" >&5 +echo "configure:1364: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1400,7 +1414,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:1404: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:1418: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -1434,7 +1448,7 @@ if false; then echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1438: checking for executable suffix" >&5 +echo "configure:1452: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1444,7 +1458,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj | *.ilk | *.pdb) ;; @@ -1574,7 +1588,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1578: checking for $ac_word" >&5 +echo "configure:1592: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1604,7 +1618,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1608: checking for $ac_word" >&5 +echo "configure:1622: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1655,7 +1669,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1659: checking for $ac_word" >&5 +echo "configure:1673: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1687,7 +1701,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1691: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1705: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1698,12 +1712,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1702 "configure" +#line 1716 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1729,12 +1743,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1733: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1747: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1738: checking whether we are using GNU C" >&5 +echo "configure:1752: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1743,7 +1757,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1747: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1762,7 +1776,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1766: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1780: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1805,7 +1819,7 @@ ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1809: checking for ld used by GCC" >&5 +echo "configure:1823: checking for ld used by GCC" >&5 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -1835,10 +1849,10 @@ echo "configure:1809: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1839: checking for GNU ld" >&5 +echo "configure:1853: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1842: checking for non-GNU ld" >&5 +echo "configure:1856: checking for non-GNU ld" >&5 fi if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1873,7 +1887,7 @@ else fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1877: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:1891: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1890,7 +1904,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:1894: checking for $LD option to reload object files" >&5 +echo "configure:1908: checking for $LD option to reload object files" >&5 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1902,7 +1916,7 @@ reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1906: checking for BSD-compatible nm" >&5 +echo "configure:1920: checking for BSD-compatible nm" >&5 if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1940,7 +1954,7 @@ NM="$lt_cv_path_NM" echo "$ac_t""$NM" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1944: checking whether ln -s works" >&5 +echo "configure:1958: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1961,7 +1975,7 @@ else fi echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6 -echo "configure:1965: checking how to recognise dependant libraries" >&5 +echo "configure:1979: checking how to recognise dependant libraries" >&5 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2134,13 +2148,13 @@ file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:2138: checking for object suffix" >&5 +echo "configure:2152: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:2144: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2158: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -2164,7 +2178,7 @@ case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 -echo "configure:2168: checking for ${ac_tool_prefix}file" >&5 +echo "configure:2182: checking for ${ac_tool_prefix}file" >&5 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2226,7 +2240,7 @@ fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then echo $ac_n "checking for file""... $ac_c" 1>&6 -echo "configure:2230: checking for file" >&5 +echo "configure:2244: checking for file" >&5 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2297,7 +2311,7 @@ esac # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2301: checking for $ac_word" >&5 +echo "configure:2315: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2329,7 +2343,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2333: checking for $ac_word" >&5 +echo "configure:2347: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2364,7 +2378,7 @@ fi # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2368: checking for $ac_word" >&5 +echo "configure:2382: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2396,7 +2410,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2400: checking for $ac_word" >&5 +echo "configure:2414: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2463,8 +2477,8 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 2467 "configure"' > conftest.$ac_ext - if { (eval echo configure:2468: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 2481 "configure"' > conftest.$ac_ext + if { (eval echo configure:2482: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" @@ -2483,7 +2497,7 @@ case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext - if { (eval echo configure:2487: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + if { (eval echo configure:2501: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *ELF-32*) HPUX_IA64_MODE="32" @@ -2501,7 +2515,7 @@ ia64-*-hpux*) SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:2505: checking whether the C compiler needs -belf" >&5 +echo "configure:2519: checking whether the C compiler needs -belf" >&5 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2514,14 +2528,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -2551,7 +2565,7 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2555: checking for $ac_word" >&5 +echo "configure:2569: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2583,7 +2597,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2587: checking for $ac_word" >&5 +echo "configure:2601: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2618,7 +2632,7 @@ fi # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2622: checking for $ac_word" >&5 +echo "configure:2636: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2650,7 +2664,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2654: checking for $ac_word" >&5 +echo "configure:2668: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2685,7 +2699,7 @@ fi # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2689: checking for $ac_word" >&5 +echo "configure:2703: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2717,7 +2731,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2721: checking for $ac_word" >&5 +echo "configure:2735: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2753,12 +2767,12 @@ fi # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6 -echo "configure:2757: checking if libtool should supply DllMain function" >&5 +echo "configure:2771: checking if libtool should supply DllMain function" >&5 if eval "test \"`echo '$''{'lt_cv_need_dllmain'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_need_dllmain=no else @@ -2787,19 +2801,19 @@ echo "$ac_t""$lt_cv_need_dllmain" 1>&6 SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mdll" echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6 -echo "configure:2791: checking how to link DLLs" >&5 +echo "configure:2805: checking how to link DLLs" >&5 if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_dll_switch=-mdll else diff --git a/newlib/libc/configure.in b/newlib/libc/configure.in index 6a5eeed5e..93b86132c 100644 --- a/newlib/libc/configure.in +++ b/newlib/libc/configure.in @@ -7,6 +7,15 @@ AC_INIT(sys.tex) dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. AC_CONFIG_AUX_DIR(../..) +dnl Support --enable-newlib-io-pos-args used by libc/stdio +AC_ARG_ENABLE(newlib-io-pos-args, +[ --enable-newlib-io-pos-args enable printf-family positional arg support], +[case "${enableval}" in + yes) newlib_io_pos_args=yes ;; + no) newlib_io_pos_args=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-io-pos-args option) ;; + esac], [newlib_io_pos_args=no])dnl + NEWLIB_CONFIGURE(..) dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index aee96d8bd..77885e43e 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -106,10 +106,10 @@ include $(srcdir)/../../Makefile.shared # libtool moves vfprintf.o and subsequently can't find it. vfprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -c $(srcdir)/vfprintf.c + $(LIB_COMPILE) -fshort-enums -c $(srcdir)/vfprintf.c vfiprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@ + $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@ CHEWOUT_FILES = \ clearerr.def \ diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index 54d21dad7..d9a09e327 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -561,10 +561,10 @@ objectlist.awk.in: $(noinst_LTLIBRARIES) # libtool moves vfprintf.o and subsequently can't find it. vfprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -c $(srcdir)/vfprintf.c + $(LIB_COMPILE) -fshort-enums -c $(srcdir)/vfprintf.c vfiprintf.$(oext): vfprintf.c - $(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@ + $(LIB_COMPILE) -fshort-enums -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@ .c.def: $(CHEW) < $< > $*.def 2> $*.ref diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 889a7a083..8e1efd7bb 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -111,7 +111,7 @@ Supporting OS subroutines required: <>, <>, <>, <>, <>, <>, <>. */ -/*- +/* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * @@ -174,6 +174,11 @@ static char *rcsid = "$Id$"; # undef _NO_LONGLONG #endif +#define _NO_POS_ARGS +#if defined WANT_IO_POS_ARGS +# undef _NO_POS_ARGS +#endif + #include <_ansi.h> #include #include @@ -279,6 +284,46 @@ static int exponent _PARAMS((char *, int, int)); #endif /* FLOATING_POINT */ +#ifndef _NO_LONG_LONG +#define quad_t long long +#define u_quad_t unsigned long long +#else +#define quad_t long +#define u_quad_t unsigned long +#endif + +typedef quad_t * quad_ptr_t; +typedef void * void_ptr_t; +typedef char * char_ptr_t; +typedef long * long_ptr_t; +typedef int * int_ptr_t; +typedef short * short_ptr_t; + +#ifndef _NO_POS_ARGS +#define MAX_POS_ARGS 32 + +union arg_val +{ + int val_int; + u_int val_u_int; + long val_long; + u_long val_u_long; + float val_float; + double val_double; + _LONG_DOUBLE val__LONG_DOUBLE; + int_ptr_t val_int_ptr_t; + short_ptr_t val_short_ptr_t; + long_ptr_t val_long_ptr_t; + char_ptr_t val_char_ptr_t; + quad_ptr_t val_quad_ptr_t; + void_ptr_t val_void_ptr_t; + quad_t val_quad_t; + u_quad_t val_u_quad_t; +}; + +static union arg_val *get_arg (int n, char *fmt, va_list *ap, int *numargs, union arg_val *args, + int *arg_type, char **last_fmt); +#endif /* !_NO_POS_ARGS */ /* * Macros for converting digits to letters and vice versa @@ -306,6 +351,8 @@ static int exponent _PARAMS((char *, int, int)); #define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ #define FPT 0x100 /* Floating point number */ +int _EXFUN (_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); + int _DEFUN (VFPRINTF, (fp, fmt0, ap), FILE * fp _AND @@ -333,6 +380,17 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), register char *cp; /* handy char pointer (short term usage) */ register struct __siov *iovp;/* for PRINT macro */ register int flags; /* flags as above */ + char *fmt_anchor; /* current format spec being processed */ + int N; /* arg number */ + int arg_index; /* index into args processed directly */ +#ifndef _NO_POS_ARGS + int numargs; /* number of varargs read */ + char *saved_fmt; /* saved fmt pointer */ + union arg_val args[MAX_POS_ARGS]; + int arg_type[MAX_POS_ARGS]; + int is_pos_arg; /* is current format positional? */ + int old_is_pos_arg; /* is current format positional? */ +#endif int ret; /* return value accumulator */ int width; /* width from format (%8d), or 0 */ int prec; /* precision from format (%.3d), or -1 */ @@ -355,16 +413,9 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), char expstr[7]; /* buffer for exponent string */ #endif -#ifndef _NO_LONGLONG -#define quad_t long long -#define u_quad_t unsigned long long -#endif -#ifndef _NO_LONGLONG u_quad_t _uquad; /* integer arguments %[diouxX] */ -#else - u_long _uquad; -#endif + enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ int dprec; /* a copy of prec if [diouxX], 0 otherwise */ int realsz; /* field size expanded by dprec */ @@ -418,30 +469,47 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), iovp = iov; \ } + /* Macros to support positional arguments */ +#ifndef _NO_POS_ARGS +#define GET_ARG(n, ap, type) \ + ( is_pos_arg \ + ? n < numargs \ + ? args[n].val_##type \ + : get_arg (n, fmt_anchor, &ap, &numargs, args, arg_type, &saved_fmt)->val_##type \ + : arg_index++ < numargs \ + ? args[n].val_##type \ + : numargs < MAX_POS_ARGS \ + ? args[numargs++].val_##type = va_arg(ap, type) \ + : va_arg(ap, type) \ + ) +#else +#define GET_ARG(n, ap, type) (va_arg(ap, type)) +#endif + /* * To extend shorts properly, we need both signed and unsigned * argument extraction methods. */ #ifndef _NO_LONGLONG #define SARG() \ - (flags&QUADINT ? va_arg(ap, quad_t) : \ - flags&LONGINT ? va_arg(ap, long) : \ - flags&SHORTINT ? (long)(short)va_arg(ap, int) : \ - (long)va_arg(ap, int)) + (flags&QUADINT ? GET_ARG(N, ap, quad_t) : \ + flags&LONGINT ? GET_ARG(N, ap, long) : \ + flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \ + (long)GET_ARG(N, ap, int)) #define UARG() \ - (flags&QUADINT ? va_arg(ap, u_quad_t) : \ - flags&LONGINT ? va_arg(ap, u_long) : \ - flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \ - (u_long)va_arg(ap, u_int)) + (flags&QUADINT ? GET_ARG(N, ap, u_quad_t) : \ + flags&LONGINT ? GET_ARG(N, ap, u_long) : \ + flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \ + (u_long)GET_ARG(N, ap, u_int)) #else #define SARG() \ - (flags&LONGINT ? va_arg(ap, long) : \ - flags&SHORTINT ? (long)(short)va_arg(ap, int) : \ - (long)va_arg(ap, int)) + (flags&LONGINT ? GET_ARG(N, ap, long) : \ + flags&SHORTINT ? (long)(short)GET_ARG(N, ap, int) : \ + (long)GET_ARG(N, ap, int)) #define UARG() \ - (flags&LONGINT ? va_arg(ap, u_long) : \ - flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \ - (u_long)va_arg(ap, u_int)) + (flags&LONGINT ? GET_ARG(N, ap, u_long) : \ + flags&SHORTINT ? (u_long)(u_short)GET_ARG(N, ap, int) : \ + (u_long)GET_ARG(N, ap, u_int)) #endif /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ @@ -458,6 +526,13 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), uio.uio_resid = 0; uio.uio_iovcnt = 0; ret = 0; + arg_index = 0; +#ifndef _NO_POS_ARGS + saved_fmt = NULL; + arg_type[0] = -1; + numargs = 0; + is_pos_arg = 0; +#endif /* * Scan the format for conversions (`%' character). @@ -477,6 +552,8 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), } if (n <= 0) goto done; + + fmt_anchor = fmt; fmt++; /* skip over '%' */ flags = 0; @@ -484,6 +561,10 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), width = 0; prec = -1; sign = '\0'; + N = arg_index; +#ifndef _NO_POS_ARGS + is_pos_arg = 0; +#endif rflag: ch = *fmt++; reswitch: switch (ch) { @@ -500,13 +581,47 @@ reswitch: switch (ch) { flags |= ALT; goto rflag; case '*': + n = N; +#ifndef _NO_POS_ARGS + /* we must check for positional arg used for dynamic width */ + old_is_pos_arg = is_pos_arg; + is_pos_arg = 0; + if (is_digit(*fmt)) { + char *old_fmt = fmt; + + n = 0; + ch = *fmt++; + do { + n = 10 * n + to_digit(ch); + ch = *fmt++; + } while (is_digit(ch)); + + if (ch == '$') { + if (n <= MAX_POS_ARGS) { + n -= 1; + is_pos_arg = 1; + } + else + goto error; + } + else { + fmt = old_fmt; + goto rflag; + } + } +#endif /* !_NO_POS_ARGS */ + /* * ``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. */ - if ((width = va_arg(ap, int)) >= 0) + width = GET_ARG(n, ap, int); +#ifndef _NO_POS_ARGS + is_pos_arg = old_is_pos_arg; +#endif + if (width >= 0) goto rflag; width = -width; /* FALLTHROUGH */ @@ -518,8 +633,41 @@ reswitch: switch (ch) { goto rflag; case '.': if ((ch = *fmt++) == '*') { - n = va_arg(ap, int); - prec = n < 0 ? -1 : n; + n = N; +#ifndef _NO_POS_ARGS + /* we must check for positional arg used for dynamic width */ + old_is_pos_arg = is_pos_arg; + is_pos_arg = 0; + if (is_digit(*fmt)) { + char *old_fmt = fmt; + + n = 0; + ch = *fmt++; + do { + n = 10 * n + to_digit(ch); + ch = *fmt++; + } while (is_digit(ch)); + + if (ch == '$') { + if (n <= MAX_POS_ARGS) { + n -= 1; + is_pos_arg = 1; + } + else + goto error; + } + else { + fmt = old_fmt; + goto rflag; + } + } +#endif /* !_NO_POS_ARGS */ + prec = GET_ARG(n, ap, int); +#ifndef _NO_POS_ARGS + is_pos_arg = old_is_pos_arg; +#endif + if (prec < 0) + prec = -1; goto rflag; } n = 0; @@ -544,6 +692,17 @@ reswitch: switch (ch) { n = 10 * n + to_digit(ch); ch = *fmt++; } while (is_digit(ch)); +#ifndef _NO_POS_ARGS + if (ch == '$') { + if (n <= MAX_POS_ARGS) { + N = n - 1; + is_pos_arg = 1; + goto rflag; + } + else + goto error; + } +#endif /* !_NO_POS_ARGS */ width = n; goto reswitch; #ifdef FLOATING_POINT @@ -566,7 +725,7 @@ reswitch: switch (ch) { flags |= QUADINT; goto rflag; case 'c': - *(cp = buf) = va_arg(ap, int); + *(cp = buf) = GET_ARG(N, ap, int); size = 1; sign = '\0'; break; @@ -602,9 +761,9 @@ reswitch: switch (ch) { #ifdef _NO_LONGDBL if (flags & LONGDBL) { - _fpvalue = (double) va_arg(ap, _LONG_DOUBLE); + _fpvalue = (double) GET_ARG(N, ap, _LONG_DOUBLE); } else { - _fpvalue = va_arg(ap, double); + _fpvalue = GET_ARG(N, ap, double); } /* do this before tricky precision changes */ @@ -624,9 +783,9 @@ reswitch: switch (ch) { #else /* !_NO_LONGDBL */ if (flags & LONGDBL) { - _fpvalue = va_arg(ap, _LONG_DOUBLE); + _fpvalue = GET_ARG(N, ap, _LONG_DOUBLE); } else { - _fpvalue = (_LONG_DOUBLE)va_arg(ap, double); + _fpvalue = (_LONG_DOUBLE)GET_ARG(N, ap, double); } /* do this before tricky precision changes */ @@ -684,15 +843,15 @@ reswitch: switch (ch) { case 'n': #ifndef _NO_LONGLONG if (flags & QUADINT) - *va_arg(ap, quad_t *) = ret; + *GET_ARG(N, ap, quad_ptr_t *) = ret; else #endif if (flags & LONGINT) - *va_arg(ap, long *) = ret; + *GET_ARG(N, ap, long_ptr_t) = ret; else if (flags & SHORTINT) - *va_arg(ap, short *) = ret; + *GET_ARG(N, ap, short_ptr_t) = ret; else - *va_arg(ap, int *) = ret; + *GET_ARG(N, ap, int_ptr_t) = ret; continue; /* no output */ case 'O': flags |= LONGINT; @@ -710,14 +869,14 @@ reswitch: switch (ch) { * -- ANSI X3J11 */ /* NOSTRICT */ - _uquad = (u_long)(unsigned _POINTER_INT)va_arg(ap, void *); + _uquad = (u_long)(unsigned _POINTER_INT)GET_ARG(N, ap, void_ptr_t); base = HEX; xdigs = "0123456789abcdef"; flags |= HEXPREFIX; ch = 'x'; goto nosign; case 's': - if ((cp = va_arg(ap, char *)) == NULL) + if ((cp = GET_ARG(N, ap, char_ptr_t)) == NULL) cp = "(null)"; if (prec >= 0) { /* @@ -1053,3 +1212,384 @@ exponent(p0, exp, fmtch) return (p - p0); } #endif /* FLOATING_POINT */ + + +#ifndef _NO_POS_ARGS + +/* Positional argument support. + Written by Jeff Johnston + + Copyright (c) 2002 Red Hat Incorporated. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + The name of Red Hat Incorporated may not be used to endorse + or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 RED HAT INCORPORATED 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. */ + +typedef enum { + ZERO, /* '0' */ + DIGIT, /* '1-9' */ + DOLLAR, /* '$' */ + MODFR, /* spec modifier */ + SPEC, /* format specifier */ + DOT, /* '.' */ + STAR, /* '*' */ + FLAG, /* format flag */ + OTHER, /* all other chars */ + MAX_CH_CLASS /* place-holder */ +} CH_CLASS; + +typedef enum { + START, /* start */ + SFLAG, /* seen a flag */ + WDIG, /* seen digits in width area */ + WIDTH, /* processed width */ + SMOD, /* seen spec modifier */ + SDOT, /* seen dot */ + VARW, /* have variable width specifier */ + VARP, /* have variable precision specifier */ + PREC, /* processed precision */ + VWDIG, /* have digits in variable width specification */ + VPDIG, /* have digits in variable precision specification */ + DONE, /* done */ + MAX_STATE, /* place-holder */ +} STATE; + +typedef enum { + NOOP, /* do nothing */ + NUMBER, /* build a number from digits */ + SKIPNUM, /* skip over digits */ + GETMOD, /* get and process format modifier */ + GETARG, /* get and process argument */ + GETPW, /* get variable precision or width */ + GETPWB, /* get variable precision or width and pushback fmt char */ + GETPOS, /* get positional parameter value */ + PWPOS, /* get positional parameter value for variable width or precision */ +} ACTION; + +const static CH_CLASS chclass[256] = { + /* 00-07 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 08-0f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 10-17 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 18-1f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 20-27 */ FLAG, OTHER, OTHER, FLAG, DOLLAR, OTHER, OTHER, OTHER, + /* 28-2f */ OTHER, OTHER, STAR, FLAG, OTHER, FLAG, DOT, OTHER, + /* 30-37 */ ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, + /* 38-3f */ DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 40-47 */ OTHER, OTHER, OTHER, OTHER, SPEC, SPEC, OTHER, SPEC, + /* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC, + /* 50-57 */ OTHER, OTHER, OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, + /* 58-5f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 60-67 */ OTHER, OTHER, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, + /* 68-6f */ MODFR, SPEC, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC, + /* 70-77 */ SPEC, MODFR, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER, + /* 78-7f */ SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 80-87 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 88-8f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 90-97 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* 98-9f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* a0-a7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* a8-af */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* b0-b7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* b8-bf */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* c0-c7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* c8-cf */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* d0-d7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* d8-df */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* e0-e7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* e8-ef */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* f0-f7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, + /* f8-ff */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, +}; + +const static STATE state_table[MAX_STATE][MAX_CH_CLASS] = { + /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ + /* START */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, + /* SFLAG */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, + /* WDIG */ { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE }, + /* WIDTH */ { DONE, DONE, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE }, + /* SMOD */ { DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE }, + /* SDOT */ { SDOT, PREC, DONE, SMOD, DONE, DONE, VARP, DONE, DONE }, + /* VARW */ { DONE, VWDIG, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE }, + /* VARP */ { DONE, VPDIG, DONE, SMOD, DONE, DONE, DONE, DONE, DONE }, + /* PREC */ { DONE, DONE, DONE, SMOD, DONE, DONE, DONE, DONE, DONE }, + /* VWDIG */ { DONE, DONE, WIDTH, DONE, DONE, DONE, DONE, DONE, DONE }, + /* VPDIG */ { DONE, DONE, PREC, DONE, DONE, DONE, DONE, DONE, DONE }, +}; + +const static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = { + /* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ + /* START */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* SFLAG */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* WDIG */ { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* WIDTH */ { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* SMOD */ { NOOP, NOOP, NOOP, NOOP, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* SDOT */ { NOOP, SKIPNUM, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* VARW */ { NOOP, NUMBER, NOOP, GETPW, GETPWB, GETPW, NOOP, NOOP, NOOP }, + /* VARP */ { NOOP, NUMBER, NOOP, GETPW, GETPWB, NOOP, NOOP, NOOP, NOOP }, + /* PREC */ { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, + /* VWDIG */ { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP }, + /* VPDIG */ { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP }, +}; + +/* function to get positional parameter N where n = N - 1 */ +static union arg_val * +get_arg (int n, char *fmt, va_list *ap, int *numargs_p, union arg_val *args, + int *arg_type, char **last_fmt) +{ + int ch; + wchar_t wc; + int nbytes, number, flags; + int spec_type; + int numargs = *numargs_p; + CH_CLASS chtype; + STATE state, next_state; + ACTION action; + int pos, last_arg; + int wc_state = 0; + int max_pos_arg = n; + enum types { INT, LONG_INT, SHORT_INT, QUAD_INT, CHAR, CHAR_PTR, DOUBLE, LONG_DOUBLE }; + + /* if this isn't the first call, pick up where we left off last time */ + if (*last_fmt != NULL) + fmt = *last_fmt; + + /* we need to process either to end of fmt string or until we have actually + read the desired parameter from the vararg list. */ + while (*fmt && n >= numargs) + { + while ((nbytes = _mbtowc_r(_REENT, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0) + { + fmt += nbytes; + if (wc == '%') + break; + } + + if (nbytes <= 0) + break; + + state = START; + flags = 0; + pos = -1; + number = 0; + spec_type = INT; + + /* Use state/action table to process format specifiers. We ignore invalid + formats and we are only interested in information that tells us how to + read the vararg list. */ + while (state != DONE) + { + ch = *fmt++; + chtype = chclass[ch]; + next_state = state_table[state][chtype]; + action = action_table[state][chtype]; + state = next_state; + + switch (action) + { + case GETMOD: /* we have format modifier */ + switch (ch) + { + case 'h': + flags |= SHORTINT; + break; + case 'L': + flags |= LONGDBL; + break; + case 'q': + flags |= QUADINT; + break; + case 'l': + default: + if (*fmt == 'l') + { + flags |= QUADINT; + ++fmt; + } + else + flags |= LONGINT; + break; + } + break; + case GETARG: /* we have format specifier */ + { + numargs &= (MAX_POS_ARGS - 1); + /* process the specifier and translate it to a type to fetch from varargs */ + switch (ch) + { + case 'd': + case 'i': + case 'o': + case 'x': + case 'X': + case 'u': + if (flags & LONGINT) + spec_type = LONG_INT; + else if (flags & SHORTINT) + spec_type = SHORT_INT; +#ifndef _NO_LONG_LONG + else if (flags & QUADINT) + spec_type = QUAD_INT; +#endif + else + spec_type = INT; + break; + case 'D': + case 'U': + case 'O': + spec_type = LONG_INT; + break; + case 'f': + case 'g': + case 'G': + case 'E': + case 'e': +#ifndef _NO_LONGDBL + if (flags & LONGDBL) + spec_type = LONG_DOUBLE; + else +#endif + spec_type = DOUBLE; + break; + case 's': + case 'p': + spec_type = CHAR_PTR; + break; + case 'c': + spec_type = CHAR; + break; + } + + /* if we have a positional parameter, just store the type, otherwise + fetch the parameter from the vararg list */ + if (pos != -1) + arg_type[pos] = spec_type; + else + { + switch (spec_type) + { + case LONG_INT: + args[numargs++].val_long = va_arg(*ap, long); + break; + case QUAD_INT: + args[numargs++].val_quad_t = va_arg(*ap, quad_t); + break; + case CHAR: + case SHORT_INT: + case INT: + args[numargs++].val_int = va_arg(*ap, int); + break; + case CHAR_PTR: + args[numargs++].val_char_ptr_t = va_arg(*ap, char *); + break; + case DOUBLE: + args[numargs++].val_double = va_arg(*ap, double); + break; + case LONG_DOUBLE: + args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE); + break; + } + } + } + break; + case GETPOS: /* we have positional specifier */ + if (arg_type[0] == -1) + memset (arg_type, 0, sizeof(int) * MAX_POS_ARGS); + pos = number - 1; + max_pos_arg = (max_pos_arg > pos ? max_pos_arg : pos); + break; + case PWPOS: /* we have positional specifier for width or precision */ + if (arg_type[0] == -1) + memset (arg_type, 0, sizeof(int) * MAX_POS_ARGS); + number -= 1; + arg_type[number] = INT; + max_pos_arg = (max_pos_arg > number ? max_pos_arg : number); + break; + case GETPWB: /* we require format pushback */ + --fmt; + /* fallthrough */ + case GETPW: /* we have a variable precision or width to acquire */ + args[numargs++].val_int = va_arg(*ap, int); + break; + case NUMBER: /* we have a number to process */ + number = (ch - '0'); + while ((ch = *fmt) != '\0' && is_digit(ch)) + { + number = number * 10 + (ch - '0'); + ++fmt; + } + break; + case SKIPNUM: /* we have a number to skip */ + while ((ch = *fmt) != '\0' && is_digit(ch)) + ++fmt; + break; + case NOOP: + default: + break; /* do nothing */ + } + } + } + + /* process all arguments up to at least the one we are looking for and if we + have seen the end of the string, then process up to the max argument needed */ + if (*fmt == '\0') + last_arg = max_pos_arg; + else + last_arg = n; + + while (numargs <= last_arg) + { + switch (arg_type[numargs]) + { + case LONG_INT: + args[numargs++].val_long = va_arg(*ap, long); + break; + case QUAD_INT: + args[numargs++].val_quad_t = va_arg(*ap, quad_t); + break; + case CHAR_PTR: + args[numargs++].val_char_ptr_t = va_arg(*ap, char *); + break; + case DOUBLE: + args[numargs++].val_double = va_arg(*ap, double); + break; + case LONG_DOUBLE: + args[numargs++].val__LONG_DOUBLE = va_arg(*ap, _LONG_DOUBLE); + break; + case INT: + case SHORT_INT: + case CHAR: + default: + args[numargs++].val_int = va_arg(*ap, int); + break; + } + } + + /* alter the global numargs value and keep a reference to the last bit of the fmt + string we processed here because the caller will continue processing where we started */ + *numargs_p = numargs; + *last_fmt = fmt; + return &args[n]; +} +#endif /* !_NO_POS_ARGS */