ANSI C is now 25 years old. We already use ANSI-C-isms all over the source tree. This sort of paranoia check is now well out of date. --- acinclude.m4 | 55 +++----------------------------------------------- config.in | 3 --- configure.ac | 1 - demos/expr/expr-impl.h | 14 ------------- demos/expr/exprf.c | 17 ++-------------- demos/expr/exprq.c | 17 ++-------------- demos/expr/exprz.c | 17 ++-------------- gmp-impl.h | 6 +----- mpf/clears.c | 12 ----------- mpf/inits.c | 12 ----------- mpq/clears.c | 12 ----------- mpq/inits.c | 12 ----------- mpz/clears.c | 12 ----------- mpz/inits.c | 12 ----------- printf/asprintf.c | 14 ------------- printf/fprintf.c | 14 ------------- printf/obprintf.c | 13 ------------ printf/printf.c | 12 ----------- printf/snprintf.c | 14 ------------- printf/sprintf.c | 14 ------------- rand/rand.c | 18 ++--------------- scanf/fscanf.c | 15 +------------- scanf/scanf.c | 13 +----------- scanf/sscanf.c | 14 +------------ tests/misc/t-printf.c | 33 ++---------------------------- tests/misc/t-scanf.c | 19 +---------------- 26 files changed, 18 insertions(+), 377 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4 index f7b128e..20389a7 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -3434,40 +3434,6 @@ esac ]) -dnl GMP_C_STDARG -dnl ------------ -dnl Test whether to use <stdarg.h> or <varargs.h>. -dnl -dnl Notice the AC_DEFINE here is HAVE_STDARG to avoid clashing with -dnl HAVE_STDARG_H which could arise from AC_CHECK_HEADERS. -dnl -dnl This test might be slight overkill, after all there's really only going -dnl to be ANSI or K&R and the two can be differentiated by AC_PROG_CC_STDC -dnl or very likely by the setups for _PROTO in gmp.h. On the other hand -dnl this test is nice and direct, being what we're going to actually use. - -AC_DEFUN([GMP_C_STDARG], -[AC_CACHE_CHECK([whether <stdarg.h> exists and works], - gmp_cv_c_stdarg, -[AC_TRY_COMPILE( -[#include <stdarg.h> -int foo (int x, ...) -{ - va_list ap; - int y; - va_start (ap, x); - y = va_arg (ap, int); - va_end (ap); - return y; -}],, -gmp_cv_c_stdarg=yes, gmp_cv_c_stdarg=no) -]) -if test $gmp_cv_c_stdarg = yes; then - AC_DEFINE(HAVE_STDARG, 1, [Define to 1 if <stdarg.h> exists and works]) -fi -]) - - dnl GMP_FUNC_ALLOCA dnl --------------- dnl Determine whether "alloca" is available. This is AC_FUNC_ALLOCA from @@ -3619,8 +3585,7 @@ dnl not sure which 2.0.x does which), but still puts the correct null dnl terminated result into the buffer. AC_DEFUN([GMP_FUNC_VSNPRINTF], -[AC_REQUIRE([GMP_C_STDARG]) -AC_CHECK_FUNC(vsnprintf, +[AC_CHECK_FUNC(vsnprintf, [gmp_vsnprintf_exists=yes], [gmp_vsnprintf_exists=no]) if test "$gmp_vsnprintf_exists" = no; then @@ -3633,35 +3598,21 @@ else AC_TRY_RUN([ #include <string.h> /* for strcmp */ #include <stdio.h> /* for vsnprintf */ - -#if HAVE_STDARG #include <stdarg.h> -#else -#include <varargs.h> -#endif int -#if HAVE_STDARG check (const char *fmt, ...) -#else -check (va_alist) - va_dcl -#endif { static char buf[128]; va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); -#else - char *fmt; - va_start (ap); - fmt = va_arg (ap, char *); -#endif ret = vsnprintf (buf, 4, fmt, ap); + va_end (ap); + if (strcmp (buf, "hel") != 0) return 1; diff --git a/config.in b/config.in index 60ea30d..14b6fa4 100644 --- a/config.in +++ b/config.in @@ -391,9 +391,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. /* Define to 1 if the system has the type `stack_t'. */ #undef HAVE_STACK_T -/* Define to 1 if <stdarg.h> exists and works */ -#undef HAVE_STDARG - /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H diff --git a/configure.ac b/configure.ac index 9a805cb..77e656c 100644 --- a/configure.ac +++ b/configure.ac @@ -2575,7 +2575,6 @@ AC_C_VOLATILE AC_C_RESTRICT -GMP_C_STDARG GMP_C_ATTRIBUTE_CONST GMP_C_ATTRIBUTE_MALLOC GMP_C_ATTRIBUTE_MODE diff --git a/demos/expr/expr-impl.h b/demos/expr/expr-impl.h index 84c5bce..a4e0b08 100644 --- a/demos/expr/expr-impl.h +++ b/demos/expr/expr-impl.h @@ -18,21 +18,7 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ -/* Same tests as gmp.h. */ -#if defined (__STDC__) \ - || defined (__cplusplus) \ - || defined (_AIX) \ - || defined (__DECC) \ - || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ - || defined (_MSC_VER) \ - || defined (_WIN32) -#define HAVE_STDARG 1 #include <stdarg.h> -#else -#define HAVE_STDARG 0 -#include <varargs.h> -#endif - #include "expr.h" diff --git a/demos/expr/exprf.c b/demos/expr/exprf.c index 98ce834..c65d174 100644 --- a/demos/expr/exprf.c +++ b/demos/expr/exprf.c @@ -93,30 +93,17 @@ const struct mpexpr_operator_t * const mpf_expr_standard_table int -#if HAVE_STDARG mpf_expr (mpf_ptr res, int base, const char *e, ...) -#else -mpf_expr (va_alist) - va_dcl -#endif { mpf_srcptr var[MPEXPR_VARIABLES]; va_list ap; int ret; -#if HAVE_STDARG + va_start (ap, e); -#else - mpf_ptr res; - int base; - const char *e; - va_start (ap); - res = va_arg (ap, mpf_ptr); - base = va_arg (ap, int); - e = va_arg (ap, const char *); -#endif TRACE (printf ("mpf_expr(): base %d, %s\n", base, e)); ret = mpexpr_va_to_var ((void **) var, ap); + va_end (ap); if (ret != MPEXPR_RESULT_OK) diff --git a/demos/expr/exprq.c b/demos/expr/exprq.c index a16b216..f37a26b 100644 --- a/demos/expr/exprq.c +++ b/demos/expr/exprq.c @@ -126,30 +126,17 @@ const struct mpexpr_operator_t * const mpq_expr_standard_table int -#if HAVE_STDARG mpq_expr (mpq_ptr res, int base, const char *e, ...) -#else -mpq_expr (va_alist) - va_dcl -#endif { mpq_srcptr var[MPEXPR_VARIABLES]; va_list ap; int ret; -#if HAVE_STDARG + va_start (ap, e); -#else - mpq_ptr res; - int base; - const char *e; - va_start (ap); - res = va_arg (ap, mpq_ptr); - base = va_arg (ap, int); - e = va_arg (ap, const char *); -#endif TRACE (printf ("mpq_expr(): base %d, %s\n", base, e)); ret = mpexpr_va_to_var ((void **) var, ap); + va_end (ap); if (ret != MPEXPR_RESULT_OK) diff --git a/demos/expr/exprz.c b/demos/expr/exprz.c index 3d4ec65..ac36777 100644 --- a/demos/expr/exprz.c +++ b/demos/expr/exprz.c @@ -177,30 +177,17 @@ const struct mpexpr_operator_t * const mpz_expr_standard_table int -#if HAVE_STDARG mpz_expr (mpz_ptr res, int base, const char *e, ...) -#else -mpz_expr (va_alist) - va_dcl -#endif { mpz_srcptr var[MPEXPR_VARIABLES]; va_list ap; int ret; -#if HAVE_STDARG + va_start (ap, e); -#else - mpz_ptr res; - int base; - const char *e; - va_start (ap); - res = va_arg (ap, mpz_ptr); - base = va_arg (ap, int); - e = va_arg (ap, const char *); -#endif TRACE (printf ("mpz_expr(): base %d, %s\n", base, e)); ret = mpexpr_va_to_var ((void **) var, ap); + va_end (ap); if (ret != MPEXPR_RESULT_OK) diff --git a/gmp-impl.h b/gmp-impl.h index d1c756f..17440b2 100644 --- a/gmp-impl.h +++ b/gmp-impl.h @@ -71,12 +71,8 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #if HAVE_SYS_TYPES_H # include <sys/types.h> /* for quad_t */ #endif -#if HAVE_STDARG -# include <stdarg.h> /* for va_list and hence doprnt_funs_t */ -#else -# include <varargs.h> -#endif +#include <stdarg.h> #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/mpf/clears.c b/mpf/clears.c index deea432..eeea8d2 100644 --- a/mpf/clears.c +++ b/mpf/clears.c @@ -20,23 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG mpf_clears (mpf_ptr x, ...) -#else -mpf_clears (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG va_start (ap, x); -#else - mpf_ptr x; - va_start (ap); - x = va_arg (ap, mpf_ptr); -#endif - while (x != NULL) { mpf_clear (x); diff --git a/mpf/inits.c b/mpf/inits.c index 97b94be..350ac27 100644 --- a/mpf/inits.c +++ b/mpf/inits.c @@ -20,23 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG mpf_inits (mpf_ptr x, ...) -#else -mpf_inits (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG va_start (ap, x); -#else - mpf_ptr x; - va_start (ap); - x = va_arg (ap, mpf_ptr); -#endif - while (x != NULL) { mpf_init (x); diff --git a/mpq/clears.c b/mpq/clears.c index f4eee46..1a3c77f 100644 --- a/mpq/clears.c +++ b/mpq/clears.c @@ -20,23 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG mpq_clears (mpq_ptr x, ...) -#else -mpq_clears (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG va_start (ap, x); -#else - mpq_ptr x; - va_start (ap); - x = va_arg (ap, mpq_ptr); -#endif - while (x != NULL) { mpq_clear (x); diff --git a/mpq/inits.c b/mpq/inits.c index a9bf0f4..2c9da08 100644 --- a/mpq/inits.c +++ b/mpq/inits.c @@ -20,23 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG mpq_inits (mpq_ptr x, ...) -#else -mpq_inits (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG va_start (ap, x); -#else - mpq_ptr x; - va_start (ap); - x = va_arg (ap, mpq_ptr); -#endif - while (x != NULL) { mpq_init (x); diff --git a/mpz/clears.c b/mpz/clears.c index 470eef2..49a230c 100644 --- a/mpz/clears.c +++ b/mpz/clears.c @@ -20,23 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG mpz_clears (mpz_ptr x, ...) -#else -mpz_clears (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG va_start (ap, x); -#else - mpz_ptr x; - va_start (ap); - x = va_arg (ap, mpz_ptr); -#endif - while (x != NULL) { mpz_clear (x); diff --git a/mpz/inits.c b/mpz/inits.c index 50ff1e9..73dc369 100644 --- a/mpz/inits.c +++ b/mpz/inits.c @@ -20,23 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG mpz_inits (mpz_ptr x, ...) -#else -mpz_inits (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG va_start (ap, x); -#else - mpz_ptr x; - va_start (ap); - x = va_arg (ap, mpz_ptr); -#endif - while (x != NULL) { mpz_init (x); diff --git a/printf/asprintf.c b/printf/asprintf.c index 1f99d64..642f977 100644 --- a/printf/asprintf.c +++ b/printf/asprintf.c @@ -21,26 +21,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_asprintf (char **result, const char *fmt, ...) -#else -gmp_asprintf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); -#else - char **result; - const char *fmt; - va_start (ap); - result = va_arg (ap, char **); - fmt = va_arg (ap, const char *); -#endif - ret = gmp_vasprintf (result, fmt, ap); va_end (ap); return ret; diff --git a/printf/fprintf.c b/printf/fprintf.c index 1148b34..f9d4618 100644 --- a/printf/fprintf.c +++ b/printf/fprintf.c @@ -21,26 +21,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_fprintf (FILE *fp, const char *fmt, ...) -#else -gmp_fprintf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); -#else - FILE *fp; - const char *fmt; - va_start (ap); - fp = va_arg (ap, FILE *); - fmt = va_arg (ap, const char *); -#endif - ret = __gmp_doprnt (&__gmp_fprintf_funs, fp, fmt, ap); va_end (ap); return ret; diff --git a/printf/obprintf.c b/printf/obprintf.c index cb58bf7..ff46d9a 100644 --- a/printf/obprintf.c +++ b/printf/obprintf.c @@ -22,25 +22,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #if HAVE_OBSTACK_VPRINTF int -#if HAVE_STDARG gmp_obstack_printf (struct obstack *ob, const char *fmt, ...) -#else -gmp_obstack_printf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); -#else - struct obstack *ob; - const char *fmt; - va_start (ap); - ob = va_arg (ap, struct obstack *); - fmt = va_arg (ap, const char *); -#endif ASSERT (! MEM_OVERLAP_P (obstack_base(ob), obstack_object_size(ob), fmt, strlen(fmt)+1)); diff --git a/printf/printf.c b/printf/printf.c index 66e6c35..09240d5 100644 --- a/printf/printf.c +++ b/printf/printf.c @@ -21,24 +21,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_printf (const char *fmt, ...) -#else -gmp_printf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); -#else - const char *fmt; - va_start (ap); - fmt = va_arg (ap, const char *); -#endif - ret = __gmp_doprnt (&__gmp_fprintf_funs, stdout, fmt, ap); va_end (ap); return ret; diff --git a/printf/snprintf.c b/printf/snprintf.c index 4e10afd..aced10c 100644 --- a/printf/snprintf.c +++ b/printf/snprintf.c @@ -21,30 +21,16 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_snprintf (char *buf, size_t size, const char *fmt, ...) -#else -gmp_snprintf (va_alist) - va_dcl -#endif { struct gmp_snprintf_t d; va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); d.buf = buf; d.size = size; -#else - const char *fmt; - va_start (ap); - d.buf = va_arg (ap, char *); - d.size = va_arg (ap, size_t); - fmt = va_arg (ap, const char *); -#endif - ASSERT (! MEM_OVERLAP_P (buf, size, fmt, strlen(fmt)+1)); ret = __gmp_doprnt (&__gmp_snprintf_funs, &d, fmt, ap); diff --git a/printf/sprintf.c b/printf/sprintf.c index 9ad19c0..776f7d7 100644 --- a/printf/sprintf.c +++ b/printf/sprintf.c @@ -21,12 +21,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_sprintf (char *buf, const char *fmt, ...) -#else -gmp_sprintf (va_alist) - va_dcl -#endif { #if WANT_ASSERT int fmtlen = strlen(fmt); @@ -34,16 +29,7 @@ gmp_sprintf (va_alist) va_list ap; int ret; -#if HAVE_STDARG va_start (ap, fmt); -#else - char *buf; - const char *fmt; - va_start (ap); - buf = va_arg (ap, char *); - fmt = va_arg (ap, const char *); -#endif - ret = __gmp_doprnt (&__gmp_sprintf_funs, &buf, fmt, ap); va_end (ap); diff --git a/rand/rand.c b/rand/rand.c index 368c832..d9aa47e 100644 --- a/rand/rand.c +++ b/rand/rand.c @@ -20,25 +20,11 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #include "gmp-impl.h" void -#if HAVE_STDARG -gmp_randinit (gmp_randstate_t rstate, - gmp_randalg_t alg, - ...) -#else -gmp_randinit (va_alist) - va_dcl -#endif +gmp_randinit (gmp_randstate_t rstate, gmp_randalg_t alg, ...) { va_list ap; -#if HAVE_STDARG + va_start (ap, alg); -#else - __gmp_randstate_struct *rstate; - gmp_randalg_t alg; - va_start (ap); - rstate = va_arg (ap, __gmp_randstate_struct *); - alg = va_arg (ap, gmp_randalg_t); -#endif switch (alg) { case GMP_RAND_ALG_LC: diff --git a/scanf/fscanf.c b/scanf/fscanf.c index 459f360..a4d5127 100644 --- a/scanf/fscanf.c +++ b/scanf/fscanf.c @@ -21,25 +21,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_fscanf (FILE *fp, const char *fmt, ...) -#else -gmp_fscanf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG - va_start (ap, fmt); -#else - FILE *fp; - const char *fmt; - va_start (ap); - fp = va_arg (ap, FILE *); - fmt = va_arg (ap, const char *); -#endif + va_start (ap, fmt); ret = __gmp_doscan (&__gmp_fscanf_funs, fp, fmt, ap); va_end (ap); return ret; diff --git a/scanf/scanf.c b/scanf/scanf.c index e925497..9458cd6 100644 --- a/scanf/scanf.c +++ b/scanf/scanf.c @@ -21,23 +21,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_scanf (const char *fmt, ...) -#else -gmp_scanf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG - va_start (ap, fmt); -#else - const char *fmt; - va_start (ap); - fmt = va_arg (ap, const char *); -#endif + va_start (ap, fmt); ret = __gmp_doscan (&__gmp_fscanf_funs, stdin, fmt, ap); va_end (ap); return ret; diff --git a/scanf/sscanf.c b/scanf/sscanf.c index 61cdafd..20cbdb6 100644 --- a/scanf/sscanf.c +++ b/scanf/sscanf.c @@ -21,24 +21,12 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ int -#if HAVE_STDARG gmp_sscanf (const char *s, const char *fmt, ...) -#else -gmp_sscanf (va_alist) - va_dcl -#endif { va_list ap; int ret; -#if HAVE_STDARG + va_start (ap, fmt); -#else - const char *s; - const char *fmt; - va_start (ap); - s = va_arg (ap, const char *); - fmt = va_arg (ap, const char *); -#endif #if SSCANF_WRITABLE_INPUT /* let gmp_vsscanf handle the copying */ diff --git a/tests/misc/t-printf.c b/tests/misc/t-printf.c index 25b0161..b3a36b8 100644 --- a/tests/misc/t-printf.c +++ b/tests/misc/t-printf.c @@ -27,12 +27,7 @@ the GNU MP Library test suite. If not, see http://www.gnu.org/licenses/. */ #include "config.h" -#if HAVE_STDARG #include <stdarg.h> -#else -#include <varargs.h> -#endif - #include <stddef.h> /* for ptrdiff_t */ #include <stdio.h> #include <stdlib.h> @@ -73,12 +68,7 @@ FILE *check_vfprintf_fp; void -#if HAVE_STDARG check_plain (const char *want, const char *fmt_orig, ...) -#else -check_plain (va_alist) - va_dcl -#endif { char got[MAX_OUTPUT]; int got_len, want_len; @@ -86,15 +76,8 @@ check_plain (va_alist) char *fmt, *q; const char *p; va_list ap; -#if HAVE_STDARG + va_start (ap, fmt_orig); -#else - const char *want; - const char *fmt_orig; - va_start (ap); - want = va_arg (ap, const char *); - fmt_orig = va_arg (ap, const char *); -#endif if (! option_check_printf) return; @@ -318,23 +301,11 @@ check_obstack_vprintf (const char *want, const char *fmt, va_list ap) void -#if HAVE_STDARG check_one (const char *want, const char *fmt, ...) -#else -check_one (va_alist) - va_dcl -#endif { va_list ap; -#if HAVE_STDARG + va_start (ap, fmt); -#else - const char *want; - const char *fmt; - va_start (ap); - want = va_arg (ap, const char *); - fmt = va_arg (ap, const char *); -#endif /* simplest first */ check_vsprintf (want, fmt, ap); diff --git a/tests/misc/t-scanf.c b/tests/misc/t-scanf.c index b8d8338..7c85614 100644 --- a/tests/misc/t-scanf.c +++ b/tests/misc/t-scanf.c @@ -31,12 +31,7 @@ the GNU MP Library test suite. If not, see http://www.gnu.org/licenses/. */ #include "config.h" -#if HAVE_STDARG #include <stdarg.h> -#else -#include <varargs.h> -#endif - #include <stddef.h> /* for ptrdiff_t */ #include <stdio.h> #include <stdlib.h> @@ -129,25 +124,13 @@ int fromstring_next_c; /* Call gmp_fscanf, reading the "input" string data provided. */ int -#if HAVE_STDARG fromstring_gmp_fscanf (const char *input, const char *fmt, ...) -#else -fromstring_gmp_fscanf (va_alist) - va_dcl -#endif { va_list ap; FILE *fp; int ret; -#if HAVE_STDARG + va_start (ap, fmt); -#else - const char *input; - const char *fmt; - va_start (ap); - input = va_arg (ap, const char *); - fmt = va_arg (ap, const char *); -#endif fp = fopen (TEMPFILE, "w+"); ASSERT_ALWAYS (fp != NULL); -- 1.8.1.2 _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org http://gmplib.org/mailman/listinfo/gmp-devel