mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +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
|
@ -64,7 +64,9 @@ AC_FUNC_MEMCMP
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite)
|
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite)
|
||||||
AC_ZEND_BROKEN_SPRINTF
|
AC_ZEND_BROKEN_SPRINTF
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS(finite isfinite isinf isnan)
|
||||||
|
|
||||||
AC_SUBST(ZEND_SCANNER)
|
AC_SUBST(ZEND_SCANNER)
|
||||||
|
|
||||||
])
|
])
|
||||||
|
@ -95,9 +97,6 @@ AC_ARG_ENABLE(debug,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AC_DEFUN(LIBZEND_OTHER_CHECKS,[
|
AC_DEFUN(LIBZEND_OTHER_CHECKS,[
|
||||||
|
|
||||||
AC_ARG_ENABLE(c9x-inline,
|
AC_ARG_ENABLE(c9x-inline,
|
||||||
|
|
|
@ -35,6 +35,20 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||||
# define zend_sprintf sprintf
|
# define zend_sprintf sprintf
|
||||||
#endif
|
#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:
|
* Local variables:
|
||||||
* tab-width: 4
|
* tab-width: 4
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef unsigned int uint;
|
||||||
# define inline
|
# define inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define finite(A) _finite(A)
|
#define zend_finite(A) _finite(A)
|
||||||
|
|
||||||
#ifdef LIBZEND_EXPORTS
|
#ifdef LIBZEND_EXPORTS
|
||||||
# define ZEND_API __declspec(dllexport)
|
# define ZEND_API __declspec(dllexport)
|
||||||
|
|
|
@ -24,15 +24,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#ifndef HAVE_FINITE
|
#ifdef HAVE_IEEEFP_H
|
||||||
#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
|
|
||||||
#include <ieeefp.h>
|
#include <ieeefp.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if WITH_BCMATH
|
#if WITH_BCMATH
|
||||||
#include "ext/bcmath/number.h"
|
#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;
|
errno=0;
|
||||||
local_dval = strtod(str, &end_ptr);
|
local_dval = strtod(str, &end_ptr);
|
||||||
if (errno!=ERANGE && end_ptr == str+length) { /* floating point string */
|
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 */
|
/* "inf","nan" and maybe other weird ones */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue