com php-src: Add decimal point in double serialization: ext/standard/var.c tests/basic/precision.phpt

From: Date: Sun, 26 Jun 2016 12:26:43 +0000
Subject: com php-src: Add decimal point in double serialization: ext/standard/var.c tests/basic/precision.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92663@lists.php.net to get a copy of this message
Commit: 71774c241e289e6c7a4159fe53cc832742deaa3d Author: Jakub Zelenka <bukka@php.net> Sun, 26 Jun 2016 12:29:57 +0100 Parents: 75b86a2c22a5484c34acbbaa47520a05b3a6f5f0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=71774c241e289e6c7a4159fe53cc832742deaa3d Log: Add decimal point in double serialization Changed paths: M ext/standard/var.c M tests/basic/precision..phpt Diff: diff --git a/ext/standard/var.c b/ext/standard/var.c index 7b0b5da..e0938fe 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -468,22 +468,17 @@ again: smart_str_append_long(buf, Z_LVAL_P(struc)); break; case IS_DOUBLE: - /* TODO: check INF, -INF and NAN in the new logic - tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_P(struc)); - smart_str_appendl(buf, tmp_str, tmp_len); - * Without a decimal point, PHP treats a number literal as an int. + php_gcvt(Z_DVAL_P(struc), (int)PG(serialize_precision), '.', 'E', tmp_str); + smart_str_appends(buf, tmp_str); + /* Without a decimal point, PHP treats a number literal as an int. * This check even works for scientific notation, because the * mantissa always contains a decimal point. * We need to check for finiteness, because INF, -INF and NAN * must not have a decimal point added. - * + */ if (zend_finite(Z_DVAL_P(struc)) && NULL == strchr(tmp_str, '.')) { smart_str_appendl(buf, ".0", 2); } - efree(tmp_str); - */ - php_gcvt(Z_DVAL_P(struc), (int)PG(serialize_precision), '.', 'E', tmp_str); - smart_str_appends(buf, tmp_str); break; case IS_STRING: ztmp = php_addcslashes(Z_STR_P(struc), 0, "'\\", 2); diff --git a/tests/basic/precision.phpt b/tests/basic/precision.phpt index 9c50fa7..173b947 100644 --- a/tests/basic/precision.phpt +++ b/tests/basic/precision.phpt @@ -109,7 +109,7 @@ OUTPUTS 123456789 3.33333333 9.87E+102 10.0000001 string(72) "a:4:{i:0;d:123456789;i:1;d:3.33333333;i:2;d:9.87E+102;i:3;d:10.0000001;}" array ( - 0 => 123456789, + 0 => 123456789.0, 1 => 3.33333333, 2 => 9.87E+102, 3 => 10.0000001,

« previous php.cvs (#92663) next »