From 0404a0243012a7fdf201cdf83a37e43c9455e9b6 Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Sun, 18 Jun 2000 16:33:15 +0000 Subject: [PATCH] Welcome zend_finite(n). This chooses the best combination of what is available: finite, isfinite, isinf, isnan --- Zend/Zend.m4 | 7 +++---- Zend/acconfig.h | 14 ++++++++++++++ Zend/zend_config.w32.h | 2 +- Zend/zend_operators.h | 10 ++-------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index ef236bbed09..79d2c69138d 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -64,7 +64,9 @@ AC_FUNC_MEMCMP AC_FUNC_ALLOCA AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite) AC_ZEND_BROKEN_SPRINTF - + +AC_CHECK_FUNCS(finite isfinite isinf isnan) + AC_SUBST(ZEND_SCANNER) ]) @@ -95,9 +97,6 @@ AC_ARG_ENABLE(debug, - - - AC_DEFUN(LIBZEND_OTHER_CHECKS,[ AC_ARG_ENABLE(c9x-inline, diff --git a/Zend/acconfig.h b/Zend/acconfig.h index 85e52829f14..9b3153daf14 100644 --- a/Zend/acconfig.h +++ b/Zend/acconfig.h @@ -35,6 +35,20 @@ int zend_sprintf(char *buffer, const char *format, ...); # define zend_sprintf sprintf #endif +#ifdef HAVE_FINITE +#define zend_finite(a) finite(a) +#elif defined(HAVE_ISFINITE) +#define zend_finite(a) isfinite(a) +#elif defined(HAVE_ISNAN) && defined(HAVE_ISINF) +#define zend_finite(a) (isnan(a) ? 0 : isinf(a) ? 0 : 1) +#elif defined(HAVE_ISNAN) +#define zend_finite(a) (isnan(a) ? 0 : 1) +#elif defined(HAVE_ISINF) +#define zend_finite(a) (isinf(a) ? 0 : 1) +#else +#define zend_finite(a) (1) +#endif + /* * Local variables: * tab-width: 4 diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h index 8b60474bbf9..d8d0f72613d 100644 --- a/Zend/zend_config.w32.h +++ b/Zend/zend_config.w32.h @@ -63,7 +63,7 @@ typedef unsigned int uint; # define inline #endif -#define finite(A) _finite(A) +#define zend_finite(A) _finite(A) #ifdef LIBZEND_EXPORTS # define ZEND_API __declspec(dllexport) diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 404209660c9..5b95f6f4541 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -24,15 +24,9 @@ #include #include -#ifndef HAVE_FINITE -#ifndef finite /* in case it's already a macro */ -#define finite(a) isfinite(a) /* HPUX 11 only has isfinite() */ -#endif -#else -#if HAVE_IEEEFP_H +#ifdef HAVE_IEEEFP_H #include #endif -#endif #if WITH_BCMATH #include "ext/bcmath/number.h" @@ -87,7 +81,7 @@ ZEND_API inline int is_numeric_string(char *str, int length, long *lval, double errno=0; local_dval = strtod(str, &end_ptr); if (errno!=ERANGE && end_ptr == str+length) { /* floating point string */ - if (! finite(local_dval)) { + if (! zend_finite(local_dval)) { /* "inf","nan" and maybe other weird ones */ return 0; }