diff options
Diffstat (limited to 'vendor/gmp-6.3.0/tests/misc')
-rw-r--r-- | vendor/gmp-6.3.0/tests/misc/Makefile.am | 34 | ||||
-rw-r--r-- | vendor/gmp-6.3.0/tests/misc/Makefile.in | 1041 | ||||
-rw-r--r-- | vendor/gmp-6.3.0/tests/misc/t-locale.c | 197 | ||||
-rw-r--r-- | vendor/gmp-6.3.0/tests/misc/t-printf.c | 955 | ||||
-rw-r--r-- | vendor/gmp-6.3.0/tests/misc/t-scanf.c | 1615 |
5 files changed, 3842 insertions, 0 deletions
diff --git a/vendor/gmp-6.3.0/tests/misc/Makefile.am b/vendor/gmp-6.3.0/tests/misc/Makefile.am new file mode 100644 index 0000000..9fe6efb --- /dev/null +++ b/vendor/gmp-6.3.0/tests/misc/Makefile.am @@ -0,0 +1,34 @@ +## Process this file with automake to generate Makefile.in + +# Copyright 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library test suite. +# +# The GNU MP Library test suite is free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# The GNU MP Library test suite is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. + + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests +AM_LDFLAGS = -no-install +LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la + +check_PROGRAMS = t-printf t-scanf t-locale +TESTS = $(check_PROGRAMS) + +# Temporary files used by the tests. Removed automatically if the tests +# pass, but ensure they're cleaned if they fail. +# +CLEANFILES = *.tmp + +$(top_builddir)/tests/libtests.la: + cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la diff --git a/vendor/gmp-6.3.0/tests/misc/Makefile.in b/vendor/gmp-6.3.0/tests/misc/Makefile.in new file mode 100644 index 0000000..62a5f04 --- /dev/null +++ b/vendor/gmp-6.3.0/tests/misc/Makefile.in @@ -0,0 +1,1041 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 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. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of the GNU MP Library test suite. +# +# The GNU MP Library test suite is free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the License, +# or (at your option) any later version. +# +# The GNU MP Library test suite is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = t-printf$(EXEEXT) t-scanf$(EXEEXT) t-locale$(EXEEXT) +subdir = tests/misc +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +t_locale_SOURCES = t-locale.c +t_locale_OBJECTS = t-locale.$(OBJEXT) +t_locale_LDADD = $(LDADD) +t_locale_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +t_printf_SOURCES = t-printf.c +t_printf_OBJECTS = t-printf.$(OBJEXT) +t_printf_LDADD = $(LDADD) +t_printf_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +t_scanf_SOURCES = t-scanf.c +t_scanf_OBJECTS = t-scanf.$(OBJEXT) +t_scanf_LDADD = $(LDADD) +t_scanf_DEPENDENCIES = $(top_builddir)/tests/libtests.la \ + $(top_builddir)/libgmp.la +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = t-locale.c t-printf.c t-scanf.c +DIST_SOURCES = t-locale.c t-printf.c t-scanf.c +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/test-driver +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABI = @ABI@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +ASMFLAGS = @ASMFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@ +CC = @CC@ +CCAS = @CCAS@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@ +DEFS = @DEFS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ +FGREP = @FGREP@ +GMP_LDFLAGS = @GMP_LDFLAGS@ +GMP_LIMB_BITS = @GMP_LIMB_BITS@ +GMP_NAIL_BITS = @GMP_NAIL_BITS@ +GREP = @GREP@ +HAVE_CLOCK_01 = @HAVE_CLOCK_01@ +HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@ +HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@ +HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@ +HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@ +HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@ +HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@ +HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@ +HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@ +HAVE_STACK_T_01 = @HAVE_STACK_T_01@ +HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBCURSES = @LIBCURSES@ +LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@ +LIBGMP_DLL = @LIBGMP_DLL@ +LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@ +LIBM = @LIBM@ +LIBM_FOR_BUILD = @LIBM_FOR_BUILD@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +M4 = @M4@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@ +STRIP = @STRIP@ +TAL_OBJECT = @TAL_OBJECT@ +TUNE_LIBS = @TUNE_LIBS@ +TUNE_SQR_OBJ = @TUNE_SQR_OBJ@ +U_FOR_BUILD = @U_FOR_BUILD@ +VERSION = @VERSION@ +WITH_READLINE_01 = @WITH_READLINE_01@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gmp_srclinks = @gmp_srclinks@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +mpn_objects = @mpn_objects@ +mpn_objs_in_libgmp = @mpn_objs_in_libgmp@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests +AM_LDFLAGS = -no-install +LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la +TESTS = $(check_PROGRAMS) + +# Temporary files used by the tests. Removed automatically if the tests +# pass, but ensure they're cleaned if they fail. +# +CLEANFILES = *.tmp +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps tests/misc/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps tests/misc/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +t-locale$(EXEEXT): $(t_locale_OBJECTS) $(t_locale_DEPENDENCIES) $(EXTRA_t_locale_DEPENDENCIES) + @rm -f t-locale$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_locale_OBJECTS) $(t_locale_LDADD) $(LIBS) + +t-printf$(EXEEXT): $(t_printf_OBJECTS) $(t_printf_DEPENDENCIES) $(EXTRA_t_printf_DEPENDENCIES) + @rm -f t-printf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_printf_OBJECTS) $(t_printf_LDADD) $(LIBS) + +t-scanf$(EXEEXT): $(t_scanf_OBJECTS) $(t_scanf_DEPENDENCIES) $(EXTRA_t_scanf_DEPENDENCIES) + @rm -f t-scanf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_scanf_OBJECTS) $(t_scanf_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(AM_V_CC)$(COMPILE) -c -o $@ $< + +.c.obj: + $(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: + $(AM_V_CC)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +t-printf.log: t-printf$(EXEEXT) + @p='t-printf$(EXEEXT)'; \ + b='t-printf'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-scanf.log: t-scanf$(EXEEXT) + @p='t-scanf$(EXEEXT)'; \ + b='t-scanf'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +t-locale.log: t-locale$(EXEEXT) + @p='t-locale$(EXEEXT)'; \ + b='t-locale'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + recheck tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +$(top_builddir)/tests/libtests.la: + cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/vendor/gmp-6.3.0/tests/misc/t-locale.c b/vendor/gmp-6.3.0/tests/misc/t-locale.c new file mode 100644 index 0000000..c5b0b3c --- /dev/null +++ b/vendor/gmp-6.3.0/tests/misc/t-locale.c @@ -0,0 +1,197 @@ +/* Test locale support, or attempt to do so. + +Copyright 2001, 2002, 2011, 2014, 2020 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 3 of the License, +or (at your option) any later version. + +The GNU MP Library test suite is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along with +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + +#define _GNU_SOURCE /* for DECIMAL_POINT in glibc langinfo.h */ + +#include "config.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#if HAVE_NL_TYPES_H +#include <nl_types.h> /* for nl_item (on netbsd 1.4.1 at least) */ +#endif + +#if HAVE_LANGINFO_H +#include <langinfo.h> /* for nl_langinfo */ +#endif + +#if HAVE_LOCALE_H +#include <locale.h> /* for lconv */ +#endif + +#include "gmp-impl.h" +#include "tests.h" + +const char *decimal_point; + +/* Replace the libc localeconv with one we can manipulate. */ +#if HAVE_LOCALECONV && ! defined __MINGW32__ +struct lconv * +localeconv (void) +#if defined __cplusplus && defined __GLIBC__ + throw() +#endif +{ + static struct lconv l; + l.decimal_point = (char *) decimal_point; + return &l; +} +#endif + +/* Replace the libc nl_langinfo with one we can manipulate. */ +#if HAVE_NL_LANGINFO && ! defined __TERMUX__ +char * +nl_langinfo (nl_item n) +#if defined __cplusplus && defined __GLIBC__ + throw() +#endif +{ +#if defined (DECIMAL_POINT) + if (n == DECIMAL_POINT) + return (char *) decimal_point; +#endif +#if defined (RADIXCHAR) + if (n == RADIXCHAR) + return (char *) decimal_point; +#endif + return (char *) ""; +} +#endif + +void +check_input (void) +{ + static const char *point[] = { + ".", ",", "WU", "STR", "ZTV***" + }; + + static const struct { + const char *str; + double d; + } data[] = { + + { "1%s", 1.0 }, + { "1%s0", 1.0 }, + { "1%s00", 1.0 }, + + { "%s5", 0.5 }, + { "0%s5", 0.5 }, + { "00%s5", 0.5 }, + { "00%s50", 0.5 }, + + { "1%s5", 1.5 }, + { "1%s5e1", 15.0 }, + }; + + int i, j, neg, ret; + char str[128]; + mpf_t f; + double d; + + mpf_init (f); + + for (i = 0; i < numberof (point); i++) + { + decimal_point = (const char *) point[i]; + + for (neg = 0; neg <= 1; neg++) + { + for (j = 0; j < numberof (data); j++) + { + strcpy (str, neg ? "-" : ""); + sprintf (str+strlen(str), data[j].str, decimal_point); + + d = data[j].d; + if (neg) + d = -d; + + mpf_set_d (f, 123.0); + if (mpf_set_str (f, str, 10) != 0) + { + printf ("mpf_set_str error\n"); + printf (" point %s\n", decimal_point); + printf (" str %s\n", str); + abort (); + } + if (mpf_cmp_d (f, d) != 0) + { + printf ("mpf_set_str wrong result\n"); + printf (" point %s\n", decimal_point); + printf (" str %s\n", str); + mpf_trace (" f", f); + printf (" d=%g\n", d); + abort (); + } + + mpf_set_d (f, 123.0); + ret = gmp_sscanf (str, "%Ff", f); + if (ret != 1) + { + printf ("gmp_sscanf wrong return value\n"); + printf (" point %s\n", decimal_point); + printf (" str %s\n", str); + printf (" ret %d\n", ret); + abort (); + } + if (mpf_cmp_d (f, d) != 0) + { + printf ("gmp_sscanf wrong result\n"); + printf (" point %s\n", decimal_point); + printf (" str %s\n", str); + mpf_trace (" f", f); + printf (" d=%g\n", d); + abort (); + } + } + } + } + mpf_clear (f); +} + +int +main (void) +{ + /* The localeconv replacement breaks printf "%lu" on SunOS 4, so we can't + print the seed in tests_rand_start(). Nothing random is used in this + program though, so just use the memory tests alone. */ + tests_memory_start (); + + { + mpf_t f; + char buf[128]; + mpf_init (f); + decimal_point = ","; + mpf_set_d (f, 1.5); + gmp_snprintf (buf, sizeof(buf), "%.1Ff", f); + mpf_clear (f); + if (strcmp (buf, "1,5") != 0) + { + printf ("Test skipped, replacing localeconv/nl_langinfo doesn't work\n"); + goto done; + } + } + + check_input (); + + done: + tests_memory_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/misc/t-printf.c b/vendor/gmp-6.3.0/tests/misc/t-printf.c new file mode 100644 index 0000000..ef104ba --- /dev/null +++ b/vendor/gmp-6.3.0/tests/misc/t-printf.c @@ -0,0 +1,955 @@ +/* Test gmp_printf and related functions. + +Copyright 2001-2003, 2015 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 3 of the License, +or (at your option) any later version. + +The GNU MP Library test suite is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along with +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + + +/* Usage: t-printf [-s] + + -s Check the data against the system printf, where possible. This is + only an option since we don't want to fail if the system printf is + faulty or strange. */ + + +#include "config.h" /* needed for the HAVE_, could also move gmp incls */ + +#include <stdarg.h> +#include <stddef.h> /* for ptrdiff_t */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#if HAVE_OBSTACK_VPRINTF +#define obstack_chunk_alloc tests_allocate +#define obstack_chunk_free tests_free_nosize +#include <obstack.h> +#endif + +#if HAVE_INTTYPES_H +# include <inttypes.h> /* for intmax_t */ +#endif +#if HAVE_STDINT_H +# include <stdint.h> +#endif + +#if HAVE_UNISTD_H +#include <unistd.h> /* for unlink */ +#endif + +#include "gmp-impl.h" +#include "tests.h" + + +int option_check_printf = 0; + + +#define CHECK_VFPRINTF_FILENAME "t-printf.tmp" +FILE *check_vfprintf_fp; + + +/* From any of the tests run here. */ +#define MAX_OUTPUT 1024 + + +void +check_plain (const char *want, const char *fmt_orig, ...) +{ + char got[MAX_OUTPUT]; + int got_len, want_len; + size_t fmtsize; + char *fmt, *q; + const char *p; + va_list ap; + va_start (ap, fmt_orig); + + if (! option_check_printf) + return; + + fmtsize = strlen (fmt_orig) + 1; + fmt = (char *) (*__gmp_allocate_func) (fmtsize); + + for (p = fmt_orig, q = fmt; *p != '\0'; p++) + { + switch (*p) { + case 'a': + case 'A': + /* The exact value of the exponent isn't guaranteed in glibc, and it + and gmp_printf do slightly different things, so don't compare + directly. */ + goto done; + case 'F': + if (p > fmt_orig && *(p-1) == '.') + goto done; /* don't test the "all digits" cases */ + /* discard 'F' type */ + break; + case 'Z': + /* transmute */ + *q++ = 'l'; + break; + default: + *q++ = *p; + break; + } + } + *q = '\0'; + + want_len = strlen (want); + ASSERT_ALWAYS (want_len < sizeof(got)); + + got_len = vsprintf (got, fmt, ap); + + if (got_len != want_len || strcmp (got, want) != 0) + { + printf ("wanted data doesn't match plain vsprintf\n"); + printf (" fmt |%s|\n", fmt); + printf (" got |%s|\n", got); + printf (" want |%s|\n", want); + printf (" got_len %d\n", got_len); + printf (" want_len %d\n", want_len); + abort (); + } + + done: + (*__gmp_free_func) (fmt, fmtsize); +} + +void +check_vsprintf (const char *want, const char *fmt, va_list ap) +{ + char got[MAX_OUTPUT]; + int got_len, want_len; + + want_len = strlen (want); + got_len = gmp_vsprintf (got, fmt, ap); + + if (got_len != want_len || strcmp (got, want) != 0) + { + printf ("gmp_vsprintf wrong\n"); + printf (" fmt |%s|\n", fmt); + printf (" got |%s|\n", got); + printf (" want |%s|\n", want); + printf (" got_len %d\n", got_len); + printf (" want_len %d\n", want_len); + abort (); + } +} + +void +check_vfprintf (const char *want, const char *fmt, va_list ap) +{ + char got[MAX_OUTPUT]; + int got_len, want_len, fread_len; + long ftell_len; + + want_len = strlen (want); + + rewind (check_vfprintf_fp); + got_len = gmp_vfprintf (check_vfprintf_fp, fmt, ap); + ASSERT_ALWAYS (got_len != -1); + ASSERT_ALWAYS (fflush (check_vfprintf_fp) == 0); + + ftell_len = ftell (check_vfprintf_fp); + ASSERT_ALWAYS (ftell_len != -1); + + rewind (check_vfprintf_fp); + ASSERT_ALWAYS (ftell_len <= sizeof(got)); + fread_len = fread (got, 1, ftell_len, check_vfprintf_fp); + + if (got_len != want_len + || ftell_len != want_len + || fread_len != want_len + || memcmp (got, want, want_len) != 0) + { + printf ("gmp_vfprintf wrong\n"); + printf (" fmt |%s|\n", fmt); + printf (" got |%.*s|\n", fread_len, got); + printf (" want |%s|\n", want); + printf (" got_len %d\n", got_len); + printf (" ftell_len %ld\n", ftell_len); + printf (" fread_len %d\n", fread_len); + printf (" want_len %d\n", want_len); + abort (); + } +} + +void +check_vsnprintf (const char *want, const char *fmt, va_list ap) +{ + char got[MAX_OUTPUT+1]; + int ret, got_len, want_len; + size_t bufsize; + + want_len = strlen (want); + + bufsize = -1; + for (;;) + { + /* do 0 to 5, then want-5 to want+5 */ + bufsize++; + if (bufsize > 5 && bufsize < want_len-5) + bufsize = want_len-5; + if (bufsize > want_len + 5) + break; + ASSERT_ALWAYS (bufsize+1 <= sizeof (got)); + + got[bufsize] = '!'; + ret = gmp_vsnprintf (got, bufsize, fmt, ap); + + got_len = MIN (MAX(1,bufsize)-1, want_len); + + if (got[bufsize] != '!') + { + printf ("gmp_vsnprintf overwrote bufsize sentinel\n"); + goto error; + } + + if (ret != want_len) + { + printf ("gmp_vsnprintf return value wrong\n"); + goto error; + } + + if (bufsize > 0) + { + if (memcmp (got, want, got_len) != 0 || got[got_len] != '\0') + { + printf ("gmp_vsnprintf wrong result string\n"); + error: + printf (" fmt |%s|\n", fmt); + printf (" bufsize %lu\n", (unsigned long) bufsize); + printf (" got |%s|\n", got); + printf (" want |%.*s|\n", got_len, want); + printf (" want full |%s|\n", want); + printf (" ret %d\n", ret); + printf (" want_len %d\n", want_len); + abort (); + } + } + } +} + +void +check_vasprintf (const char *want, const char *fmt, va_list ap) +{ + char *got; + int got_len, want_len; + + want_len = strlen (want); + got_len = gmp_vasprintf (&got, fmt, ap); + + if (got_len != want_len || strcmp (got, want) != 0) + { + printf ("gmp_vasprintf wrong\n"); + printf (" fmt |%s|\n", fmt); + printf (" got |%s|\n", got); + printf (" want |%s|\n", want); + printf (" got_len %d\n", got_len); + printf (" want_len %d\n", want_len); + abort (); + } + (*__gmp_free_func) (got, strlen(got)+1); +} + +void +check_obstack_vprintf (const char *want, const char *fmt, va_list ap) +{ +#if HAVE_OBSTACK_VPRINTF + struct obstack ob; + int got_len, want_len, ob_len; + char *got; + + want_len = strlen (want); + + obstack_init (&ob); + got_len = gmp_obstack_vprintf (&ob, fmt, ap); + got = (char *) obstack_base (&ob); + ob_len = obstack_object_size (&ob); + + if (got_len != want_len + || ob_len != want_len + || memcmp (got, want, want_len) != 0) + { + printf ("gmp_obstack_vprintf wrong\n"); + printf (" fmt |%s|\n", fmt); + printf (" got |%s|\n", got); + printf (" want |%s|\n", want); + printf (" got_len %d\n", got_len); + printf (" ob_len %d\n", ob_len); + printf (" want_len %d\n", want_len); + abort (); + } + obstack_free (&ob, NULL); +#endif +} + + +void +check_one (const char *want, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + + /* simplest first */ + check_vsprintf (want, fmt, ap); + check_vfprintf (want, fmt, ap); + check_vsnprintf (want, fmt, ap); + check_vasprintf (want, fmt, ap); + check_obstack_vprintf (want, fmt, ap); +} + + +#define hex_or_octal_p(fmt) \ + (strchr (fmt, 'x') != NULL \ + || strchr (fmt, 'X') != NULL \ + || strchr (fmt, 'o') != NULL) + +void +check_z (void) +{ + static const struct { + const char *fmt; + const char *z; + const char *want; + } data[] = { + { "%Zd", "0", "0" }, + { "%Zd", "1", "1" }, + { "%Zd", "123", "123" }, + { "%Zd", "-1", "-1" }, + { "%Zd", "-123", "-123" }, + + { "%+Zd", "0", "+0" }, + { "%+Zd", "123", "+123" }, + { "%+Zd", "-123", "-123" }, + + { "%Zx", "123", "7b" }, + { "%ZX", "123", "7B" }, + { "%Zx", "-123", "-7b" }, + { "%ZX", "-123", "-7B" }, + { "%Zo", "123", "173" }, + { "%Zo", "-123", "-173" }, + + { "%#Zx", "0", "0" }, + { "%#ZX", "0", "0" }, + { "%#Zx", "123", "0x7b" }, + { "%#ZX", "123", "0X7B" }, + { "%#Zx", "-123", "-0x7b" }, + { "%#ZX", "-123", "-0X7B" }, + + { "%#Zo", "0", "0" }, + { "%#Zo", "123", "0173" }, + { "%#Zo", "-123", "-0173" }, + + { "%10Zd", "0", " 0" }, + { "%10Zd", "123", " 123" }, + { "%10Zd", "-123", " -123" }, + + { "%-10Zd", "0", "0 " }, + { "%-10Zd", "123", "123 " }, + { "%-10Zd", "-123", "-123 " }, + + { "%+10Zd", "123", " +123" }, + { "%+-10Zd", "123", "+123 " }, + { "%+10Zd", "-123", " -123" }, + { "%+-10Zd", "-123", "-123 " }, + + { "%08Zd", "0", "00000000" }, + { "%08Zd", "123", "00000123" }, + { "%08Zd", "-123", "-0000123" }, + + { "%+08Zd", "0", "+0000000" }, + { "%+08Zd", "123", "+0000123" }, + { "%+08Zd", "-123", "-0000123" }, + + { "%#08Zx", "0", "00000000" }, + { "%#08Zx", "123", "0x00007b" }, + { "%#08Zx", "-123", "-0x0007b" }, + + { "%+#08Zx", "0", "+0000000" }, + { "%+#08Zx", "123", "+0x0007b" }, + { "%+#08Zx", "-123", "-0x0007b" }, + + { "%.0Zd", "0", "" }, + { "%.1Zd", "0", "0" }, + { "%.2Zd", "0", "00" }, + { "%.3Zd", "0", "000" }, + }; + + int i, j; + mpz_t z; + char *nfmt; + mp_size_t nsize, zeros; + + mpz_init (z); + + for (i = 0; i < numberof (data); i++) + { + mpz_set_str_or_abort (z, data[i].z, 0); + + /* don't try negatives or forced sign in hex or octal */ + if (mpz_fits_slong_p (z) + && ! (hex_or_octal_p (data[i].fmt) + && (strchr (data[i].fmt, '+') != NULL || mpz_sgn(z) < 0))) + { + check_plain (data[i].want, data[i].fmt, mpz_get_si (z)); + } + + check_one (data[i].want, data[i].fmt, z); + + /* Same again, with %N and possibly some high zero limbs */ + nfmt = __gmp_allocate_strdup (data[i].fmt); + for (j = 0; nfmt[j] != '\0'; j++) + if (nfmt[j] == 'Z') + nfmt[j] = 'N'; + for (zeros = 0; zeros <= 3; zeros++) + { + nsize = ABSIZ(z)+zeros; + MPZ_REALLOC (z, nsize); + nsize = (SIZ(z) >= 0 ? nsize : -nsize); + refmpn_zero (PTR(z)+ABSIZ(z), zeros); + check_one (data[i].want, nfmt, PTR(z), nsize); + } + __gmp_free_func (nfmt, strlen(nfmt)+1); + } + + mpz_clear (z); +} + +void +check_q (void) +{ + static const struct { + const char *fmt; + const char *q; + const char *want; + } data[] = { + { "%Qd", "0", "0" }, + { "%Qd", "1", "1" }, + { "%Qd", "123", "123" }, + { "%Qd", "-1", "-1" }, + { "%Qd", "-123", "-123" }, + { "%Qd", "3/2", "3/2" }, + { "%Qd", "-3/2", "-3/2" }, + + { "%+Qd", "0", "+0" }, + { "%+Qd", "123", "+123" }, + { "%+Qd", "-123", "-123" }, + { "%+Qd", "5/8", "+5/8" }, + { "%+Qd", "-5/8", "-5/8" }, + + { "%Qx", "123", "7b" }, + { "%QX", "123", "7B" }, + { "%Qx", "15/16", "f/10" }, + { "%QX", "15/16", "F/10" }, + { "%Qx", "-123", "-7b" }, + { "%QX", "-123", "-7B" }, + { "%Qx", "-15/16", "-f/10" }, + { "%QX", "-15/16", "-F/10" }, + { "%Qo", "123", "173" }, + { "%Qo", "-123", "-173" }, + { "%Qo", "16/17", "20/21" }, + { "%Qo", "-16/17", "-20/21" }, + + { "%#Qx", "0", "0" }, + { "%#QX", "0", "0" }, + { "%#Qx", "123", "0x7b" }, + { "%#QX", "123", "0X7B" }, + { "%#Qx", "5/8", "0x5/0x8" }, + { "%#QX", "5/8", "0X5/0X8" }, + { "%#Qx", "-123", "-0x7b" }, + { "%#QX", "-123", "-0X7B" }, + { "%#Qx", "-5/8", "-0x5/0x8" }, + { "%#QX", "-5/8", "-0X5/0X8" }, + { "%#Qo", "0", "0" }, + { "%#Qo", "123", "0173" }, + { "%#Qo", "-123", "-0173" }, + { "%#Qo", "5/7", "05/07" }, + { "%#Qo", "-5/7", "-05/07" }, + + /* zero denominator and showbase */ + { "%#10Qo", "0/0", " 0/0" }, + { "%#10Qd", "0/0", " 0/0" }, + { "%#10Qx", "0/0", " 0/0" }, + { "%#10Qo", "123/0", " 0173/0" }, + { "%#10Qd", "123/0", " 123/0" }, + { "%#10Qx", "123/0", " 0x7b/0" }, + { "%#10QX", "123/0", " 0X7B/0" }, + { "%#10Qo", "-123/0", " -0173/0" }, + { "%#10Qd", "-123/0", " -123/0" }, + { "%#10Qx", "-123/0", " -0x7b/0" }, + { "%#10QX", "-123/0", " -0X7B/0" }, + + { "%10Qd", "0", " 0" }, + { "%-10Qd", "0", "0 " }, + { "%10Qd", "123", " 123" }, + { "%-10Qd", "123", "123 " }, + { "%10Qd", "-123", " -123" }, + { "%-10Qd", "-123", "-123 " }, + + { "%+10Qd", "123", " +123" }, + { "%+-10Qd", "123", "+123 " }, + { "%+10Qd", "-123", " -123" }, + { "%+-10Qd", "-123", "-123 " }, + + { "%08Qd", "0", "00000000" }, + { "%08Qd", "123", "00000123" }, + { "%08Qd", "-123", "-0000123" }, + + { "%+08Qd", "0", "+0000000" }, + { "%+08Qd", "123", "+0000123" }, + { "%+08Qd", "-123", "-0000123" }, + + { "%#08Qx", "0", "00000000" }, + { "%#08Qx", "123", "0x00007b" }, + { "%#08Qx", "-123", "-0x0007b" }, + + { "%+#08Qx", "0", "+0000000" }, + { "%+#08Qx", "123", "+0x0007b" }, + { "%+#08Qx", "-123", "-0x0007b" }, + }; + + int i; + mpq_t q; + + mpq_init (q); + + for (i = 0; i < numberof (data); i++) + { + mpq_set_str_or_abort (q, data[i].q, 0); + check_one (data[i].want, data[i].fmt, q); + } + + mpq_clear (q); +} + +void +check_f (void) +{ + static const struct { + const char *fmt; + const char *f; + const char *want; + + } data[] = { + + { "%Ff", "0", "0.000000" }, + { "%Ff", "123", "123.000000" }, + { "%Ff", "-123", "-123.000000" }, + + { "%+Ff", "0", "+0.000000" }, + { "%+Ff", "123", "+123.000000" }, + { "%+Ff", "-123", "-123.000000" }, + + { "%.0Ff", "0", "0" }, + { "%.0Ff", "123", "123" }, + { "%.0Ff", "-123", "-123" }, + + { "%8.0Ff", "0", " 0" }, + { "%8.0Ff", "123", " 123" }, + { "%8.0Ff", "-123", " -123" }, + + { "%08.0Ff", "0", "00000000" }, + { "%08.0Ff", "123", "00000123" }, + { "%08.0Ff", "-123", "-0000123" }, + + { "%10.2Ff", "0", " 0.00" }, + { "%10.2Ff", "0.25", " 0.25" }, + { "%10.2Ff", "123.25", " 123.25" }, + { "%10.2Ff", "-123.25", " -123.25" }, + + { "%-10.2Ff", "0", "0.00 " }, + { "%-10.2Ff", "0.25", "0.25 " }, + { "%-10.2Ff", "123.25", "123.25 " }, + { "%-10.2Ff", "-123.25", "-123.25 " }, + + { "%.2Ff", "0.00000000000001", "0.00" }, + { "%.2Ff", "0.002", "0.00" }, + { "%.2Ff", "0.008", "0.01" }, + + { "%.0Ff", "123.00000000000001", "123" }, + { "%.0Ff", "123.2", "123" }, + { "%.0Ff", "123.8", "124" }, + + { "%.0Ff", "999999.9", "1000000" }, + { "%.0Ff", "3999999.9", "4000000" }, + + { "%Fe", "0", "0.000000e+00" }, + { "%Fe", "1", "1.000000e+00" }, + { "%Fe", "123", "1.230000e+02" }, + + { "%FE", "0", "0.000000E+00" }, + { "%FE", "1", "1.000000E+00" }, + { "%FE", "123", "1.230000E+02" }, + + { "%Fe", "0", "0.000000e+00" }, + { "%Fe", "1", "1.000000e+00" }, + + { "%.0Fe", "10000000000", "1e+10" }, + { "%.0Fe", "-10000000000", "-1e+10" }, + + { "%.2Fe", "10000000000", "1.00e+10" }, + { "%.2Fe", "-10000000000", "-1.00e+10" }, + + { "%8.0Fe", "10000000000", " 1e+10" }, + { "%8.0Fe", "-10000000000", " -1e+10" }, + + { "%-8.0Fe", "10000000000", "1e+10 " }, + { "%-8.0Fe", "-10000000000", "-1e+10 " }, + + { "%12.2Fe", "10000000000", " 1.00e+10" }, + { "%12.2Fe", "-10000000000", " -1.00e+10" }, + + { "%012.2Fe", "10000000000", "00001.00e+10" }, + { "%012.2Fe", "-10000000000", "-0001.00e+10" }, + + { "%Fg", "0", "0" }, + { "%Fg", "1", "1" }, + { "%Fg", "-1", "-1" }, + + { "%.0Fg", "0", "0" }, + { "%.0Fg", "1", "1" }, + { "%.0Fg", "-1", "-1" }, + + { "%.1Fg", "100", "1e+02" }, + { "%.2Fg", "100", "1e+02" }, + { "%.3Fg", "100", "100" }, + { "%.4Fg", "100", "100" }, + + { "%Fg", "0.001", "0.001" }, + { "%Fg", "0.0001", "0.0001" }, + { "%Fg", "0.00001", "1e-05" }, + { "%Fg", "0.000001", "1e-06" }, + + { "%.4Fg", "1.00000000000001", "1" }, + { "%.4Fg", "100000000000001", "1e+14" }, + + { "%.4Fg", "12345678", "1.235e+07" }, + + { "%Fa", "0","0x0p+0" }, + { "%FA", "0","0X0P+0" }, + + { "%Fa", "1","0x1p+0" }, + { "%Fa", "65535","0xf.fffp+12" }, + { "%Fa", "65536","0x1p+16" }, + { "%F.10a", "65536","0x1.0000000000p+16" }, + { "%F.1a", "65535","0x1.0p+16" }, + { "%F.0a", "65535","0x1p+16" }, + + { "%.2Ff", "0.99609375", "1.00" }, + { "%.Ff", "0.99609375", "0.99609375" }, + { "%.Fe", "0.99609375", "9.9609375e-01" }, + { "%.Fg", "0.99609375", "0.99609375" }, + { "%.20Fg", "1000000", "1000000" }, + { "%.Fg", "1000000", "1000000" }, + + { "%#.0Ff", "1", "1." }, + { "%#.0Fe", "1", "1.e+00" }, + { "%#.0Fg", "1", "1." }, + + { "%#.1Ff", "1", "1.0" }, + { "%#.1Fe", "1", "1.0e+00" }, + { "%#.1Fg", "1", "1." }, + + { "%#.4Ff", "1234", "1234.0000" }, + { "%#.4Fe", "1234", "1.2340e+03" }, + { "%#.4Fg", "1234", "1234." }, + + { "%#.8Ff", "1234", "1234.00000000" }, + { "%#.8Fe", "1234", "1.23400000e+03" }, + { "%#.8Fg", "1234", "1234.0000" }, + + }; + + int i; + mpf_t f; + double d; + + mpf_init2 (f, 256L); + + for (i = 0; i < numberof (data); i++) + { + if (data[i].f[0] == '0' && data[i].f[1] == 'x') + mpf_set_str_or_abort (f, data[i].f, 16); + else + mpf_set_str_or_abort (f, data[i].f, 10); + + /* if mpf->double doesn't truncate, then expect same result */ + d = mpf_get_d (f); + if (mpf_cmp_d (f, d) == 0) + check_plain (data[i].want, data[i].fmt, d); + + check_one (data[i].want, data[i].fmt, f); + } + + mpf_clear (f); +} + + +void +check_limb (void) +{ + int i; + mp_limb_t limb; + mpz_t z; + char *s; + + check_one ("0", "%Md", CNST_LIMB(0)); + check_one ("1", "%Md", CNST_LIMB(1)); + + /* "i" many 1 bits, tested against mpz_get_str in decimal and hex */ + limb = 1; + mpz_init_set_ui (z, 1L); + for (i = 1; i <= GMP_LIMB_BITS; i++) + { + s = mpz_get_str (NULL, 10, z); + check_one (s, "%Mu", limb); + (*__gmp_free_func) (s, strlen (s) + 1); + + s = mpz_get_str (NULL, 16, z); + check_one (s, "%Mx", limb); + (*__gmp_free_func) (s, strlen (s) + 1); + + s = mpz_get_str (NULL, -16, z); + check_one (s, "%MX", limb); + (*__gmp_free_func) (s, strlen (s) + 1); + + limb = 2*limb + 1; + mpz_mul_2exp (z, z, 1L); + mpz_add_ui (z, z, 1L); + } + + mpz_clear (z); +} + + +void +check_n (void) +{ + { + int n = -1; + check_one ("blah", "%nblah", &n); + ASSERT_ALWAYS (n == 0); + } + + { + int n = -1; + check_one ("hello ", "hello %n", &n); + ASSERT_ALWAYS (n == 6); + } + + { + int n = -1; + check_one ("hello world", "hello %n world", &n); + ASSERT_ALWAYS (n == 6); + } + +#define CHECK_N(type, string) \ + do { \ + type x[2]; \ + char fmt[128]; \ + \ + x[0] = ~ (type) 0; \ + x[1] = ~ (type) 0; \ + sprintf (fmt, "%%d%%%sn%%d", string); \ + check_one ("123456", fmt, 123, &x[0], 456); \ + \ + /* should write whole of x[0] and none of x[1] */ \ + ASSERT_ALWAYS (x[0] == 3); \ + ASSERT_ALWAYS (x[1] == (type) ~ (type) 0); \ + \ + } while (0) + + CHECK_N (mp_limb_t, "M"); + CHECK_N (char, "hh"); + CHECK_N (long, "l"); +#if HAVE_LONG_LONG + CHECK_N (long long, "L"); +#endif +#if HAVE_INTMAX_T + CHECK_N (intmax_t, "j"); +#endif +#if HAVE_PTRDIFF_T + CHECK_N (ptrdiff_t, "t"); +#endif + CHECK_N (short, "h"); + CHECK_N (size_t, "z"); + + { + mpz_t x[2]; + mpz_init_set_si (x[0], -987L); + mpz_init_set_si (x[1], 654L); + check_one ("123456", "%d%Zn%d", 123, x[0], 456); + MPZ_CHECK_FORMAT (x[0]); + MPZ_CHECK_FORMAT (x[1]); + ASSERT_ALWAYS (mpz_cmp_ui (x[0], 3L) == 0); + ASSERT_ALWAYS (mpz_cmp_ui (x[1], 654L) == 0); + mpz_clear (x[0]); + mpz_clear (x[1]); + } + + { + mpq_t x[2]; + mpq_init (x[0]); + mpq_init (x[1]); + mpq_set_ui (x[0], 987L, 654L); + mpq_set_ui (x[1], 4115L, 226L); + check_one ("123456", "%d%Qn%d", 123, x[0], 456); + MPQ_CHECK_FORMAT (x[0]); + MPQ_CHECK_FORMAT (x[1]); + ASSERT_ALWAYS (mpq_cmp_ui (x[0], 3L, 1L) == 0); + ASSERT_ALWAYS (mpq_cmp_ui (x[1], 4115L, 226L) == 0); + mpq_clear (x[0]); + mpq_clear (x[1]); + } + + { + mpf_t x[2]; + mpf_init (x[0]); + mpf_init (x[1]); + mpf_set_ui (x[0], 987L); + mpf_set_ui (x[1], 654L); + check_one ("123456", "%d%Fn%d", 123, x[0], 456); + MPF_CHECK_FORMAT (x[0]); + MPF_CHECK_FORMAT (x[1]); + ASSERT_ALWAYS (mpf_cmp_ui (x[0], 3L) == 0); + ASSERT_ALWAYS (mpf_cmp_ui (x[1], 654L) == 0); + mpf_clear (x[0]); + mpf_clear (x[1]); + } + + { + mp_limb_t a[5]; + mp_limb_t a_want[numberof(a)]; + mp_size_t i; + + a[0] = 123; + check_one ("blah", "bl%Nnah", a, (mp_size_t) 0); + ASSERT_ALWAYS (a[0] == 123); + + MPN_ZERO (a_want, numberof (a_want)); + for (i = 1; i < numberof (a); i++) + { + check_one ("blah", "bl%Nnah", a, i); + a_want[0] = 2; + ASSERT_ALWAYS (mpn_cmp (a, a_want, i) == 0); + } + } +} + + +void +check_misc (void) +{ + mpz_t z; + mpf_t f; + + mpz_init (z); + mpf_init2 (f, 128L); + + check_one ("!", "%c", '!'); + + check_one ("hello world", "hello %s", "world"); + check_one ("hello:", "%s:", "hello"); + mpz_set_ui (z, 0L); + check_one ("hello0", "%s%Zd", "hello", z, z); + + { + static char xs[801]; + memset (xs, 'x', sizeof(xs)-1); + check_one (xs, "%s", xs); + } + { + char *xs; + xs = (char *) (*__gmp_allocate_func) (MAX_OUTPUT * 2 - 12); + memset (xs, '%', MAX_OUTPUT * 2 - 14); + xs [MAX_OUTPUT * 2 - 13] = '\0'; + xs [MAX_OUTPUT * 2 - 14] = 'x'; + check_one (xs + MAX_OUTPUT - 7, xs, NULL); + (*__gmp_free_func) (xs, MAX_OUTPUT * 2 - 12); + } + + mpz_set_ui (z, 12345L); + check_one (" 12345", "%*Zd", 10, z); + check_one ("0000012345", "%0*Zd", 10, z); + check_one ("12345 ", "%*Zd", -10, z); + check_one ("12345 and 678", "%Zd and %d", z, 678); + check_one ("12345,1,12345,2,12345", "%Zd,%d,%Zd,%d,%Zd", z, 1, z, 2, z); + + /* from the glibc info docs */ + mpz_set_si (z, 0L); + check_one ("| 0|0 | +0|+0 | 0|00000| | 00|0|", + "|%5Zd|%-5Zd|%+5Zd|%+-5Zd|% 5Zd|%05Zd|%5.0Zd|%5.2Zd|%Zd|", + /**/ z, z, z, z, z, z, z, z, z); + mpz_set_si (z, 1L); + check_one ("| 1|1 | +1|+1 | 1|00001| 1| 01|1|", + "|%5Zd|%-5Zd|%+5Zd|%+-5Zd|% 5Zd|%05Zd|%5.0Zd|%5.2Zd|%Zd|", + /**/ z, z, z, z, z, z, z, z, z); + mpz_set_si (z, -1L); + check_one ("| -1|-1 | -1|-1 | -1|-0001| -1| -01|-1|", + "|%5Zd|%-5Zd|%+5Zd|%+-5Zd|% 5Zd|%05Zd|%5.0Zd|%5.2Zd|%Zd|", + /**/ z, z, z, z, z, z, z, z, z); + mpz_set_si (z, 100000L); + check_one ("|100000|100000|+100000|+100000| 100000|100000|100000|100000|100000|", + "|%5Zd|%-5Zd|%+5Zd|%+-5Zd|% 5Zd|%05Zd|%5.0Zd|%5.2Zd|%Zd|", + /**/ z, z, z, z, z, z, z, z, z); + mpz_set_si (z, 0L); + check_one ("| 0| 0| 0| 0| 0| 0| 00000000|", + "|%5Zo|%5Zx|%5ZX|%#5Zo|%#5Zx|%#5ZX|%#10.8Zx|", + /**/ z, z, z, z, z, z, z); + mpz_set_si (z, 1L); + check_one ("| 1| 1| 1| 01| 0x1| 0X1|0x00000001|", + "|%5Zo|%5Zx|%5ZX|%#5Zo|%#5Zx|%#5ZX|%#10.8Zx|", + /**/ z, z, z, z, z, z, z); + mpz_set_si (z, 100000L); + check_one ("|303240|186a0|186A0|0303240|0x186a0|0X186A0|0x000186a0|", + "|%5Zo|%5Zx|%5ZX|%#5Zo|%#5Zx|%#5ZX|%#10.8Zx|", + /**/ z, z, z, z, z, z, z); + + /* %zd for size_t won't be available on old systems, and running something + to see if it works might be bad, so only try it on glibc, and only on a + new enough version (glibc 2.0 doesn't have %zd) */ +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0) + mpz_set_ui (z, 789L); + check_one ("456 789 blah", "%zd %Zd blah", (size_t) 456, z); +#endif + + mpz_clear (z); + mpf_clear (f); +} + + +int +main (int argc, char *argv[]) +{ + if (argc > 1 && strcmp (argv[1], "-s") == 0) + option_check_printf = 1; + + tests_start (); + check_vfprintf_fp = fopen (CHECK_VFPRINTF_FILENAME, "w+"); + ASSERT_ALWAYS (check_vfprintf_fp != NULL); + + check_z (); + check_q (); + check_f (); + check_limb (); + check_n (); + check_misc (); + + ASSERT_ALWAYS (fclose (check_vfprintf_fp) == 0); + unlink (CHECK_VFPRINTF_FILENAME); + tests_end (); + exit (0); +} diff --git a/vendor/gmp-6.3.0/tests/misc/t-scanf.c b/vendor/gmp-6.3.0/tests/misc/t-scanf.c new file mode 100644 index 0000000..8b82f1e --- /dev/null +++ b/vendor/gmp-6.3.0/tests/misc/t-scanf.c @@ -0,0 +1,1615 @@ +/* Test gmp_scanf and related functions. + +Copyright 2001-2004 Free Software Foundation, Inc. + +This file is part of the GNU MP Library test suite. + +The GNU MP Library test suite is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 3 of the License, +or (at your option) any later version. + +The GNU MP Library test suite is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along with +the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ + + +/* Usage: t-scanf [-s] + + -s Check the data against the system scanf, where possible. This is + only an option since we don't want to fail if the system scanf is + faulty or strange. + + There's some fairly unattractive repetition between check_z, check_q and + check_f, but enough differences to make a common loop or a set of macros + seem like too much trouble. */ + +#include "config.h" /* needed for the HAVE_, could also move gmp incls */ + +#include <stdarg.h> + +#include <stddef.h> /* for ptrdiff_t */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#if HAVE_INTTYPES_H +# include <inttypes.h> /* for intmax_t */ +#endif +#if HAVE_STDINT_H +# include <stdint.h> +#endif + +#if HAVE_UNISTD_H +#include <unistd.h> /* for unlink */ +#endif + +#include "gmp-impl.h" +#include "tests.h" + + +#define TEMPFILE "t-scanf.tmp" + +int option_libc_scanf = 0; + +typedef int (*fun_t) (const char *, const char *, void *, void *); + + +/* This problem was seen on powerpc7450-apple-darwin7.0.0, sscanf returns 0 + where it should return EOF. A workaround in gmp_sscanf would be a bit + tedious, and since this is a rather obvious libc bug, quite likely + affecting other programs, we'll just suppress affected tests for now. */ +int +test_sscanf_eof_ok (void) +{ + static int result = -1; + + if (result == -1) + { + int x; + if (sscanf ("", "%d", &x) == EOF) + { + result = 1; + } + else + { + printf ("Warning, sscanf(\"\",\"%%d\",&x) doesn't return EOF.\n"); + printf ("This affects gmp_sscanf, tests involving it will be suppressed.\n"); + printf ("You should try to get a fix for your libc.\n"); + result = 0; + } + } + return result; +} + + +/* Convert fmt from a GMP scanf format string to an equivalent for a plain + libc scanf, for example "%Zd" becomes "%ld". Return 1 if this succeeds, + 0 if it cannot (or should not) be done. */ +int +libc_scanf_convert (char *fmt) +{ + char *p = fmt; + + if (! option_libc_scanf) + return 0; + + for ( ; *fmt != '\0'; fmt++) + { + switch (*fmt) { + case 'F': + case 'Q': + case 'Z': + /* transmute */ + *p++ = 'l'; + break; + default: + *p++ = *fmt; + break; + } + } + *p = '\0'; + return 1; +} + + +long got_ftell; +int fromstring_next_c; + +/* Call gmp_fscanf, reading the "input" string data provided. */ +int +fromstring_gmp_fscanf (const char *input, const char *fmt, ...) +{ + va_list ap; + FILE *fp; + int ret; + va_start (ap, fmt); + + fp = fopen (TEMPFILE, "w+"); + ASSERT_ALWAYS (fp != NULL); + ASSERT_ALWAYS (fputs (input, fp) != EOF); + ASSERT_ALWAYS (fflush (fp) == 0); + rewind (fp); + + ret = gmp_vfscanf (fp, fmt, ap); + got_ftell = ftell (fp); + ASSERT_ALWAYS (got_ftell != -1L); + + fromstring_next_c = getc (fp); + + ASSERT_ALWAYS (fclose (fp) == 0); + va_end (ap); + return ret; +} + + +int +fun_gmp_sscanf (const char *input, const char *fmt, void *a1, void *a2) +{ + if (a2 == NULL) + return gmp_sscanf (input, fmt, a1); + else + return gmp_sscanf (input, fmt, a1, a2); +} + +int +fun_gmp_fscanf (const char *input, const char *fmt, void *a1, void *a2) +{ + if (a2 == NULL) + return fromstring_gmp_fscanf (input, fmt, a1); + else + return fromstring_gmp_fscanf (input, fmt, a1, a2); +} + + +int +fun_fscanf (const char *input, const char *fmt, void *a1, void *a2) +{ + FILE *fp; + int ret; + + fp = fopen (TEMPFILE, "w+"); + ASSERT_ALWAYS (fp != NULL); + ASSERT_ALWAYS (fputs (input, fp) != EOF); + ASSERT_ALWAYS (fflush (fp) == 0); + rewind (fp); + + if (a2 == NULL) + ret = fscanf (fp, fmt, a1); + else + ret = fscanf (fp, fmt, a1, a2); + + got_ftell = ftell (fp); + ASSERT_ALWAYS (got_ftell != -1L); + + fromstring_next_c = getc (fp); + + ASSERT_ALWAYS (fclose (fp) == 0); + return ret; +} + + +/* On various old systems, for instance HP-UX 9, the C library sscanf needs + to be able to write into the input string. Ensure that this is possible, + when gcc is putting the test data into a read-only section. + + Actually we ought to only need this under SSCANF_WRITABLE_INPUT from + configure, but it's just as easy to do it unconditionally, and in any + case this code is only executed under the -s option. */ + +int +fun_sscanf (const char *input, const char *fmt, void *a1, void *a2) +{ + char *input_writable; + size_t size; + int ret; + + size = strlen (input) + 1; + input_writable = (char *) (*__gmp_allocate_func) (size); + memcpy (input_writable, input, size); + + if (a2 == NULL) + ret = sscanf (input_writable, fmt, a1); + else + ret = sscanf (input_writable, fmt, a1, a2); + + (*__gmp_free_func) (input_writable, size); + return ret; +} + + +/* whether the format string consists entirely of ignored fields */ +int +fmt_allignore (const char *fmt) +{ + int saw_star = 1; + for ( ; *fmt != '\0'; fmt++) + { + switch (*fmt) { + case '%': + if (! saw_star) + return 0; + saw_star = 0; + break; + case '*': + saw_star = 1; + break; + } + } + return 1; +} + +void +check_z (void) +{ + static const struct { + const char *fmt; + const char *input; + const char *want; + int want_ret; + long want_ftell; + int want_upto; + int not_glibc; + + } data[] = { + + { "%Zd", "0", "0", 1, -1, -1 }, + { "%Zd", "1", "1", 1, -1, -1 }, + { "%Zd", "123", "123", 1, -1, -1 }, + { "%Zd", "+0", "0", 1, -1, -1 }, + { "%Zd", "+1", "1", 1, -1, -1 }, + { "%Zd", "+123", "123", 1, -1, -1 }, + { "%Zd", "-0", "0", 1, -1, -1 }, + { "%Zd", "-1", "-1", 1, -1, -1 }, + { "%Zd", "-123", "-123", 1, -1, -1 }, + + { "%Zo", "0", "0", 1, -1, -1 }, + { "%Zo", "173", "123", 1, -1, -1 }, + { "%Zo", "+0", "0", 1, -1, -1 }, + { "%Zo", "+173", "123", 1, -1, -1 }, + { "%Zo", "-0", "0", 1, -1, -1 }, + { "%Zo", "-173", "-123", 1, -1, -1 }, + + { "%Zx", "0", "0", 1, -1, -1 }, + { "%Zx", "7b", "123", 1, -1, -1 }, + { "%Zx", "7b", "123", 1, -1, -1 }, + { "%Zx", "+0", "0", 1, -1, -1 }, + { "%Zx", "+7b", "123", 1, -1, -1 }, + { "%Zx", "+7b", "123", 1, -1, -1 }, + { "%Zx", "-0", "-0", 1, -1, -1 }, + { "%Zx", "-7b", "-123", 1, -1, -1 }, + { "%Zx", "-7b", "-123", 1, -1, -1 }, + { "%ZX", "0", "0", 1, -1, -1 }, + { "%ZX", "7b", "123", 1, -1, -1 }, + { "%ZX", "7b", "123", 1, -1, -1 }, + { "%ZX", "+0", "0", 1, -1, -1 }, + { "%ZX", "+7b", "123", 1, -1, -1 }, + { "%ZX", "+7b", "123", 1, -1, -1 }, + { "%ZX", "-0", "-0", 1, -1, -1 }, + { "%ZX", "-7b", "-123", 1, -1, -1 }, + { "%ZX", "-7b", "-123", 1, -1, -1 }, + { "%Zx", "0", "0", 1, -1, -1 }, + { "%Zx", "7B", "123", 1, -1, -1 }, + { "%Zx", "7B", "123", 1, -1, -1 }, + { "%Zx", "+0", "0", 1, -1, -1 }, + { "%Zx", "+7B", "123", 1, -1, -1 }, + { "%Zx", "+7B", "123", 1, -1, -1 }, + { "%Zx", "-0", "-0", 1, -1, -1 }, + { "%Zx", "-7B", "-123", 1, -1, -1 }, + { "%Zx", "-7B", "-123", 1, -1, -1 }, + { "%ZX", "0", "0", 1, -1, -1 }, + { "%ZX", "7B", "123", 1, -1, -1 }, + { "%ZX", "7B", "123", 1, -1, -1 }, + { "%ZX", "+0", "0", 1, -1, -1 }, + { "%ZX", "+7B", "123", 1, -1, -1 }, + { "%ZX", "+7B", "123", 1, -1, -1 }, + { "%ZX", "-0", "-0", 1, -1, -1 }, + { "%ZX", "-7B", "-123", 1, -1, -1 }, + { "%ZX", "-7B", "-123", 1, -1, -1 }, + + { "%Zi", "0", "0", 1, -1, -1 }, + { "%Zi", "1", "1", 1, -1, -1 }, + { "%Zi", "123", "123", 1, -1, -1 }, + { "%Zi", "+0", "0", 1, -1, -1 }, + { "%Zi", "+1", "1", 1, -1, -1 }, + { "%Zi", "+123", "123", 1, -1, -1 }, + { "%Zi", "-0", "0", 1, -1, -1 }, + { "%Zi", "-1", "-1", 1, -1, -1 }, + { "%Zi", "-123", "-123", 1, -1, -1 }, + + { "%Zi", "00", "0", 1, -1, -1 }, + { "%Zi", "0173", "123", 1, -1, -1 }, + { "%Zi", "+00", "0", 1, -1, -1 }, + { "%Zi", "+0173", "123", 1, -1, -1 }, + { "%Zi", "-00", "0", 1, -1, -1 }, + { "%Zi", "-0173", "-123", 1, -1, -1 }, + + { "%Zi", "0x0", "0", 1, -1, -1 }, + { "%Zi", "0x7b", "123", 1, -1, -1 }, + { "%Zi", "0x7b", "123", 1, -1, -1 }, + { "%Zi", "+0x0", "0", 1, -1, -1 }, + { "%Zi", "+0x7b", "123", 1, -1, -1 }, + { "%Zi", "+0x7b", "123", 1, -1, -1 }, + { "%Zi", "-0x0", "-0", 1, -1, -1 }, + { "%Zi", "-0x7b", "-123", 1, -1, -1 }, + { "%Zi", "-0x7b", "-123", 1, -1, -1 }, + { "%Zi", "0X0", "0", 1, -1, -1 }, + { "%Zi", "0X7b", "123", 1, -1, -1 }, + { "%Zi", "0X7b", "123", 1, -1, -1 }, + { "%Zi", "+0X0", "0", 1, -1, -1 }, + { "%Zi", "+0X7b", "123", 1, -1, -1 }, + { "%Zi", "+0X7b", "123", 1, -1, -1 }, + { "%Zi", "-0X0", "-0", 1, -1, -1 }, + { "%Zi", "-0X7b", "-123", 1, -1, -1 }, + { "%Zi", "-0X7b", "-123", 1, -1, -1 }, + { "%Zi", "0x0", "0", 1, -1, -1 }, + { "%Zi", "0x7B", "123", 1, -1, -1 }, + { "%Zi", "0x7B", "123", 1, -1, -1 }, + { "%Zi", "+0x0", "0", 1, -1, -1 }, + { "%Zi", "+0x7B", "123", 1, -1, -1 }, + { "%Zi", "+0x7B", "123", 1, -1, -1 }, + { "%Zi", "-0x0", "-0", 1, -1, -1 }, + { "%Zi", "-0x7B", "-123", 1, -1, -1 }, + { "%Zi", "-0x7B", "-123", 1, -1, -1 }, + { "%Zi", "0X0", "0", 1, -1, -1 }, + { "%Zi", "0X7B", "123", 1, -1, -1 }, + { "%Zi", "0X7B", "123", 1, -1, -1 }, + { "%Zi", "+0X0", "0", 1, -1, -1 }, + { "%Zi", "+0X7B", "123", 1, -1, -1 }, + { "%Zi", "+0X7B", "123", 1, -1, -1 }, + { "%Zi", "-0X0", "-0", 1, -1, -1 }, + { "%Zi", "-0X7B", "-123", 1, -1, -1 }, + { "%Zi", "-0X7B", "-123", 1, -1, -1 }, + + { "%Zd", " 0", "0", 1, -1, -1 }, + { "%Zd", " 0", "0", 1, -1, -1 }, + { "%Zd", " 0", "0", 1, -1, -1 }, + { "%Zd", "\t0", "0", 1, -1, -1 }, + { "%Zd", "\t\t0", "0", 1, -1, -1 }, + + { "hello%Zd", "hello0", "0", 1, -1, -1 }, + { "hello%Zd", "hello 0", "0", 1, -1, -1 }, + { "hello%Zd", "hello \t0", "0", 1, -1, -1 }, + { "hello%Zdworld", "hello 0world", "0", 1, -1, -1 }, + + { "hello%*Zd", "hello0", "-999", 0, -1, -1 }, + { "hello%*Zd", "hello 0", "-999", 0, -1, -1 }, + { "hello%*Zd", "hello \t0", "-999", 0, -1, -1 }, + { "hello%*Zdworld", "hello 0world", "-999", 0, -1, -1 }, + + { "%Zd", "", "-999", -1, -1, -555 }, + { "%Zd", " ", "-999", -1, -1, -555 }, + { " %Zd", "", "-999", -1, -1, -555 }, + { "xyz%Zd", "", "-999", -1, -1, -555 }, + + { "%*Zd", "", "-999", -1, -1, -555 }, + { " %*Zd", "", "-999", -1, -1, -555 }, + { "xyz%*Zd", "", "-999", -1, -1, -555 }, + + { "%Zd", "xyz", "0", 0, 0, -555 }, + + /* match something, but invalid */ + { "%Zd", "-", "-999", 0, 1, -555 }, + { "%Zd", "+", "-999", 0, 1, -555 }, + { "xyz%Zd", "xyz-", "-999", 0, 4, -555 }, + { "xyz%Zd", "xyz+", "-999", 0, 4, -555 }, + { "%Zi", "0x", "-999", 0, 2, -555 }, + { "%Zi", "0X", "-999", 0, 2, -555 }, + { "%Zi", "0x-", "-999", 0, 2, -555 }, + { "%Zi", "0X+", "-999", 0, 2, -555 }, + { "%Zi", "-0x", "-999", 0, 3, -555 }, + { "%Zi", "-0X", "-999", 0, 3, -555 }, + { "%Zi", "+0x", "-999", 0, 3, -555 }, + { "%Zi", "+0X", "-999", 0, 3, -555 }, + + { "%1Zi", "1234", "1", 1, 1, 1 }, + { "%2Zi", "1234", "12", 1, 2, 2 }, + { "%3Zi", "1234", "123", 1, 3, 3 }, + { "%4Zi", "1234", "1234", 1, 4, 4 }, + { "%5Zi", "1234", "1234", 1, 4, 4 }, + { "%6Zi", "1234", "1234", 1, 4, 4 }, + + { "%1Zi", "01234", "0", 1, 1, 1 }, + { "%2Zi", "01234", "01", 1, 2, 2 }, + { "%3Zi", "01234", "012", 1, 3, 3 }, + { "%4Zi", "01234", "0123", 1, 4, 4 }, + { "%5Zi", "01234", "01234", 1, 5, 5 }, + { "%6Zi", "01234", "01234", 1, 5, 5 }, + { "%7Zi", "01234", "01234", 1, 5, 5 }, + + { "%1Zi", "0x1234", "0", 1, 1, 1 }, + { "%2Zi", "0x1234", "-999", 0, 2, -555 }, + { "%3Zi", "0x1234", "0x1", 1, 3, 3 }, + { "%4Zi", "0x1234", "0x12", 1, 4, 4 }, + { "%5Zi", "0x1234", "0x123", 1, 5, 5 }, + { "%6Zi", "0x1234", "0x1234", 1, 6, 6 }, + { "%7Zi", "0x1234", "0x1234", 1, 6, 6 }, + { "%8Zi", "0x1234", "0x1234", 1, 6, 6 }, + + { "%%xyz%Zd", "%xyz123", "123", 1, -1, -1 }, + { "12%%34%Zd", "12%34567", "567", 1, -1, -1 }, + { "%%%%%Zd", "%%123", "123", 1, -1, -1 }, + + /* various subtle EOF cases */ + { "x", "", "-999", EOF, 0, -555 }, + { " x", "", "-999", EOF, 0, -555 }, + { "xyz", "", "-999", EOF, 0, -555 }, + { " ", "", "-999", 0, 0, 0 }, + { " ", " ", "-999", 0, 1, 1 }, + { "%*Zd%Zd", "", "-999", EOF, 0, -555 }, + { "%*Zd%Zd", "123", "-999", EOF, 3, -555 }, + { "x", "x", "-999", 0, 1, 1 }, + { "xyz", "x", "-999", EOF, 1, -555 }, + { "xyz", "xy", "-999", EOF, 2, -555 }, + { "xyz", "xyz", "-999", 0, 3, 3 }, + { "%Zn", "", "0", 0, 0, 0 }, + { " %Zn", "", "0", 0, 0, 0 }, + { " x%Zn", "", "-999", EOF, 0, -555 }, + { "xyz%Zn", "", "-999", EOF, 0, -555 }, + { " x%Zn", "", "-999", EOF, 0, -555 }, + { " %Zn x", " ", "-999", EOF, 1, -555 }, + + /* these seem to tickle a bug in glibc 2.2.4 */ + { " x", " ", "-999", EOF, 1, -555, 1 }, + { " xyz", " ", "-999", EOF, 1, -555, 1 }, + { " x%Zn", " ", "-999", EOF, 1, -555, 1 }, + }; + + int i, j, ignore; + int got_ret, want_ret, got_upto, want_upto; + mpz_t got, want; + long got_l, want_ftell; + int error = 0; + fun_t fun; + const char *name; + char fmt[128]; + + mpz_init (got); + mpz_init (want); + + for (i = 0; i < numberof (data); i++) + { + mpz_set_str_or_abort (want, data[i].want, 0); + + ASSERT_ALWAYS (strlen (data[i].fmt) + 2 < sizeof (fmt)); + strcpy (fmt, data[i].fmt); + strcat (fmt, "%n"); + + ignore = fmt_allignore (fmt); + + for (j = 0; j <= 3; j++) + { + want_ret = data[i].want_ret; + + want_ftell = data[i].want_ftell; + if (want_ftell == -1) + want_ftell = strlen (data[i].input); + + want_upto = data[i].want_upto; + if (want_upto == -1) + want_upto = strlen (data[i].input); + + switch (j) { + case 0: + name = "gmp_sscanf"; + fun = fun_gmp_sscanf; + break; + case 1: + name = "gmp_fscanf"; + fun = fun_gmp_fscanf; + break; + case 2: +#ifdef __GLIBC__ + if (data[i].not_glibc) + continue; +#endif + if (! libc_scanf_convert (fmt)) + continue; + name = "standard sscanf"; + fun = fun_sscanf; + break; + case 3: +#ifdef __GLIBC__ + if (data[i].not_glibc) + continue; +#endif + if (! libc_scanf_convert (fmt)) + continue; + name = "standard fscanf"; + fun = fun_fscanf; + break; + default: + ASSERT_ALWAYS (0); + break; + } + + got_upto = -555; + got_ftell = -1L; + + switch (j) { + case 0: + case 1: + mpz_set_si (got, -999L); + if (ignore) + got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); + else + got_ret = (*fun) (data[i].input, fmt, got, &got_upto); + break; + case 2: + case 3: + got_l = -999L; + if (ignore) + got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); + else + got_ret = (*fun) (data[i].input, fmt, &got_l, &got_upto); + mpz_set_si (got, got_l); + break; + default: + ASSERT_ALWAYS (0); + break; + } + + MPZ_CHECK_FORMAT (got); + + if (got_ret != want_ret) + { + printf ("%s wrong return value\n", name); + error = 1; + } + if (want_ret == 1 && mpz_cmp (want, got) != 0) + { + printf ("%s wrong result\n", name); + error = 1; + } + if (got_upto != want_upto) + { + printf ("%s wrong upto\n", name); + error = 1; + } + if (got_ftell != -1 && want_ftell != -1 && got_ftell != want_ftell) + { + printf ("%s wrong ftell\n", name); + error = 1; + } + if (error) + { + printf (" fmt \"%s\"\n", data[i].fmt); + printf (" input \"%s\"\n", data[i].input); + printf (" ignore %d\n", ignore); + printf (" ret want=%d\n", want_ret); + printf (" got =%d\n", got_ret); + mpz_trace (" value want", want); + mpz_trace (" got ", got); + printf (" upto want =%d\n", want_upto); + printf (" got =%d\n", got_upto); + if (got_ftell != -1) + { + printf (" ftell want =%ld\n", want_ftell); + printf (" got =%ld\n", got_ftell); + } + abort (); + } + } + } + + mpz_clear (got); + mpz_clear (want); +} + +void +check_q (void) +{ + static const struct { + const char *fmt; + const char *input; + const char *want; + int ret; + long ftell; + + } data[] = { + + { "%Qd", "0", "0", 1, -1 }, + { "%Qd", "1", "1", 1, -1 }, + { "%Qd", "123", "123", 1, -1 }, + { "%Qd", "+0", "0", 1, -1 }, + { "%Qd", "+1", "1", 1, -1 }, + { "%Qd", "+123", "123", 1, -1 }, + { "%Qd", "-0", "0", 1, -1 }, + { "%Qd", "-1", "-1", 1, -1 }, + { "%Qd", "-123", "-123", 1, -1 }, + + { "%Qo", "0", "0", 1, -1 }, + { "%Qo", "173", "123", 1, -1 }, + { "%Qo", "+0", "0", 1, -1 }, + { "%Qo", "+173", "123", 1, -1 }, + { "%Qo", "-0", "0", 1, -1 }, + { "%Qo", "-173", "-123", 1, -1 }, + + { "%Qx", "0", "0", 1, -1 }, + { "%Qx", "7b", "123", 1, -1 }, + { "%Qx", "7b", "123", 1, -1 }, + { "%Qx", "+0", "0", 1, -1 }, + { "%Qx", "+7b", "123", 1, -1 }, + { "%Qx", "+7b", "123", 1, -1 }, + { "%Qx", "-0", "-0", 1, -1 }, + { "%Qx", "-7b", "-123", 1, -1 }, + { "%Qx", "-7b", "-123", 1, -1 }, + { "%QX", "0", "0", 1, -1 }, + { "%QX", "7b", "123", 1, -1 }, + { "%QX", "7b", "123", 1, -1 }, + { "%QX", "+0", "0", 1, -1 }, + { "%QX", "+7b", "123", 1, -1 }, + { "%QX", "+7b", "123", 1, -1 }, + { "%QX", "-0", "-0", 1, -1 }, + { "%QX", "-7b", "-123", 1, -1 }, + { "%QX", "-7b", "-123", 1, -1 }, + { "%Qx", "0", "0", 1, -1 }, + { "%Qx", "7B", "123", 1, -1 }, + { "%Qx", "7B", "123", 1, -1 }, + { "%Qx", "+0", "0", 1, -1 }, + { "%Qx", "+7B", "123", 1, -1 }, + { "%Qx", "+7B", "123", 1, -1 }, + { "%Qx", "-0", "-0", 1, -1 }, + { "%Qx", "-7B", "-123", 1, -1 }, + { "%Qx", "-7B", "-123", 1, -1 }, + { "%QX", "0", "0", 1, -1 }, + { "%QX", "7B", "123", 1, -1 }, + { "%QX", "7B", "123", 1, -1 }, + { "%QX", "+0", "0", 1, -1 }, + { "%QX", "+7B", "123", 1, -1 }, + { "%QX", "+7B", "123", 1, -1 }, + { "%QX", "-0", "-0", 1, -1 }, + { "%QX", "-7B", "-123", 1, -1 }, + { "%QX", "-7B", "-123", 1, -1 }, + + { "%Qi", "0", "0", 1, -1 }, + { "%Qi", "1", "1", 1, -1 }, + { "%Qi", "123", "123", 1, -1 }, + { "%Qi", "+0", "0", 1, -1 }, + { "%Qi", "+1", "1", 1, -1 }, + { "%Qi", "+123", "123", 1, -1 }, + { "%Qi", "-0", "0", 1, -1 }, + { "%Qi", "-1", "-1", 1, -1 }, + { "%Qi", "-123", "-123", 1, -1 }, + + { "%Qi", "00", "0", 1, -1 }, + { "%Qi", "0173", "123", 1, -1 }, + { "%Qi", "+00", "0", 1, -1 }, + { "%Qi", "+0173", "123", 1, -1 }, + { "%Qi", "-00", "0", 1, -1 }, + { "%Qi", "-0173", "-123", 1, -1 }, + + { "%Qi", "0x0", "0", 1, -1 }, + { "%Qi", "0x7b", "123", 1, -1 }, + { "%Qi", "0x7b", "123", 1, -1 }, + { "%Qi", "+0x0", "0", 1, -1 }, + { "%Qi", "+0x7b", "123", 1, -1 }, + { "%Qi", "+0x7b", "123", 1, -1 }, + { "%Qi", "-0x0", "-0", 1, -1 }, + { "%Qi", "-0x7b", "-123", 1, -1 }, + { "%Qi", "-0x7b", "-123", 1, -1 }, + { "%Qi", "0X0", "0", 1, -1 }, + { "%Qi", "0X7b", "123", 1, -1 }, + { "%Qi", "0X7b", "123", 1, -1 }, + { "%Qi", "+0X0", "0", 1, -1 }, + { "%Qi", "+0X7b", "123", 1, -1 }, + { "%Qi", "+0X7b", "123", 1, -1 }, + { "%Qi", "-0X0", "-0", 1, -1 }, + { "%Qi", "-0X7b", "-123", 1, -1 }, + { "%Qi", "-0X7b", "-123", 1, -1 }, + { "%Qi", "0x0", "0", 1, -1 }, + { "%Qi", "0x7B", "123", 1, -1 }, + { "%Qi", "0x7B", "123", 1, -1 }, + { "%Qi", "+0x0", "0", 1, -1 }, + { "%Qi", "+0x7B", "123", 1, -1 }, + { "%Qi", "+0x7B", "123", 1, -1 }, + { "%Qi", "-0x0", "-0", 1, -1 }, + { "%Qi", "-0x7B", "-123", 1, -1 }, + { "%Qi", "-0x7B", "-123", 1, -1 }, + { "%Qi", "0X0", "0", 1, -1 }, + { "%Qi", "0X7B", "123", 1, -1 }, + { "%Qi", "0X7B", "123", 1, -1 }, + { "%Qi", "+0X0", "0", 1, -1 }, + { "%Qi", "+0X7B", "123", 1, -1 }, + { "%Qi", "+0X7B", "123", 1, -1 }, + { "%Qi", "-0X0", "-0", 1, -1 }, + { "%Qi", "-0X7B", "-123", 1, -1 }, + { "%Qi", "-0X7B", "-123", 1, -1 }, + + { "%Qd", " 0", "0", 1, -1 }, + { "%Qd", " 0", "0", 1, -1 }, + { "%Qd", " 0", "0", 1, -1 }, + { "%Qd", "\t0", "0", 1, -1 }, + { "%Qd", "\t\t0", "0", 1, -1 }, + + { "%Qd", "3/2", "3/2", 1, -1 }, + { "%Qd", "+3/2", "3/2", 1, -1 }, + { "%Qd", "-3/2", "-3/2", 1, -1 }, + + { "%Qx", "f/10", "15/16", 1, -1 }, + { "%Qx", "F/10", "15/16", 1, -1 }, + { "%QX", "f/10", "15/16", 1, -1 }, + { "%QX", "F/10", "15/16", 1, -1 }, + + { "%Qo", "20/21", "16/17", 1, -1 }, + { "%Qo", "-20/21", "-16/17", 1, -1 }, + + { "%Qi", "10/11", "10/11", 1, -1 }, + { "%Qi", "+10/11", "10/11", 1, -1 }, + { "%Qi", "-10/11", "-10/11", 1, -1 }, + { "%Qi", "010/11", "8/11", 1, -1 }, + { "%Qi", "+010/11", "8/11", 1, -1 }, + { "%Qi", "-010/11", "-8/11", 1, -1 }, + { "%Qi", "0x10/11", "16/11", 1, -1 }, + { "%Qi", "+0x10/11", "16/11", 1, -1 }, + { "%Qi", "-0x10/11", "-16/11", 1, -1 }, + + { "%Qi", "10/011", "10/9", 1, -1 }, + { "%Qi", "+10/011", "10/9", 1, -1 }, + { "%Qi", "-10/011", "-10/9", 1, -1 }, + { "%Qi", "010/011", "8/9", 1, -1 }, + { "%Qi", "+010/011", "8/9", 1, -1 }, + { "%Qi", "-010/011", "-8/9", 1, -1 }, + { "%Qi", "0x10/011", "16/9", 1, -1 }, + { "%Qi", "+0x10/011", "16/9", 1, -1 }, + { "%Qi", "-0x10/011", "-16/9", 1, -1 }, + + { "%Qi", "10/0x11", "10/17", 1, -1 }, + { "%Qi", "+10/0x11", "10/17", 1, -1 }, + { "%Qi", "-10/0x11", "-10/17", 1, -1 }, + { "%Qi", "010/0x11", "8/17", 1, -1 }, + { "%Qi", "+010/0x11", "8/17", 1, -1 }, + { "%Qi", "-010/0x11", "-8/17", 1, -1 }, + { "%Qi", "0x10/0x11", "16/17", 1, -1 }, + { "%Qi", "+0x10/0x11", "16/17", 1, -1 }, + { "%Qi", "-0x10/0x11", "-16/17", 1, -1 }, + + { "hello%Qd", "hello0", "0", 1, -1 }, + { "hello%Qd", "hello 0", "0", 1, -1 }, + { "hello%Qd", "hello \t0", "0", 1, -1 }, + { "hello%Qdworld", "hello 0world", "0", 1, -1 }, + { "hello%Qd", "hello3/2", "3/2", 1, -1 }, + + { "hello%*Qd", "hello0", "-999/121", 0, -1 }, + { "hello%*Qd", "hello 0", "-999/121", 0, -1 }, + { "hello%*Qd", "hello \t0", "-999/121", 0, -1 }, + { "hello%*Qdworld", "hello 0world", "-999/121", 0, -1 }, + { "hello%*Qdworld", "hello3/2world", "-999/121", 0, -1 }, + + { "%Qd", "", "-999/121", -1, -1 }, + { "%Qd", " ", "-999/121", -1, -1 }, + { " %Qd", "", "-999/121", -1, -1 }, + { "xyz%Qd", "", "-999/121", -1, -1 }, + + { "%*Qd", "", "-999/121", -1, -1 }, + { " %*Qd", "", "-999/121", -1, -1 }, + { "xyz%*Qd", "", "-999/121", -1, -1 }, + + /* match something, but invalid */ + { "%Qd", "-", "-999/121", 0, 1 }, + { "%Qd", "+", "-999/121", 0, 1 }, + { "%Qd", "/-", "-999/121", 0, 1 }, + { "%Qd", "/+", "-999/121", 0, 1 }, + { "%Qd", "-/", "-999/121", 0, 1 }, + { "%Qd", "+/", "-999/121", 0, 1 }, + { "%Qd", "-/-", "-999/121", 0, 1 }, + { "%Qd", "-/+", "-999/121", 0, 1 }, + { "%Qd", "+/+", "-999/121", 0, 1 }, + { "%Qd", "/123", "-999/121", 0, 1 }, + { "%Qd", "-/123", "-999/121", 0, 1 }, + { "%Qd", "+/123", "-999/121", 0, 1 }, + { "%Qd", "123/", "-999/121", 0, 1 }, + { "%Qd", "123/-", "-999/121", 0, 1 }, + { "%Qd", "123/+", "-999/121", 0, 1 }, + { "xyz%Qd", "xyz-", "-999/121", 0, 4 }, + { "xyz%Qd", "xyz+", "-999/121", 0, 4 }, + + { "%1Qi", "12/57", "1", 1, 1 }, + { "%2Qi", "12/57", "12", 1, 2 }, + { "%3Qi", "12/57", "-999/121", 0, -1 }, + { "%4Qi", "12/57", "12/5", 1, 4 }, + { "%5Qi", "12/57", "12/57", 1, 5 }, + { "%6Qi", "12/57", "12/57", 1, 5 }, + { "%7Qi", "12/57", "12/57", 1, 5 }, + + { "%1Qi", "012/057", "0", 1, 1 }, + { "%2Qi", "012/057", "01", 1, 2 }, + { "%3Qi", "012/057", "012", 1, 3 }, + { "%4Qi", "012/057", "-999/121", 0, -1 }, + { "%5Qi", "012/057", "012/0", 1, 5 }, + { "%6Qi", "012/057", "012/5", 1, 6 }, + { "%7Qi", "012/057", "012/057", 1, 7 }, + { "%8Qi", "012/057", "012/057", 1, 7 }, + { "%9Qi", "012/057", "012/057", 1, 7 }, + + { "%1Qi", "0x12/0x57", "0", 1, 1 }, + { "%2Qi", "0x12/0x57", "-999", 0, 2 }, + { "%3Qi", "0x12/0x57", "0x1", 1, 3 }, + { "%4Qi", "0x12/0x57", "0x12", 1, 4 }, + { "%5Qi", "0x12/0x57", "-999/121", 0, 5 }, + { "%6Qi", "0x12/0x57", "0x12/0", 1, 6 }, + { "%7Qi", "0x12/0x57", "-999/121", 0, 7 }, + { "%8Qi", "0x12/0x57", "0x12/0x5", 1, 8 }, + { "%9Qi", "0x12/0x57", "0x12/0x57", 1, 9 }, + { "%10Qi", "0x12/0x57", "0x12/0x57", 1, 9 }, + { "%11Qi", "0x12/0x57", "0x12/0x57", 1, 9 }, + + { "%Qd", "xyz", "0", 0, 0 }, + }; + + int i, j, ignore, got_ret, want_ret, got_upto, want_upto; + mpq_t got, want; + long got_l, want_ftell; + int error = 0; + fun_t fun; + const char *name; + char fmt[128]; + + mpq_init (got); + mpq_init (want); + + for (i = 0; i < numberof (data); i++) + { + mpq_set_str_or_abort (want, data[i].want, 0); + + ASSERT_ALWAYS (strlen (data[i].fmt) + 2 < sizeof (fmt)); + strcpy (fmt, data[i].fmt); + strcat (fmt, "%n"); + + ignore = (strchr (fmt, '*') != NULL); + + for (j = 0; j <= 3; j++) + { + want_ret = data[i].ret; + + want_ftell = data[i].ftell; + if (want_ftell == -1) + want_ftell = strlen (data[i].input); + want_upto = want_ftell; + + if (want_ret == -1 || (want_ret == 0 && ! ignore)) + { + want_ftell = -1; + want_upto = -555; + } + + switch (j) { + case 0: + name = "gmp_sscanf"; + fun = fun_gmp_sscanf; + break; + case 1: + name = "gmp_fscanf"; + fun = fun_gmp_fscanf; + break; + case 2: + if (strchr (data[i].input, '/') != NULL) + continue; + if (! libc_scanf_convert (fmt)) + continue; + name = "standard sscanf"; + fun = fun_sscanf; + break; + case 3: + if (strchr (data[i].input, '/') != NULL) + continue; + if (! libc_scanf_convert (fmt)) + continue; + name = "standard fscanf"; + fun = fun_fscanf; + break; + default: + ASSERT_ALWAYS (0); + break; + } + + got_upto = -555; + got_ftell = -1; + + switch (j) { + case 0: + case 1: + mpq_set_si (got, -999L, 121L); + if (ignore) + got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); + else + got_ret = (*fun) (data[i].input, fmt, got, &got_upto); + break; + case 2: + case 3: + got_l = -999L; + if (ignore) + got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); + else + got_ret = (*fun) (data[i].input, fmt, &got_l, &got_upto); + mpq_set_si (got, got_l, (got_l == -999L ? 121L : 1L)); + break; + default: + ASSERT_ALWAYS (0); + break; + } + + MPZ_CHECK_FORMAT (mpq_numref (got)); + MPZ_CHECK_FORMAT (mpq_denref (got)); + + if (got_ret != want_ret) + { + printf ("%s wrong return value\n", name); + error = 1; + } + /* use direct mpz compares, since some of the test data is + non-canonical and can trip ASSERTs in mpq_equal */ + if (want_ret == 1 + && ! (mpz_cmp (mpq_numref(want), mpq_numref(got)) == 0 + && mpz_cmp (mpq_denref(want), mpq_denref(got)) == 0)) + { + printf ("%s wrong result\n", name); + error = 1; + } + if (got_upto != want_upto) + { + printf ("%s wrong upto\n", name); + error = 1; + } + if (got_ftell != -1 && want_ftell != -1 && got_ftell != want_ftell) + { + printf ("%s wrong ftell\n", name); + error = 1; + } + if (error) + { + printf (" fmt \"%s\"\n", data[i].fmt); + printf (" input \"%s\"\n", data[i].input); + printf (" ret want=%d\n", want_ret); + printf (" got =%d\n", got_ret); + mpq_trace (" value want", want); + mpq_trace (" got ", got); + printf (" upto want=%d\n", want_upto); + printf (" got =%d\n", got_upto); + if (got_ftell != -1) + { + printf (" ftell want =%ld\n", want_ftell); + printf (" got =%ld\n", got_ftell); + } + abort (); + } + } + } + + mpq_clear (got); + mpq_clear (want); +} + +void +check_f (void) +{ + static const struct { + const char *fmt; + const char *input; + const char *want; + int ret; + long ftell; /* or -1 for length of input string */ + + } data[] = { + + { "%Ff", "0", "0", 1, -1 }, + { "%Fe", "0", "0", 1, -1 }, + { "%FE", "0", "0", 1, -1 }, + { "%Fg", "0", "0", 1, -1 }, + { "%FG", "0", "0", 1, -1 }, + + { "%Ff", "123", "123", 1, -1 }, + { "%Ff", "+123", "123", 1, -1 }, + { "%Ff", "-123", "-123", 1, -1 }, + { "%Ff", "123.", "123", 1, -1 }, + { "%Ff", "+123.", "123", 1, -1 }, + { "%Ff", "-123.", "-123", 1, -1 }, + { "%Ff", "123.0", "123", 1, -1 }, + { "%Ff", "+123.0", "123", 1, -1 }, + { "%Ff", "-123.0", "-123", 1, -1 }, + { "%Ff", "0123", "123", 1, -1 }, + { "%Ff", "-0123", "-123", 1, -1 }, + + { "%Ff", "123.456e3", "123456", 1, -1 }, + { "%Ff", "-123.456e3", "-123456", 1, -1 }, + { "%Ff", "123.456e+3", "123456", 1, -1 }, + { "%Ff", "-123.456e+3", "-123456", 1, -1 }, + { "%Ff", "123000e-3", "123", 1, -1 }, + { "%Ff", "-123000e-3", "-123", 1, -1 }, + { "%Ff", "123000.e-3", "123", 1, -1 }, + { "%Ff", "-123000.e-3", "-123", 1, -1 }, + + { "%Ff", "123.456E3", "123456", 1, -1 }, + { "%Ff", "-123.456E3", "-123456", 1, -1 }, + { "%Ff", "123.456E+3", "123456", 1, -1 }, + { "%Ff", "-123.456E+3", "-123456", 1, -1 }, + { "%Ff", "123000E-3", "123", 1, -1 }, + { "%Ff", "-123000E-3", "-123", 1, -1 }, + { "%Ff", "123000.E-3", "123", 1, -1 }, + { "%Ff", "-123000.E-3", "-123", 1, -1 }, + + { "%Ff", ".456e3", "456", 1, -1 }, + { "%Ff", "-.456e3", "-456", 1, -1 }, + { "%Ff", ".456e+3", "456", 1, -1 }, + { "%Ff", "-.456e+3", "-456", 1, -1 }, + + { "%Ff", " 0", "0", 1, -1 }, + { "%Ff", " 0", "0", 1, -1 }, + { "%Ff", " 0", "0", 1, -1 }, + { "%Ff", "\t0", "0", 1, -1 }, + { "%Ff", "\t\t0", "0", 1, -1 }, + + { "hello%Fg", "hello0", "0", 1, -1 }, + { "hello%Fg", "hello 0", "0", 1, -1 }, + { "hello%Fg", "hello \t0", "0", 1, -1 }, + { "hello%Fgworld", "hello 0world", "0", 1, -1 }, + { "hello%Fg", "hello3.0", "3.0", 1, -1 }, + + { "hello%*Fg", "hello0", "-999", 0, -1 }, + { "hello%*Fg", "hello 0", "-999", 0, -1 }, + { "hello%*Fg", "hello \t0", "-999", 0, -1 }, + { "hello%*Fgworld", "hello 0world", "-999", 0, -1 }, + { "hello%*Fgworld", "hello3.0world", "-999", 0, -1 }, + + { "%Ff", "", "-999", -1, -1 }, + { "%Ff", " ", "-999", -1, -1 }, + { "%Ff", "\t", "-999", -1, -1 }, + { "%Ff", " \t", "-999", -1, -1 }, + { " %Ff", "", "-999", -1, -1 }, + { "xyz%Ff", "", "-999", -1, -1 }, + + { "%*Ff", "", "-999", -1, -1 }, + { " %*Ff", "", "-999", -1, -1 }, + { "xyz%*Ff", "", "-999", -1, -1 }, + + { "%Ff", "xyz", "0", 0 }, + + /* various non-empty but invalid */ + { "%Ff", "-", "-999", 0, 1 }, + { "%Ff", "+", "-999", 0, 1 }, + { "xyz%Ff", "xyz-", "-999", 0, 4 }, + { "xyz%Ff", "xyz+", "-999", 0, 4 }, + { "%Ff", "-.", "-999", 0, 2 }, + { "%Ff", "+.", "-999", 0, 2 }, + { "%Ff", ".e", "-999", 0, 1 }, + { "%Ff", "-.e", "-999", 0, 2 }, + { "%Ff", "+.e", "-999", 0, 2 }, + { "%Ff", ".E", "-999", 0, 1 }, + { "%Ff", "-.E", "-999", 0, 2 }, + { "%Ff", "+.E", "-999", 0, 2 }, + { "%Ff", ".e123", "-999", 0, 1 }, + { "%Ff", "-.e123", "-999", 0, 2 }, + { "%Ff", "+.e123", "-999", 0, 2 }, + { "%Ff", "123e", "-999", 0, 4 }, + { "%Ff", "-123e", "-999", 0, 5 }, + { "%Ff", "123e-", "-999", 0, 5 }, + { "%Ff", "-123e-", "-999", 0, 6 }, + { "%Ff", "123e+", "-999", 0, 5 }, + { "%Ff", "-123e+", "-999", 0, 6 }, + { "%Ff", "123e-Z", "-999", 0, 5 }, + + /* hex floats */ + { "%Ff", "0x123p0", "291", 1, -1 }, + { "%Ff", "0x123P0", "291", 1, -1 }, + { "%Ff", "0X123p0", "291", 1, -1 }, + { "%Ff", "0X123P0", "291", 1, -1 }, + { "%Ff", "-0x123p0", "-291", 1, -1 }, + { "%Ff", "+0x123p0", "291", 1, -1 }, + { "%Ff", "0x123.p0", "291", 1, -1 }, + { "%Ff", "0x12.3p4", "291", 1, -1 }, + { "%Ff", "-0x12.3p4", "-291", 1, -1 }, + { "%Ff", "+0x12.3p4", "291", 1, -1 }, + { "%Ff", "0x1230p-4", "291", 1, -1 }, + { "%Ff", "-0x1230p-4", "-291", 1, -1 }, + { "%Ff", "+0x1230p-4", "291", 1, -1 }, + { "%Ff", "+0x.1230p12", "291", 1, -1 }, + { "%Ff", "+0x123000p-12", "291", 1, -1 }, + { "%Ff", "0x123 p12", "291", 1, 5 }, + { "%Ff", "0x9 9", "9", 1, 3 }, + { "%Ff", "0x01", "1", 1, 4 }, + { "%Ff", "0x23", "35", 1, 4 }, + { "%Ff", "0x45", "69", 1, 4 }, + { "%Ff", "0x67", "103", 1, 4 }, + { "%Ff", "0x89", "137", 1, 4 }, + { "%Ff", "0xAB", "171", 1, 4 }, + { "%Ff", "0xCD", "205", 1, 4 }, + { "%Ff", "0xEF", "239", 1, 4 }, + { "%Ff", "0xab", "171", 1, 4 }, + { "%Ff", "0xcd", "205", 1, 4 }, + { "%Ff", "0xef", "239", 1, 4 }, + { "%Ff", "0x100p0A", "256", 1, 7 }, + { "%Ff", "0x1p9", "512", 1, -1 }, + + /* invalid hex floats */ + { "%Ff", "0x", "-999", 0, 2 }, + { "%Ff", "-0x", "-999", 0, 3 }, + { "%Ff", "+0x", "-999", 0, 3 }, + { "%Ff", "0x-", "-999", 0, 2 }, + { "%Ff", "0x+", "-999", 0, 2 }, + { "%Ff", "0x.", "-999", 0, 3 }, + { "%Ff", "-0x.", "-999", 0, 4 }, + { "%Ff", "+0x.", "-999", 0, 4 }, + { "%Ff", "0x.p", "-999", 0, 3 }, + { "%Ff", "-0x.p", "-999", 0, 4 }, + { "%Ff", "+0x.p", "-999", 0, 4 }, + { "%Ff", "0x.P", "-999", 0, 3 }, + { "%Ff", "-0x.P", "-999", 0, 4 }, + { "%Ff", "+0x.P", "-999", 0, 4 }, + { "%Ff", ".p123", "-999", 0, 1 }, + { "%Ff", "-.p123", "-999", 0, 2 }, + { "%Ff", "+.p123", "-999", 0, 2 }, + { "%Ff", "0x1p", "-999", 0, 4 }, + { "%Ff", "0x1p-", "-999", 0, 5 }, + { "%Ff", "0x1p+", "-999", 0, 5 }, + { "%Ff", "0x123p 12", "291", 0, 6 }, + { "%Ff", "0x 123p12", "291", 0, 2 }, + + }; + + int i, j, ignore, got_ret, want_ret, got_upto, want_upto; + mpf_t got, want; + double got_d; + long want_ftell; + int error = 0; + fun_t fun; + const char *name; + char fmt[128]; + + mpf_init (got); + mpf_init (want); + + for (i = 0; i < numberof (data); i++) + { + mpf_set_str_or_abort (want, data[i].want, 10); + + ASSERT_ALWAYS (strlen (data[i].fmt) + 2 < sizeof (fmt)); + strcpy (fmt, data[i].fmt); + strcat (fmt, "%n"); + + ignore = (strchr (fmt, '*') != NULL); + + for (j = 0; j <= 3; j++) + { + want_ret = data[i].ret; + + want_ftell = data[i].ftell; + if (want_ftell == -1) + want_ftell = strlen (data[i].input); + want_upto = want_ftell; + + if (want_ret == -1 || (want_ret == 0 && ! ignore)) + want_upto = -555; + + switch (j) { + case 0: + name = "gmp_sscanf"; + fun = fun_gmp_sscanf; + break; + case 1: + name = "gmp_fscanf"; + fun = fun_gmp_fscanf; + break; + case 2: + if (! libc_scanf_convert (fmt)) + continue; + name = "standard sscanf"; + fun = fun_sscanf; + break; + case 3: + if (! libc_scanf_convert (fmt)) + continue; + name = "standard fscanf"; + fun = fun_fscanf; + break; + default: + ASSERT_ALWAYS (0); + break; + } + + got_upto = -555; + got_ftell = -1; + + switch (j) { + case 0: + case 1: + mpf_set_si (got, -999L); + if (ignore) + got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); + else + got_ret = (*fun) (data[i].input, fmt, got, &got_upto); + break; + case 2: + case 3: + got_d = -999L; + if (ignore) + got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL); + else + got_ret = (*fun) (data[i].input, fmt, &got_d, &got_upto); + mpf_set_d (got, got_d); + break; + default: + ASSERT_ALWAYS (0); + break; + } + + MPF_CHECK_FORMAT (got); + + if (got_ret != want_ret) + { + printf ("%s wrong return value\n", name); + error = 1; + } + if (want_ret == 1 && mpf_cmp (want, got) != 0) + { + printf ("%s wrong result\n", name); + error = 1; + } + if (got_upto != want_upto) + { + printf ("%s wrong upto\n", name); + error = 1; + } + if (got_ftell != -1 && want_ftell != -1 && got_ftell != want_ftell) + { + printf ("%s wrong ftell\n", name); + error = 1; + } + if (error) + { + printf (" fmt \"%s\"\n", data[i].fmt); + printf (" input \"%s\"\n", data[i].input); + printf (" ret want=%d\n", want_ret); + printf (" got =%d\n", got_ret); + mpf_trace (" value want", want); + mpf_trace (" got ", got); + printf (" upto want=%d\n", want_upto); + printf (" got =%d\n", got_upto); + if (got_ftell != -1) + { + printf (" ftell want =%ld\n", want_ftell); + printf (" got =%ld\n", got_ftell); + } + abort (); + } + } + } + + mpf_clear (got); + mpf_clear (want); +} + + +void +check_n (void) +{ + int ret; + + /* %n suppressed */ + { + int n = 123; + gmp_sscanf (" ", " %*n", &n); + ASSERT_ALWAYS (n == 123); + } + { + int n = 123; + fromstring_gmp_fscanf (" ", " %*n", &n); + ASSERT_ALWAYS (n == 123); + } + + +#define CHECK_N(type, string) \ + do { \ + type x[2]; \ + char fmt[128]; \ + int ret; \ + \ + x[0] = ~ (type) 0; \ + x[1] = ~ (type) 0; \ + sprintf (fmt, "abc%%%sn", string); \ + ret = gmp_sscanf ("abc", fmt, &x[0]); \ + \ + ASSERT_ALWAYS (ret == 0); \ + \ + /* should write whole of x[0] and none of x[1] */ \ + ASSERT_ALWAYS (x[0] == 3); \ + ASSERT_ALWAYS (x[1] == (type) ~ (type) 0); \ + \ + } while (0) + + CHECK_N (char, "hh"); + CHECK_N (long, "l"); +#if HAVE_LONG_LONG + CHECK_N (long long, "L"); +#endif +#if HAVE_INTMAX_T + CHECK_N (intmax_t, "j"); +#endif +#if HAVE_PTRDIFF_T + CHECK_N (ptrdiff_t, "t"); +#endif + CHECK_N (short, "h"); + CHECK_N (size_t, "z"); + + /* %Zn */ + { + mpz_t x[2]; + mpz_init_set_si (x[0], -987L); + mpz_init_set_si (x[1], 654L); + ret = gmp_sscanf ("xyz ", "xyz%Zn", x[0]); + MPZ_CHECK_FORMAT (x[0]); + MPZ_CHECK_FORMAT (x[1]); + ASSERT_ALWAYS (ret == 0); + ASSERT_ALWAYS (mpz_cmp_ui (x[0], 3L) == 0); + ASSERT_ALWAYS (mpz_cmp_ui (x[1], 654L) == 0); + mpz_clear (x[0]); + mpz_clear (x[1]); + } + { + mpz_t x; + mpz_init (x); + ret = fromstring_gmp_fscanf ("xyz ", "xyz%Zn", x); + ASSERT_ALWAYS (ret == 0); + ASSERT_ALWAYS (mpz_cmp_ui (x, 3L) == 0); + mpz_clear (x); + } + + /* %Qn */ + { + mpq_t x[2]; + mpq_init (x[0]); + mpq_init (x[1]); + mpq_set_ui (x[0], 987L, 654L); + mpq_set_ui (x[1], 4115L, 226L); + ret = gmp_sscanf ("xyz ", "xyz%Qn", x[0]); + MPQ_CHECK_FORMAT (x[0]); + MPQ_CHECK_FORMAT (x[1]); + ASSERT_ALWAYS (ret == 0); + ASSERT_ALWAYS (mpq_cmp_ui (x[0], 3L, 1L) == 0); + ASSERT_ALWAYS (mpq_cmp_ui (x[1], 4115L, 226L) == 0); + mpq_clear (x[0]); + mpq_clear (x[1]); + } + { + mpq_t x; + mpq_init (x); + ret = fromstring_gmp_fscanf ("xyz ", "xyz%Qn", x); + ASSERT_ALWAYS (ret == 0); + ASSERT_ALWAYS (mpq_cmp_ui (x, 3L, 1L) == 0); + mpq_clear (x); + } + + /* %Fn */ + { + mpf_t x[2]; + mpf_init (x[0]); + mpf_init (x[1]); + mpf_set_ui (x[0], 987L); + mpf_set_ui (x[1], 654L); + ret = gmp_sscanf ("xyz ", "xyz%Fn", x[0]); + MPF_CHECK_FORMAT (x[0]); + MPF_CHECK_FORMAT (x[1]); + ASSERT_ALWAYS (ret == 0); + ASSERT_ALWAYS (mpf_cmp_ui (x[0], 3L) == 0); + ASSERT_ALWAYS (mpf_cmp_ui (x[1], 654L) == 0); + mpf_clear (x[0]); + mpf_clear (x[1]); + } + { + mpf_t x; + mpf_init (x); + ret = fromstring_gmp_fscanf ("xyz ", "xyz%Fn", x); + ASSERT_ALWAYS (ret == 0); + ASSERT_ALWAYS (mpf_cmp_ui (x, 3L) == 0); + mpf_clear (x); + } +} + + +void +check_misc (void) +{ + int ret, cmp; + { + int a=9, b=8, c=7, n=66; + mpz_t z; + mpz_init (z); + ret = gmp_sscanf ("1 2 3 4", "%d %d %d %Zd%n", + &a, &b, &c, z, &n); + ASSERT_ALWAYS (ret == 4); + ASSERT_ALWAYS (a == 1); + ASSERT_ALWAYS (b == 2); + ASSERT_ALWAYS (c == 3); + ASSERT_ALWAYS (n == 7); + ASSERT_ALWAYS (mpz_cmp_ui (z, 4L) == 0); + mpz_clear (z); + } + { + int a=9, b=8, c=7, n=66; + mpz_t z; + mpz_init (z); + ret = fromstring_gmp_fscanf ("1 2 3 4", "%d %d %d %Zd%n", + &a, &b, &c, z, &n); + ASSERT_ALWAYS (ret == 4); + ASSERT_ALWAYS (a == 1); + ASSERT_ALWAYS (b == 2); + ASSERT_ALWAYS (c == 3); + ASSERT_ALWAYS (mpz_cmp_ui (z, 4L) == 0); + ASSERT_ALWAYS (n == 7); + ASSERT_ALWAYS (got_ftell == 7); + mpz_clear (z); + } + + { + int a=9, n=8; + mpz_t z; + mpz_init (z); + ret = gmp_sscanf ("1 2 3 4", "%d %*d %*d %Zd%n", &a, z, &n); + ASSERT_ALWAYS (ret == 2); + ASSERT_ALWAYS (a == 1); + ASSERT_ALWAYS (mpz_cmp_ui (z, 4L) == 0); + ASSERT_ALWAYS (n == 7); + mpz_clear (z); + } + { + int a=9, n=8; + mpz_t z; + mpz_init (z); + ret = fromstring_gmp_fscanf ("1 2 3 4", "%d %*d %*d %Zd%n", + &a, z, &n); + ASSERT_ALWAYS (ret == 2); + ASSERT_ALWAYS (a == 1); + ASSERT_ALWAYS (mpz_cmp_ui (z, 4L) == 0); + ASSERT_ALWAYS (n == 7); + ASSERT_ALWAYS (got_ftell == 7); + mpz_clear (z); + } + + /* EOF for no matching */ + { + char buf[128]; + ret = gmp_sscanf (" ", "%s", buf); + ASSERT_ALWAYS (ret == EOF); + ret = fromstring_gmp_fscanf (" ", "%s", buf); + ASSERT_ALWAYS (ret == EOF); + if (option_libc_scanf) + { + ret = sscanf (" ", "%s", buf); + ASSERT_ALWAYS (ret == EOF); + ret = fun_fscanf (" ", "%s", buf, NULL); + ASSERT_ALWAYS (ret == EOF); + } + } + + /* suppressed field, then eof */ + { + int x; + if (test_sscanf_eof_ok ()) + { + ret = gmp_sscanf ("123", "%*d%d", &x); + ASSERT_ALWAYS (ret == EOF); + } + ret = fromstring_gmp_fscanf ("123", "%*d%d", &x); + ASSERT_ALWAYS (ret == EOF); + if (option_libc_scanf) + { + ret = sscanf ("123", "%*d%d", &x); + ASSERT_ALWAYS (ret == EOF); + ret = fun_fscanf ("123", "%*d%d", &x, NULL); + ASSERT_ALWAYS (ret == EOF); + } + } + { + mpz_t x; + mpz_init (x); + ret = gmp_sscanf ("123", "%*Zd%Zd", x); + ASSERT_ALWAYS (ret == EOF); + ret = fromstring_gmp_fscanf ("123", "%*Zd%Zd", x); + ASSERT_ALWAYS (ret == EOF); + mpz_clear (x); + } + + /* %[...], glibc only */ +#ifdef __GLIBC__ + { + char buf[128]; + int n = -1; + buf[0] = '\0'; + ret = gmp_sscanf ("abcdefgh", "%[a-d]ef%n", buf, &n); + ASSERT_ALWAYS (ret == 1); + cmp = strcmp (buf, "abcd"); + ASSERT_ALWAYS (cmp == 0); + ASSERT_ALWAYS (n == 6); + } + { + char buf[128]; + int n = -1; + buf[0] = '\0'; + ret = gmp_sscanf ("xyza", "%[^a]a%n", buf, &n); + ASSERT_ALWAYS (ret == 1); + cmp = strcmp (buf, "xyz"); + ASSERT_ALWAYS (cmp == 0); + ASSERT_ALWAYS (n == 4); + } + { + char buf[128]; + int n = -1; + buf[0] = '\0'; + ret = gmp_sscanf ("ab]ab]", "%[]ab]%n", buf, &n); + ASSERT_ALWAYS (ret == 1); + cmp = strcmp (buf, "ab]ab]"); + ASSERT_ALWAYS (cmp == 0); + ASSERT_ALWAYS (n == 6); + } + { + char buf[128]; + int n = -1; + buf[0] = '\0'; + ret = gmp_sscanf ("xyzb", "%[^]ab]b%n", buf, &n); + ASSERT_ALWAYS (ret == 1); + cmp = strcmp (buf, "xyz"); + ASSERT_ALWAYS (cmp == 0); + ASSERT_ALWAYS (n == 4); + } +#endif + + /* %zd etc won't be accepted by sscanf on old systems, and running + something to see if they work might be bad, so only try it on glibc, + and only on a new enough version (glibc 2.0 doesn't have %zd) */ +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0) + { + mpz_t z; + size_t s = -1; + mpz_init (z); + ret = gmp_sscanf ("456 789", "%zd %Zd", &s, z); + ASSERT_ALWAYS (ret == 2); + ASSERT_ALWAYS (s == 456); + ASSERT_ALWAYS (mpz_cmp_ui (z, 789L) == 0); + mpz_clear (z); + } + { + mpz_t z; + ptrdiff_t d = -1; + mpz_init (z); + ret = gmp_sscanf ("456 789", "%td %Zd", &d, z); + ASSERT_ALWAYS (ret == 2); + ASSERT_ALWAYS (d == 456); + ASSERT_ALWAYS (mpz_cmp_ui (z, 789L) == 0); + mpz_clear (z); + } + { + mpz_t z; + long long ll = -1; + mpz_init (z); + ret = gmp_sscanf ("456 789", "%Ld %Zd", &ll, z); + ASSERT_ALWAYS (ret == 2); + ASSERT_ALWAYS (ll == 456); + ASSERT_ALWAYS (mpz_cmp_ui (z, 789L) == 0); + mpz_clear (z); + } +#endif +} + +int +main (int argc, char *argv[]) +{ + if (argc > 1 && strcmp (argv[1], "-s") == 0) + option_libc_scanf = 1; + + tests_start (); + + mp_trace_base = 16; + + check_z (); + check_q (); + check_f (); + check_n (); + check_misc (); + + unlink (TEMPFILE); + tests_end (); + exit (0); +} |