mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Welcome zend_finite(n).
This chooses the best combination of what is available: finite, isfinite, isinf, isnan
This commit is contained in:
parent
6e815b76ea
commit
0404a02430
4 changed files with 20 additions and 13 deletions
|
@ -65,6 +65,8 @@ 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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -24,15 +24,9 @@
|
|||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#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 <ieeefp.h>
|
||||
#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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue