summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2016-03-20 01:32:44 +0000
committerAndrea Faulds <ajf@ajf.me>2016-03-20 01:32:44 +0000
commit1c1e20d77160c5ccc402458effa9df56399ca5da (patch)
tree63de5ab9a5ecce58c49a13ee62ee92a2615ba445
parentba4b2a60f932b05c929b843aaf010ac740579e2d (diff)
downloadphp-git-1c1e20d77160c5ccc402458effa9df56399ca5da.tar.gz
Deduplicate NAN/INF portability, move to Zend
-rw-r--r--Zend/Zend.m4137
-rw-r--r--Zend/zend_portability.h46
-rw-r--r--ext/intl/common/common_date.cpp14
-rw-r--r--ext/standard/basic_functions.c35
-rw-r--r--ext/standard/config.m4137
-rw-r--r--ext/standard/math.c7
-rw-r--r--ext/standard/var_unserializer.c71
-rw-r--r--ext/standard/var_unserializer.re7
8 files changed, 237 insertions, 217 deletions
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
index bdeac672b4..3a2da6d1de 100644
--- a/Zend/Zend.m4
+++ b/Zend/Zend.m4
@@ -466,3 +466,140 @@ else
HAVE_GCC_GLOBAL_REGS=no
fi
AC_MSG_RESULT($ZEND_GCC_GLOBAL_REGS)
+
+dnl
+dnl Check if atof() accepts NAN
+dnl
+AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[
+AC_TRY_RUN([
+#include <math.h>
+#include <stdlib.h>
+
+#ifdef HAVE_ISNAN
+#define zend_isnan(a) isnan(a)
+#elif defined(HAVE_FPCLASS)
+#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
+#else
+#define zend_isnan(a) 0
+#endif
+
+int main(int argc, char** argv)
+{
+ return zend_isnan(atof("NAN")) ? 0 : 1;
+}
+],[
+ ac_cv_atof_accept_nan=yes
+],[
+ ac_cv_atof_accept_nan=no
+],[
+ ac_cv_atof_accept_nan=no
+])])
+if test "$ac_cv_atof_accept_nan" = "yes"; then
+ AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN])
+fi
+
+dnl
+dnl Check if atof() accepts INF
+dnl
+AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[
+AC_TRY_RUN([
+#include <math.h>
+#include <stdlib.h>
+
+#ifdef HAVE_ISINF
+#define zend_isinf(a) isinf(a)
+#elif defined(INFINITY)
+/* Might not work, but is required by ISO C99 */
+#define zend_isinf(a) (((a)==INFINITY)?1:0)
+#elif defined(HAVE_FPCLASS)
+#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
+#else
+#define zend_isinf(a) 0
+#endif
+
+int main(int argc, char** argv)
+{
+ return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1;
+}
+],[
+ ac_cv_atof_accept_inf=yes
+],[
+ ac_cv_atof_accept_inf=no
+],[
+ ac_cv_atof_accept_inf=no
+])])
+if test "$ac_cv_atof_accept_inf" = "yes"; then
+ AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF])
+fi
+
+dnl
+dnl Check if HUGE_VAL == INF
+dnl
+AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[
+AC_TRY_RUN([
+#include <math.h>
+#include <stdlib.h>
+
+#ifdef HAVE_ISINF
+#define zend_isinf(a) isinf(a)
+#elif defined(INFINITY)
+/* Might not work, but is required by ISO C99 */
+#define zend_isinf(a) (((a)==INFINITY)?1:0)
+#elif defined(HAVE_FPCLASS)
+#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
+#else
+#define zend_isinf(a) 0
+#endif
+
+int main(int argc, char** argv)
+{
+ return zend_isinf(HUGE_VAL) ? 0 : 1;
+}
+],[
+ ac_cv_huge_val_inf=yes
+],[
+ ac_cv_huge_val_inf=no
+],[
+ ac_cv_huge_val_inf=yes
+])])
+dnl This is the most probable fallback so we assume yes in case of cross compile.
+if test "$ac_cv_huge_val_inf" = "yes"; then
+ AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF])
+fi
+
+dnl
+dnl Check if HUGE_VAL + -HUGEVAL == NAN
+dnl
+AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[
+AC_TRY_RUN([
+#include <math.h>
+#include <stdlib.h>
+
+#ifdef HAVE_ISNAN
+#define zend_isnan(a) isnan(a)
+#elif defined(HAVE_FPCLASS)
+#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
+#else
+#define zend_isnan(a) 0
+#endif
+
+int main(int argc, char** argv)
+{
+#if defined(__sparc__) && !(__GNUC__ >= 3)
+ /* prevent bug #27830 */
+ return 1;
+#else
+ return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1;
+#endif
+}
+],[
+ ac_cv_huge_val_nan=yes
+],[
+ ac_cv_huge_val_nan=no
+],[
+ ac_cv_huge_val_nan=yes
+])])
+dnl This is the most probable fallback so we assume yes in case of cross compile.
+if test "$ac_cv_huge_val_nan" = "yes"; then
+ AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
+fi
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 298dfb53fa..ff12d93269 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -53,6 +53,7 @@
#include <stdio.h>
#include <assert.h>
+#include <math.h>
#ifdef HAVE_UNIX_H
# include <unix.h>
@@ -420,6 +421,51 @@ char *alloca();
#undef MAX
#define MAX(a, b) (((a)>(b))?(a):(b))
#define MIN(a, b) (((a)<(b))?(a):(b))
+
+/* We always define a function, even if there's a macro or expression we could
+ * alias, so that using it in contexts where we can't make function calls
+ * won't fail to compile on some machines and not others.
+ */
+static zend_always_inline double _zend_get_inf(void) /* {{{ */
+{
+#ifdef INFINITY
+ return INFINITY;
+#elif HAVE_HUGE_VAL_INF
+ return HUGE_VAL;
+#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
+# define _zend_DOUBLE_INFINITY_HIGH 0x7ff00000
+ double val = 0.0;
+ ((uint32_t*)&val)[1] = _zend_DOUBLE_INFINITY_HIGH;
+ ((uint32_t*)&val)[0] = 0;
+ return val;
+#elif HAVE_ATOF_ACCEPTS_INF
+ return atof("INF");
+#else
+ return 1.0/0.0;
+#endif
+} /* }}} */
+#define ZEND_INFINITY (_zend_get_inf())
+
+static zend_always_inline double _zend_get_nan(void) /* {{{ */
+{
+#ifdef NAN
+ return NAN;
+#elif HAVE_HUGE_VAL_NAN
+ return HUGE_VAL + -HUGE_VAL;
+#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
+# define _zend_DOUBLE_QUIET_NAN_HIGH 0xfff80000
+ double val = 0.0;
+ ((uint32_t*)&val)[1] = _zend_DOUBLE_QUIET_NAN_HIGH;
+ ((uint32_t*)&val)[0] = 0;
+ return val;
+#elif HAVE_ATOF_ACCEPTS_NAN
+ return atof("NAN");
+#else
+ return 0.0/0.0;
+#endif
+} /* }}} */
+#define ZEND_NAN (_zend_get_nan())
+
#define ZEND_STRL(str) (str), (sizeof(str)-1)
#define ZEND_STRS(str) (str), (sizeof(str))
#define ZEND_NORMALIZE_BOOL(n) \
diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp
index f1bf75ab0f..2357a03940 100644
--- a/ext/intl/common/common_date.cpp
+++ b/ext/intl/common/common_date.cpp
@@ -25,13 +25,7 @@ extern "C" {
#include <ext/date/php_date.h>
}
-#ifndef INFINITY
-#define INFINITY (DBL_MAX+DBL_MAX)
-#endif
-
-#ifndef NAN
-#define NAN (INFINITY-INFINITY)
-#endif
+#include "zend_portability.h"
/* {{{ timezone_convert_datetimezone
* The timezone in DateTime and DateTimeZone is not unified. */
@@ -118,7 +112,7 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
}
if (millis) {
- *millis = NAN;
+ *millis = ZEND_NAN;
}
if (tz) {
*tz = NULL;
@@ -173,13 +167,13 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func)
{
- double rv = NAN;
+ double rv = ZEND_NAN;
zend_long lv;
int type;
char *message;
if (err && U_FAILURE(err->code)) {
- return NAN;
+ return ZEND_NAN;
}
switch (Z_TYPE_P(z)) {
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index f8121c1ebf..b1ac80fd94 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -48,6 +48,8 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#include "zend_language_scanner.h"
#include <zend_language_parser.h>
+#include "zend_portability.h"
+
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
@@ -3484,40 +3486,15 @@ static void basic_globals_dtor(php_basic_globals *basic_globals_p) /* {{{ */
}
/* }}} */
-#define PHP_DOUBLE_INFINITY_HIGH 0x7ff00000
-#define PHP_DOUBLE_QUIET_NAN_HIGH 0xfff80000
-
PHPAPI double php_get_nan(void) /* {{{ */
{
-#if HAVE_HUGE_VAL_NAN
- return HUGE_VAL + -HUGE_VAL;
-#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
- double val = 0.0;
- ((uint32_t*)&val)[1] = PHP_DOUBLE_QUIET_NAN_HIGH;
- ((uint32_t*)&val)[0] = 0;
- return val;
-#elif HAVE_ATOF_ACCEPTS_NAN
- return atof("NAN");
-#else
- return 0.0/0.0;
-#endif
+ return ZEND_NAN;
}
/* }}} */
PHPAPI double php_get_inf(void) /* {{{ */
{
-#if HAVE_HUGE_VAL_INF
- return HUGE_VAL;
-#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
- double val = 0.0;
- ((uint32_t*)&val)[1] = PHP_DOUBLE_INFINITY_HIGH;
- ((uint32_t*)&val)[0] = 0;
- return val;
-#elif HAVE_ATOF_ACCEPTS_INF
- return atof("INF");
-#else
- return 1.0/0.0;
-#endif
+ return ZEND_INFINITY;
}
/* }}} */
@@ -3609,8 +3586,8 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
REGISTER_MATH_CONSTANT(M_SQRT2);
REGISTER_MATH_CONSTANT(M_SQRT1_2);
REGISTER_MATH_CONSTANT(M_SQRT3);
- REGISTER_DOUBLE_CONSTANT("INF", php_get_inf(), CONST_CS | CONST_PERSISTENT);
- REGISTER_DOUBLE_CONSTANT("NAN", php_get_nan(), CONST_CS | CONST_PERSISTENT);
+ REGISTER_DOUBLE_CONSTANT("INF", ZEND_INFINITY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_DOUBLE_CONSTANT("NAN", ZEND_NAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_UP", PHP_ROUND_HALF_UP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_DOWN", PHP_ROUND_HALF_DOWN, CONST_CS | CONST_PERSISTENT);
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index f9afff30e6..c536773a3c 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -412,143 +412,6 @@ dnl
PHP_CHECK_FUNC(res_search, resolv, bind, socket)
dnl
-dnl Check if atof() accepts NAN
-dnl
-AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[
-AC_TRY_RUN([
-#include <math.h>
-#include <stdlib.h>
-
-#ifdef HAVE_ISNAN
-#define zend_isnan(a) isnan(a)
-#elif defined(HAVE_FPCLASS)
-#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
-#else
-#define zend_isnan(a) 0
-#endif
-
-int main(int argc, char** argv)
-{
- return zend_isnan(atof("NAN")) ? 0 : 1;
-}
-],[
- ac_cv_atof_accept_nan=yes
-],[
- ac_cv_atof_accept_nan=no
-],[
- ac_cv_atof_accept_nan=no
-])])
-if test "$ac_cv_atof_accept_nan" = "yes"; then
- AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN])
-fi
-
-dnl
-dnl Check if atof() accepts INF
-dnl
-AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[
-AC_TRY_RUN([
-#include <math.h>
-#include <stdlib.h>
-
-#ifdef HAVE_ISINF
-#define zend_isinf(a) isinf(a)
-#elif defined(INFINITY)
-/* Might not work, but is required by ISO C99 */
-#define zend_isinf(a) (((a)==INFINITY)?1:0)
-#elif defined(HAVE_FPCLASS)
-#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
-#else
-#define zend_isinf(a) 0
-#endif
-
-int main(int argc, char** argv)
-{
- return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1;
-}
-],[
- ac_cv_atof_accept_inf=yes
-],[
- ac_cv_atof_accept_inf=no
-],[
- ac_cv_atof_accept_inf=no
-])])
-if test "$ac_cv_atof_accept_inf" = "yes"; then
- AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF])
-fi
-
-dnl
-dnl Check if HUGE_VAL == INF
-dnl
-AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[
-AC_TRY_RUN([
-#include <math.h>
-#include <stdlib.h>
-
-#ifdef HAVE_ISINF
-#define zend_isinf(a) isinf(a)
-#elif defined(INFINITY)
-/* Might not work, but is required by ISO C99 */
-#define zend_isinf(a) (((a)==INFINITY)?1:0)
-#elif defined(HAVE_FPCLASS)
-#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
-#else
-#define zend_isinf(a) 0
-#endif
-
-int main(int argc, char** argv)
-{
- return zend_isinf(HUGE_VAL) ? 0 : 1;
-}
-],[
- ac_cv_huge_val_inf=yes
-],[
- ac_cv_huge_val_inf=no
-],[
- ac_cv_huge_val_inf=yes
-])])
-dnl This is the most probable fallback so we assume yes in case of cross compile.
-if test "$ac_cv_huge_val_inf" = "yes"; then
- AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF])
-fi
-
-dnl
-dnl Check if HUGE_VAL + -HUGEVAL == NAN
-dnl
-AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[
-AC_TRY_RUN([
-#include <math.h>
-#include <stdlib.h>
-
-#ifdef HAVE_ISNAN
-#define zend_isnan(a) isnan(a)
-#elif defined(HAVE_FPCLASS)
-#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
-#else
-#define zend_isnan(a) 0
-#endif
-
-int main(int argc, char** argv)
-{
-#if defined(__sparc__) && !(__GNUC__ >= 3)
- /* prevent bug #27830 */
- return 1;
-#else
- return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1;
-#endif
-}
-],[
- ac_cv_huge_val_nan=yes
-],[
- ac_cv_huge_val_nan=no
-],[
- ac_cv_huge_val_nan=yes
-])])
-dnl This is the most probable fallback so we assume yes in case of cross compile.
-if test "$ac_cv_huge_val_nan" = "yes"; then
- AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
-fi
-
-dnl
dnl Check for strptime()
dnl
AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 688ae9f6d1..5caac2e542 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -25,6 +25,7 @@
#include "php_math.h"
#include "zend_multiply.h"
#include "zend_exceptions.h"
+#include "zend_portability.h"
#include <math.h>
#include <float.h>
@@ -239,7 +240,7 @@ static double php_acosh(double x)
if (x >= 1) {
return log(x + sqrt(x * x - 1));
} else {
- return (DBL_MAX+DBL_MAX)-(DBL_MAX+DBL_MAX);
+ return ZEND_NAN;
}
# else
return(log(x + sqrt(x * x - 1)));
@@ -845,7 +846,7 @@ PHP_FUNCTION(log)
}
if (base == 1.0) {
- RETURN_DOUBLE(php_get_nan());
+ RETURN_DOUBLE(ZEND_NAN);
}
if (base <= 0.0) {
@@ -1119,7 +1120,7 @@ PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base)
char buf[(sizeof(double) << 3) + 1];
/* Don't try to convert +/- infinity */
- if (fvalue == HUGE_VAL || fvalue == -HUGE_VAL) {
+ if (fvalue == ZEND_INFINITY || fvalue == -ZEND_INFINITY) {
php_error_docref(NULL, E_WARNING, "Number too large");
return ZSTR_EMPTY_ALLOC();
}
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 443a42cca3..3b76af90b7 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 */
+/* Generated by re2c 0.15.3 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
@@ -23,6 +23,7 @@
#include "php.h"
#include "ext/standard/php_var.h"
#include "php_incomplete_class.h"
+#include "zend_portability.h"
/* {{{ reference-handling for unserializer: var_* */
#define VAR_ENTRIES_MAX 1024
@@ -238,7 +239,7 @@ static inline int unserialize_allowed_class(zend_string *class_name, HashTable *
#define YYMARKER marker
-#line 246 "ext/standard/var_unserializer.re"
+#line 247 "ext/standard/var_unserializer.re"
@@ -514,7 +515,7 @@ PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
start = cursor;
-#line 518 "ext/standard/var_unserializer.c"
+#line 519 "ext/standard/var_unserializer.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -551,7 +552,6 @@ PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-
if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
yych = *YYCURSOR;
switch (yych) {
@@ -574,7 +574,7 @@ yy2:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy95;
yy3:
-#line 884 "ext/standard/var_unserializer.re"
+#line 885 "ext/standard/var_unserializer.re"
{ return 0; }
#line 580 "ext/standard/var_unserializer.c"
yy4:
@@ -619,7 +619,7 @@ yy13:
goto yy3;
yy14:
++YYCURSOR;
-#line 878 "ext/standard/var_unserializer.re"
+#line 879 "ext/standard/var_unserializer.re"
{
/* this is the case where we have less data than planned */
php_error_docref(NULL, E_NOTICE, "Unexpected end of serialized data");
@@ -651,11 +651,12 @@ yy20:
if (yybm[0+yych] & 128) {
goto yy20;
}
- if (yych != ':') goto yy18;
+ if (yych <= '/') goto yy18;
+ if (yych >= ';') goto yy18;
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 733 "ext/standard/var_unserializer.re"
+#line 734 "ext/standard/var_unserializer.re"
{
size_t len, len2, len3, maxlen;
zend_long elements;
@@ -800,7 +801,7 @@ yy20:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
-#line 804 "ext/standard/var_unserializer.c"
+#line 805 "ext/standard/var_unserializer.c"
yy25:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -825,14 +826,14 @@ yy27:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 726 "ext/standard/var_unserializer.re"
+#line 727 "ext/standard/var_unserializer.re"
{
if (!var_hash) return 0;
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
}
-#line 836 "ext/standard/var_unserializer.c"
+#line 837 "ext/standard/var_unserializer.c"
yy32:
yych = *++YYCURSOR;
if (yych == '+') goto yy33;
@@ -853,7 +854,7 @@ yy34:
yych = *++YYCURSOR;
if (yych != '{') goto yy18;
++YYCURSOR;
-#line 702 "ext/standard/var_unserializer.re"
+#line 703 "ext/standard/var_unserializer.re"
{
zend_long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
@@ -877,7 +878,7 @@ yy34:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
-#line 881 "ext/standard/var_unserializer.c"
+#line 882 "ext/standard/var_unserializer.c"
yy39:
yych = *++YYCURSOR;
if (yych == '+') goto yy40;
@@ -898,7 +899,7 @@ yy41:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 668 "ext/standard/var_unserializer.re"
+#line 669 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
zend_string *str;
@@ -932,7 +933,7 @@ yy41:
ZVAL_STR(rval, str);
return 1;
}
-#line 936 "ext/standard/var_unserializer.c"
+#line 937 "ext/standard/var_unserializer.c"
yy46:
yych = *++YYCURSOR;
if (yych == '+') goto yy47;
@@ -953,7 +954,7 @@ yy48:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 636 "ext/standard/var_unserializer.re"
+#line 637 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -985,7 +986,7 @@ yy48:
ZVAL_STRINGL(rval, str, len);
return 1;
}
-#line 989 "ext/standard/var_unserializer.c"
+#line 990 "ext/standard/var_unserializer.c"
yy53:
yych = *++YYCURSOR;
if (yych <= '/') {
@@ -1073,7 +1074,7 @@ yy61:
}
yy63:
++YYCURSOR;
-#line 627 "ext/standard/var_unserializer.re"
+#line 628 "ext/standard/var_unserializer.re"
{
#if SIZEOF_ZEND_LONG == 4
use_double:
@@ -1082,7 +1083,7 @@ use_double:
ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
return 1;
}
-#line 1086 "ext/standard/var_unserializer.c"
+#line 1087 "ext/standard/var_unserializer.c"
yy65:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1141,23 +1142,23 @@ yy73:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 611 "ext/standard/var_unserializer.re"
+#line 612 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
if (!strncmp((char*)start + 2, "NAN", 3)) {
- ZVAL_DOUBLE(rval, php_get_nan());
+ ZVAL_DOUBLE(rval, ZEND_NAN);
} else if (!strncmp((char*)start + 2, "INF", 3)) {
- ZVAL_DOUBLE(rval, php_get_inf());
+ ZVAL_DOUBLE(rval, ZEND_INFINITY);
} else if (!strncmp((char*)start + 2, "-INF", 4)) {
- ZVAL_DOUBLE(rval, -php_get_inf());
+ ZVAL_DOUBLE(rval, -ZEND_INFINITY);
} else {
ZVAL_NULL(rval);
}
return 1;
}
-#line 1161 "ext/standard/var_unserializer.c"
+#line 1162 "ext/standard/var_unserializer.c"
yy76:
yych = *++YYCURSOR;
if (yych == 'N') goto yy73;
@@ -1184,7 +1185,7 @@ yy79:
if (yych <= '9') goto yy79;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 585 "ext/standard/var_unserializer.re"
+#line 586 "ext/standard/var_unserializer.re"
{
#if SIZEOF_ZEND_LONG == 4
int digits = YYCURSOR - start - 3;
@@ -1210,7 +1211,7 @@ yy79:
ZVAL_LONG(rval, parse_iv(start + 2));
return 1;
}
-#line 1214 "ext/standard/var_unserializer.c"
+#line 1215 "ext/standard/var_unserializer.c"
yy83:
yych = *++YYCURSOR;
if (yych <= '/') goto yy18;
@@ -1218,22 +1219,22 @@ yy83:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 579 "ext/standard/var_unserializer.re"
+#line 580 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
ZVAL_BOOL(rval, parse_iv(start + 2));
return 1;
}
-#line 1228 "ext/standard/var_unserializer.c"
+#line 1229 "ext/standard/var_unserializer.c"
yy87:
++YYCURSOR;
-#line 573 "ext/standard/var_unserializer.re"
+#line 574 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
ZVAL_NULL(rval);
return 1;
}
-#line 1237 "ext/standard/var_unserializer.c"
+#line 1238 "ext/standard/var_unserializer.c"
yy89:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1256,7 +1257,7 @@ yy91:
if (yych <= '9') goto yy91;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 548 "ext/standard/var_unserializer.re"
+#line 549 "ext/standard/var_unserializer.re"
{
zend_long id;
@@ -1281,7 +1282,7 @@ yy91:
return 1;
}
-#line 1285 "ext/standard/var_unserializer.c"
+#line 1286 "ext/standard/var_unserializer.c"
yy95:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1304,7 +1305,7 @@ yy97:
if (yych <= '9') goto yy97;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 522 "ext/standard/var_unserializer.re"
+#line 523 "ext/standard/var_unserializer.re"
{
zend_long id;
@@ -1330,9 +1331,9 @@ yy97:
return 1;
}
-#line 1334 "ext/standard/var_unserializer.c"
+#line 1335 "ext/standard/var_unserializer.c"
}
-#line 886 "ext/standard/var_unserializer.re"
+#line 887 "ext/standard/var_unserializer.re"
return 0;
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index abd1f28fae..4920e2bc8d 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -21,6 +21,7 @@
#include "php.h"
#include "ext/standard/php_var.h"
#include "php_incomplete_class.h"
+#include "zend_portability.h"
/* {{{ reference-handling for unserializer: var_* */
#define VAR_ENTRIES_MAX 1024
@@ -612,11 +613,11 @@ PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
*p = YYCURSOR;
if (!strncmp((char*)start + 2, "NAN", 3)) {
- ZVAL_DOUBLE(rval, php_get_nan());
+ ZVAL_DOUBLE(rval, ZEND_NAN);
} else if (!strncmp((char*)start + 2, "INF", 3)) {
- ZVAL_DOUBLE(rval, php_get_inf());
+ ZVAL_DOUBLE(rval, ZEND_INFINITY);
} else if (!strncmp((char*)start + 2, "-INF", 4)) {
- ZVAL_DOUBLE(rval, -php_get_inf());
+ ZVAL_DOUBLE(rval, -ZEND_INFINITY);
} else {
ZVAL_NULL(rval);
}