Skip to content

Commit 0404a02

Browse files
author
Sascha Schumann
committed
Welcome zend_finite(n).
This chooses the best combination of what is available: finite, isfinite, isinf, isnan
1 parent 6e815b7 commit 0404a02

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

Zend/Zend.m4

+3-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ AC_FUNC_MEMCMP
6464
AC_FUNC_ALLOCA
6565
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite)
6666
AC_ZEND_BROKEN_SPRINTF
67-
67+
68+
AC_CHECK_FUNCS(finite isfinite isinf isnan)
69+
6870
AC_SUBST(ZEND_SCANNER)
6971
7072
])
@@ -95,9 +97,6 @@ AC_ARG_ENABLE(debug,
9597

9698

9799

98-
99-
100-
101100
AC_DEFUN(LIBZEND_OTHER_CHECKS,[
102101
103102
AC_ARG_ENABLE(c9x-inline,

Zend/acconfig.h

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ int zend_sprintf(char *buffer, const char *format, ...);
3535
# define zend_sprintf sprintf
3636
#endif
3737

38+
#ifdef HAVE_FINITE
39+
#define zend_finite(a) finite(a)
40+
#elif defined(HAVE_ISFINITE)
41+
#define zend_finite(a) isfinite(a)
42+
#elif defined(HAVE_ISNAN) && defined(HAVE_ISINF)
43+
#define zend_finite(a) (isnan(a) ? 0 : isinf(a) ? 0 : 1)
44+
#elif defined(HAVE_ISNAN)
45+
#define zend_finite(a) (isnan(a) ? 0 : 1)
46+
#elif defined(HAVE_ISINF)
47+
#define zend_finite(a) (isinf(a) ? 0 : 1)
48+
#else
49+
#define zend_finite(a) (1)
50+
#endif
51+
3852
/*
3953
* Local variables:
4054
* tab-width: 4

Zend/zend_config.w32.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef unsigned int uint;
6363
# define inline
6464
#endif
6565

66-
#define finite(A) _finite(A)
66+
#define zend_finite(A) _finite(A)
6767

6868
#ifdef LIBZEND_EXPORTS
6969
# define ZEND_API __declspec(dllexport)

Zend/zend_operators.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@
2424
#include <errno.h>
2525
#include <math.h>
2626

27-
#ifndef HAVE_FINITE
28-
#ifndef finite /* in case it's already a macro */
29-
#define finite(a) isfinite(a) /* HPUX 11 only has isfinite() */
30-
#endif
31-
#else
32-
#if HAVE_IEEEFP_H
27+
#ifdef HAVE_IEEEFP_H
3328
#include <ieeefp.h>
3429
#endif
35-
#endif
3630

3731
#if WITH_BCMATH
3832
#include "ext/bcmath/number.h"
@@ -87,7 +81,7 @@ ZEND_API inline int is_numeric_string(char *str, int length, long *lval, double
8781
errno=0;
8882
local_dval = strtod(str, &end_ptr);
8983
if (errno!=ERANGE && end_ptr == str+length) { /* floating point string */
90-
if (! finite(local_dval)) {
84+
if (! zend_finite(local_dval)) {
9185
/* "inf","nan" and maybe other weird ones */
9286
return 0;
9387
}

0 commit comments

Comments
 (0)