diff options
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/array.c | 37 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/var_export-locale.phpt | 8 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/var_export_basic3.phpt | 36 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/var_export_basic5.phpt | 10 | ||||
-rw-r--r-- | ext/standard/var.c | 2 |
5 files changed, 52 insertions, 41 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 51972033ee..360a691d38 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2222,13 +2222,14 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS case HASH_KEY_IS_STRING: if (recursive && zend_hash_find(dest, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) { HashTable *thash = Z_TYPE_PP(dest_entry) == IS_ARRAY ? Z_ARRVAL_PP(dest_entry) : NULL; + zval *src_zval; + zval *tmp = NULL; if ((thash && thash->nApplyCount > 1) || (*src_entry == *dest_entry && Z_ISREF_PP(dest_entry) && (Z_REFCOUNT_PP(dest_entry) % 2))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); return 0; } SEPARATE_ZVAL(dest_entry); - SEPARATE_ZVAL(src_entry); if (Z_TYPE_PP(dest_entry) == IS_NULL) { convert_to_array_ex(dest_entry); @@ -2236,23 +2237,34 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS } else { convert_to_array_ex(dest_entry); } - if (Z_TYPE_PP(src_entry) == IS_NULL) { - convert_to_array_ex(src_entry); - add_next_index_null(*src_entry); + if (Z_TYPE_PP(src_entry) == IS_OBJECT) { + ALLOC_ZVAL(src_zval); + INIT_PZVAL_COPY(src_zval, *src_entry); + zval_copy_ctor(src_zval); + convert_to_array(src_zval); + tmp = src_zval; } else { - convert_to_array_ex(src_entry); + src_zval = *src_entry; } - if (thash) { - thash->nApplyCount++; - } - if (!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_PP(src_entry), recursive TSRMLS_CC)) { + if (Z_TYPE_P(src_zval) == IS_ARRAY) { + if (thash) { + thash->nApplyCount++; + } + if (!php_array_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_P(src_zval), recursive TSRMLS_CC)) { + if (thash) { + thash->nApplyCount--; + } + return 0; + } if (thash) { thash->nApplyCount--; } - return 0; + } else { + Z_ADDREF_PP(src_entry); + zend_hash_next_index_insert(Z_ARRVAL_PP(dest_entry), &src_zval, sizeof(zval *), NULL); } - if (thash) { - thash->nApplyCount--; + if (tmp) { + zval_ptr_dtor(&tmp); } } else { Z_ADDREF_PP(src_entry); @@ -2356,7 +2368,6 @@ static void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETERS, int array_init_size(return_value, init_size); for (i = 0; i < argc; i++) { - SEPARATE_ZVAL(args[i]); if (!replace) { php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(args[i]), recursive TSRMLS_CC); } else if (recursive && i > 0) { /* First array will be copied directly instead */ diff --git a/ext/standard/tests/general_functions/var_export-locale.phpt b/ext/standard/tests/general_functions/var_export-locale.phpt index 37142cf34c..3cbebe9c72 100644 --- a/ext/standard/tests/general_functions/var_export-locale.phpt +++ b/ext/standard/tests/general_functions/var_export-locale.phpt @@ -784,15 +784,15 @@ string(20) "array ( Iteration 13 array ( 0 => 10.5, - 1 => 5.6, + 1 => 5.5999999999999996, ) array ( 0 => 10.5, - 1 => 5.6, + 1 => 5.5999999999999996, ) -string(34) "array ( +string(49) "array ( 0 => 10.5, - 1 => 5.6, + 1 => 5.5999999999999996, )" diff --git a/ext/standard/tests/general_functions/var_export_basic3.phpt b/ext/standard/tests/general_functions/var_export_basic3.phpt index 2997215910..9e27d90425 100644 --- a/ext/standard/tests/general_functions/var_export_basic3.phpt +++ b/ext/standard/tests/general_functions/var_export_basic3.phpt @@ -96,9 +96,9 @@ string(1) "0" -- Iteration: -0.1 -- --0.1 --0.1 -string(4) "-0.1" +-0.10000000000000001 +-0.10000000000000001 +string(20) "-0.10000000000000001" -- Iteration: 10.0000000000000000005 -- @@ -120,9 +120,9 @@ string(6) "100000" -- Iteration: 1e-5 -- -1.0E-5 -1.0E-5 -string(6) "1.0E-5" +1.0000000000000001E-5 +1.0000000000000001E-5 +string(21) "1.0000000000000001E-5" -- Iteration: 1e+5 -- @@ -144,9 +144,9 @@ string(6) "100000" -- Iteration: 1E-5 -- -1.0E-5 -1.0E-5 -string(6) "1.0E-5" +1.0000000000000001E-5 +1.0000000000000001E-5 +string(21) "1.0000000000000001E-5" -- Iteration: .5e+7 -- @@ -156,20 +156,20 @@ string(7) "5000000" -- Iteration: .6e-19 -- -6.0E-20 -6.0E-20 -string(7) "6.0E-20" +6.0000000000000006E-20 +6.0000000000000006E-20 +string(22) "6.0000000000000006E-20" -- Iteration: .05E+44 -- -5.0E+42 -5.0E+42 -string(7) "5.0E+42" +5.0000000000000001E+42 +5.0000000000000001E+42 +string(22) "5.0000000000000001E+42" -- Iteration: .0034E-30 -- -3.4E-33 -3.4E-33 -string(7) "3.4E-33" +3.4000000000000001E-33 +3.4000000000000001E-33 +string(22) "3.4000000000000001E-33" ===DONE=== diff --git a/ext/standard/tests/general_functions/var_export_basic5.phpt b/ext/standard/tests/general_functions/var_export_basic5.phpt index 96b3f54cc9..1512fa8377 100644 --- a/ext/standard/tests/general_functions/var_export_basic5.phpt +++ b/ext/standard/tests/general_functions/var_export_basic5.phpt @@ -233,15 +233,15 @@ string(20) "array ( --Iteration: array(10.5, 5.6) -- array ( 0 => 10.5, - 1 => 5.6, + 1 => 5.5999999999999996, ) array ( 0 => 10.5, - 1 => 5.6, + 1 => 5.5999999999999996, ) -string(34) "array ( +string(49) "array ( 0 => 10.5, - 1 => 5.6, + 1 => 5.5999999999999996, )" @@ -274,4 +274,4 @@ string(41) "array ( 1 => 'test', )" -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/standard/var.c b/ext/standard/var.c index cafb8fa342..fb2a310f4c 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -436,7 +436,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC) smart_str_append_long(buf, Z_LVAL_PP(struc)); break; case IS_DOUBLE: - tmp_len = spprintf(&tmp_str, 0,"%.*H", (int) EG(precision), Z_DVAL_PP(struc)); + tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_PP(struc)); smart_str_appendl(buf, tmp_str, tmp_len); efree(tmp_str); break; |