{
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++] = '.';
}
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:
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;
}
/* }}} */
-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) {
/*
}
/* }}} */
-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 */