mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
Fix detection of isnan and isinf
The isnan() and isinf() are C99 macros not functions. Also fix is_infinite(-INF) in case isinf is not defined.
This commit is contained in:
parent
21d7878690
commit
9ea0949f43
6 changed files with 51 additions and 21 deletions
1
NEWS
1
NEWS
|
@ -8,6 +8,7 @@ PHP NEWS
|
||||||
. Fixed bug #73998 (array_key_exists fails on arrays created by
|
. Fixed bug #73998 (array_key_exists fails on arrays created by
|
||||||
get_object_vars). (mhagstrand)
|
get_object_vars). (mhagstrand)
|
||||||
. Fixed bug #73954 (NAN check fails on Alpine Linux with musl). (Andrea)
|
. Fixed bug #73954 (NAN check fails on Alpine Linux with musl). (Andrea)
|
||||||
|
. Fixed bug #74039 (is_infinite(-INF) returns false). (Christian Schmidt)
|
||||||
|
|
||||||
- GD:
|
- GD:
|
||||||
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
|
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
|
||||||
|
|
|
@ -100,7 +100,8 @@ AC_FUNC_ALLOCA
|
||||||
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
|
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
|
||||||
AC_ZEND_BROKEN_SPRINTF
|
AC_ZEND_BROKEN_SPRINTF
|
||||||
|
|
||||||
AC_CHECK_FUNCS(finite isfinite isinf isnan)
|
AC_CHECK_FUNCS(finite)
|
||||||
|
AC_CHECK_DECLS([isfinite, isnan, isinf], [], [], [[#include <math.h>]])
|
||||||
|
|
||||||
ZEND_FP_EXCEPT
|
ZEND_FP_EXCEPT
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,13 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||||
|
|
||||||
/* To enable the is_nan, is_infinite and is_finite PHP functions */
|
/* To enable the is_nan, is_infinite and is_finite PHP functions */
|
||||||
#ifdef NETWARE
|
#ifdef NETWARE
|
||||||
#define HAVE_ISNAN 1
|
#define HAVE_DECL_ISNAN 1
|
||||||
#define HAVE_ISINF 1
|
#define HAVE_DECL_ISINF 1
|
||||||
#define HAVE_ISFINITE 1
|
#define HAVE_DECL_ISINFINITE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef zend_isnan
|
#ifndef zend_isnan
|
||||||
#ifdef HAVE_ISNAN
|
#ifdef HAVE_DECL_ISNAN
|
||||||
#define zend_isnan(a) isnan(a)
|
#define zend_isnan(a) isnan(a)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
||||||
|
@ -79,18 +79,18 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ISINF
|
#ifdef HAVE_DECL_ISINF
|
||||||
#define zend_isinf(a) isinf(a)
|
#define zend_isinf(a) isinf(a)
|
||||||
#elif defined(INFINITY)
|
#elif defined(INFINITY)
|
||||||
/* Might not work, but is required by ISO C99 */
|
/* Might not work, but is required by ISO C99 */
|
||||||
#define zend_isinf(a) (((a)==INFINITY)?1:0)
|
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
||||||
#else
|
#else
|
||||||
#define zend_isinf(a) 0
|
#define zend_isinf(a) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_ISFINITE) || defined(isfinite)
|
#if defined(HAVE_DECL_ISINFINITE) || defined(isfinite)
|
||||||
#define zend_finite(a) isfinite(a)
|
#define zend_finite(a) isfinite(a)
|
||||||
#elif defined(HAVE_FINITE)
|
#elif defined(HAVE_FINITE)
|
||||||
#define zend_finite(a) finite(a)
|
#define zend_finite(a) finite(a)
|
||||||
|
|
14
configure.in
14
configure.in
|
@ -69,13 +69,13 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||||
|
|
||||||
/* To enable the is_nan, is_infinite and is_finite PHP functions */
|
/* To enable the is_nan, is_infinite and is_finite PHP functions */
|
||||||
#ifdef NETWARE
|
#ifdef NETWARE
|
||||||
#define HAVE_ISNAN 1
|
#define HAVE_DECL_ISNAN 1
|
||||||
#define HAVE_ISINF 1
|
#define HAVE_DECL_ISINF 1
|
||||||
#define HAVE_ISFINITE 1
|
#define HAVE_DECL_ISINFINITE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef zend_isnan
|
#ifndef zend_isnan
|
||||||
#ifdef HAVE_ISNAN
|
#ifdef HAVE_DECL_ISNAN
|
||||||
#define zend_isnan(a) isnan(a)
|
#define zend_isnan(a) isnan(a)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
||||||
|
@ -84,18 +84,18 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ISINF
|
#ifdef HAVE_DECL_ISINF
|
||||||
#define zend_isinf(a) isinf(a)
|
#define zend_isinf(a) isinf(a)
|
||||||
#elif defined(INFINITY)
|
#elif defined(INFINITY)
|
||||||
/* Might not work, but is required by ISO C99 */
|
/* Might not work, but is required by ISO C99 */
|
||||||
#define zend_isinf(a) (((a)==INFINITY)?1:0)
|
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
||||||
#else
|
#else
|
||||||
#define zend_isinf(a) 0
|
#define zend_isinf(a) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_ISFINITE) || defined(isfinite)
|
#if defined(HAVE_DECL_ISINFINITE) || defined(isfinite)
|
||||||
#define zend_finite(a) isfinite(a)
|
#define zend_finite(a) isfinite(a)
|
||||||
#elif defined(HAVE_FINITE)
|
#elif defined(HAVE_FINITE)
|
||||||
#define zend_finite(a) finite(a)
|
#define zend_finite(a) finite(a)
|
||||||
|
|
|
@ -420,7 +420,7 @@ AC_TRY_RUN([
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_ISNAN
|
#ifdef HAVE_DECL_ISNAN
|
||||||
#define zend_isnan(a) isnan(a)
|
#define zend_isnan(a) isnan(a)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
||||||
|
@ -451,11 +451,11 @@ AC_TRY_RUN([
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_ISINF
|
#ifdef HAVE_DECL_ISINF
|
||||||
#define zend_isinf(a) isinf(a)
|
#define zend_isinf(a) isinf(a)
|
||||||
#elif defined(INFINITY)
|
#elif defined(INFINITY)
|
||||||
/* Might not work, but is required by ISO C99 */
|
/* Might not work, but is required by ISO C99 */
|
||||||
#define zend_isinf(a) (((a)==INFINITY)?1:0)
|
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
||||||
#else
|
#else
|
||||||
|
@ -485,11 +485,11 @@ AC_TRY_RUN([
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_ISINF
|
#ifdef HAVE_DECL_ISINF
|
||||||
#define zend_isinf(a) isinf(a)
|
#define zend_isinf(a) isinf(a)
|
||||||
#elif defined(INFINITY)
|
#elif defined(INFINITY)
|
||||||
/* Might not work, but is required by ISO C99 */
|
/* Might not work, but is required by ISO C99 */
|
||||||
#define zend_isinf(a) (((a)==INFINITY)?1:0)
|
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
||||||
#else
|
#else
|
||||||
|
@ -520,7 +520,7 @@ AC_TRY_RUN([
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_ISNAN
|
#ifdef HAVE_DECL_ISNAN
|
||||||
#define zend_isnan(a) isnan(a)
|
#define zend_isnan(a) isnan(a)
|
||||||
#elif defined(HAVE_FPCLASS)
|
#elif defined(HAVE_FPCLASS)
|
||||||
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
||||||
|
|
28
ext/standard/tests/math/bug74039.phpt
Normal file
28
ext/standard/tests/math/bug74039.phpt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #74039: is_infinite(-INF) returns false
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
var_dump(is_finite(INF));
|
||||||
|
var_dump(is_infinite(INF));
|
||||||
|
var_dump(is_nan(INF));
|
||||||
|
|
||||||
|
var_dump(is_finite(-INF));
|
||||||
|
var_dump(is_infinite(-INF));
|
||||||
|
var_dump(is_nan(-INF));
|
||||||
|
|
||||||
|
var_dump(is_finite(NAN));
|
||||||
|
var_dump(is_infinite(NAN));
|
||||||
|
var_dump(is_nan(NAN));
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue