mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Merge branch 'PHP-8.0'
* PHP-8.0: Revert "Fix #79908: json_encode encodes negative zero as int"
This commit is contained in:
commit
d2cc7239b7
2 changed files with 1 additions and 14 deletions
|
@ -84,8 +84,7 @@ static inline void php_json_encode_double(smart_str *buf, double d, int options)
|
||||||
|
|
||||||
php_gcvt(d, (int)PG(serialize_precision), '.', 'e', num);
|
php_gcvt(d, (int)PG(serialize_precision), '.', 'e', num);
|
||||||
len = strlen(num);
|
len = strlen(num);
|
||||||
if ((options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_DOUBLE_MAX_LENGTH - 2)
|
if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_DOUBLE_MAX_LENGTH - 2) {
|
||||||
|| (UNEXPECTED(len == 2 && num[0] == '-' && num[1] == '0'))) {
|
|
||||||
num[len++] = '.';
|
num[len++] = '.';
|
||||||
num[len++] = '0';
|
num[len++] = '0';
|
||||||
num[len] = '\0';
|
num[len] = '\0';
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
--TEST--
|
|
||||||
Bug #79908 (json_encode encodes negative zero as int)
|
|
||||||
--SKIPIF--
|
|
||||||
<?php
|
|
||||||
if (!extension_loaded('json')) die("skip json extension not available");
|
|
||||||
?>
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
var_dump(json_encode(-0.));
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
string(4) "-0.0"
|
|
Loading…
Add table
Add a link
Reference in a new issue