]> granicus.if.org Git - php/commitdiff
MFH
authorIlia Alshanetsky <iliaa@php.net>
Thu, 8 May 2003 01:23:36 +0000 (01:23 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 8 May 2003 01:23:36 +0000 (01:23 +0000)
ext/standard/tests/serialize/bug23298.phpt
ext/standard/var.c
main/main.c
main/php_globals.h
php.ini-dist
php.ini-recommended

index 5d1931bd74c61e3d22d8fddeb314e5d2b4842189..a5305cf37c924d805d9001c7b6bc767b1fac2869 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 Bug #23298 (serialize() and floats/doubles)
+--INI--
+serialize_precision=100
 --FILE--
 <?php 
        ini_set('precision', 12);
index aea8fbe7bb9791dcc05234984a8228740196c10c..628d0c372ba6e806bc97775ad9d193ce67ea27c1 100644 (file)
@@ -514,7 +514,7 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va
                                char *s;
                                ulong slen;
 
-                               slen = spprintf(&s, 0, "d:%.100G;", Z_DVAL_PP(struc));
+                               slen = spprintf(&s, 0, "d:%.*G;", PG(serialize_precision), Z_DVAL_PP(struc));
                                smart_str_appendl(buf, s, slen);
                                efree(s);
                                return;
index 081806dde87e76cb5862422d46492461c489574c..0aab6236c02f0aed5cf05be7f2b612c924da2b39 100644 (file)
@@ -329,6 +329,7 @@ PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN("y2k_compliance",           "1",            PHP_INI_ALL,            OnUpdateBool,                   y2k_compliance,                 php_core_globals,       core_globals)
 
        STD_PHP_INI_ENTRY("unserialize_callback_func",  NULL,   PHP_INI_ALL,            OnUpdateString,                 unserialize_callback_func,      php_core_globals,       core_globals)
+       STD_PHP_INI_ENTRY("serialize_precision",        "100",  PHP_INI_ALL,            OnUpdateInt,                    serialize_precision,    php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("arg_separator.output",       "&",            PHP_INI_ALL,            OnUpdateStringUnempty,  arg_separator.output,   php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("arg_separator.input",        "&",            PHP_INI_SYSTEM|PHP_INI_PERDIR,  OnUpdateStringUnempty,  arg_separator.input,    php_core_globals,       core_globals)
 
index 07cc122f59bae24f8c3d166d21cc240541bb0abd..7a8497ee50907f68cba823929a9e76a8649376a2 100644 (file)
@@ -67,6 +67,7 @@ struct _php_core_globals {
        char *output_handler;
 
        char *unserialize_callback_func;
+       long serialize_precision;
 
        char *safe_mode_exec_dir;
 
index 4864b1f760178a66d4653d24cbde373b1d52a438..358db2aa1d890e1254f387382e70e9d8b7a63695 100644 (file)
@@ -137,6 +137,11 @@ implicit_flush = Off
 ; callback-function.
 unserialize_callback_func=
 
+; When floats & doubles are serialized store serialize_precision significant
+; digits after the floating point. The default value ensures that when floats
+; are decoded with unserialize, the data will remain the same.
+serialize_precision = 100
+
 ; Whether to enable the ability to force arguments to be passed by reference
 ; at function call time.  This method is deprecated and is likely to be
 ; unsupported in future versions of PHP/Zend.  The encouraged method of
index b413871a79c631b5ccfb956c3394cae5be5e5485..89c60df5d7870b0d584afaa6ab7788166efc022a 100644 (file)
@@ -150,6 +150,11 @@ implicit_flush = Off
 ; callback-function.
 unserialize_callback_func=
 
+; When floats & doubles are serialized store serialize_precision significant
+; digits after the floating point. The default value ensures that when floats
+; are decoded with unserialize, the data will remain the same.
+serialize_precision = 100
+
 ; Whether to enable the ability to force arguments to be passed by reference
 ; at function call time.  This method is deprecated and is likely to be
 ; unsupported in future versions of PHP/Zend.  The encouraged method of