com php-src: Simply use ndigit for flag for zend_dtoa mode : ext/json/json_encoder.c ext/standard/var.c main /snprintf.c

From: Date: Sun, 26 Jun 2016 12:26:43 +0000
Subject: com php-src: Simply use ndigit for flag for zend_dtoa mode : ext/json/json_encoder.c ext/standard/var.c main /snprintf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92676@lists.php.net to get a copy of this message
Commit: e3d9f1f4d8fc553e51881475e9dbc84c0de39e0e Author: Yasuo Ohgaki <yohgaki@ohgaki.net> Sun, 30 Aug 2015 17:13:24 +0900 Committer: Jakub Zelenka <bukka@php.net> Sun, 26 Jun 2016 13:26:43 +0100 Parents: 3aa2aadcf0c39d7d22532c46d8921f443d27166f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e3d9f1f4d8fc553e51881475e9dbc84c0de39e0e Log: Simply use ndigit for flag for zend_dtoa mode Changed paths: M ext/json/json_encoder.c M ext/standard/var.c M main/snprintf.c Diff: diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index cf9d9ad..b797e7d 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -104,11 +104,8 @@ static inline void php_json_encode_double(smart_str *buf, double d, int options) { size_t len; char num[PHP_JSON_DOUBLE_MAX_LENGTH]; - if (JSON_G(precision) == -1) { - php_0cvt(d, 17, '.', 'e', num); - } else { - php_gcvt(d, JSON_G(precision), '.', 'e', num); - } + + php_gcvt(d, JSON_G(precision), '.', 'e', num); len = strlen(num); if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_JSON_DOUBLE_MAX_LENGTH - 2) { num[len++] = '.'; diff --git a/ext/standard/var.c b/ext/standard/var.c index e197198..59404b8 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -471,11 +471,7 @@ again: } efree(tmp_str); */ - if (PG(serialize_precision < 0)) { - php_0cvt(Z_DVAL_P(struc), 17, '.', 'E', tmp_str); - } else { - php_gcvt(Z_DVAL_P(struc), (int)PG(serialize_precision), '.', 'E', 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: @@ -853,11 +849,7 @@ again: case IS_DOUBLE: { char tmp_str[2048]; /* Use the same magic number of spprintf.c NUM_BUF_SIZE */ smart_str_appendl(buf, "d:", 2); - if (PG(serialize_precision < 0)) { - php_0cvt(Z_DVAL_P(struc), 17, '.', 'E', tmp_str); - } else { - php_gcvt(Z_DVAL_P(struc), (int)PG(serialize_precision), '.', 'E', tmp_str); - } + php_gcvt(Z_DVAL_P(struc), (int)PG(serialize_precision), '.', 'E', tmp_str); smart_str_appends(buf, tmp_str); smart_str_appendc(buf, ';'); return; diff --git a/main/snprintf.c b/main/snprintf.c index a69ebb3..80a5c6e 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -139,11 +139,15 @@ static inline char *php_fcvt(double value, int ndigit, int *decpt, int *sign) /* } /* }}} */ -static inline char *_php_cvt(double value, int ndigit, char dec_point, char exponent, char *buf, int mode) /* {{{ */ +PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */ { char *digits, *dst, *src; int i, decpt, sign; + int mode = ndigit > 0 ? 2 : 0; + if (mode == 0) { + ndigit = 17; + } digits = zend_dtoa(value, mode, ndigit, &decpt, &sign, NULL); if (decpt == 9999) { /* @@ -234,18 +238,6 @@ static inline char *_php_cvt(double value, int ndigit, char dec_point, char expo } /* }}} */ -PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */ -{ - return _php_cvt(value, ndigit, dec_point, exponent, buf, 2); -} -/* }}} */ - -PHPAPI char *php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */ -{ - return _php_cvt(value, ndigit, dec_point, exponent, buf, 0); -} -/* }}} */ - /* {{{ Apache license */

« previous php.cvs (#92676) next »