From: Marcus Boerger Date: Tue, 23 Mar 2004 22:30:25 +0000 (+0000) Subject: - Allow negative infinity X-Git-Tag: php-5.0.0RC2RC1~255 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdcff80c163d07e3aee163a6fc2f4bdc0c589b58;p=php - Allow negative infinity - Register missing constants, they work anyway but cause an E_NOTICE # generation by atof() should be portable enough (afaik) --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 46ec37f640..c7cccee506 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -982,6 +982,8 @@ PHP_MINIT_FUNCTION(basic) REGISTER_MATH_CONSTANT(M_2_SQRTPI); REGISTER_MATH_CONSTANT(M_SQRT2); REGISTER_MATH_CONSTANT(M_SQRT1_2); + REGISTER_DOUBLE_CONSTANT("INF", atof("INF"), CONST_CS | CONST_PERSISTENT); + REGISTER_DOUBLE_CONSTANT("NAN", atof("NAN"), CONST_CS | CONST_PERSISTENT); #if ENABLE_TEST_CLASS test_class_startup(); diff --git a/ext/standard/tests/math/bug27646.phpt b/ext/standard/tests/math/bug27646.phpt new file mode 100755 index 0000000000..8c05bb9194 --- /dev/null +++ b/ext/standard/tests/math/bug27646.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #27646 (Cannot serialize/unserialize non-finite numeric values) +--FILE-- + +--EXPECT-- +float(-INF) +string(7) "d:-INF;" +float(-INF) +float(INF) +string(6) "d:INF;" +float(INF) +float(NAN) +string(6) "d:NAN;" +float(NAN) diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 8f53eca0b6..9895a3b893 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -320,7 +320,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return 1; } -"d:" (iv | nv | nvexp | "NAN" | "INF") ";" { +"d:" (iv | nv | nvexp | "NAN" | "-"? "INF") ";" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_DOUBLE(*rval, atof(start + 2));