diff options
| author | Yasuo Ohgaki <yohgaki@ohgaki.net> | 2015-08-05 08:12:10 +0900 |
|---|---|---|
| committer | Jakub Zelenka <bukka@php.net> | 2016-06-26 13:26:42 +0100 |
| commit | f943daf2d7eeed98d3ead5c05637c2ea8a2ff0e6 (patch) | |
| tree | 869bb1269326a413167ce94e81aaa1136cfce71f /main/snprintf.c | |
| parent | 8de8636a2b6dc331486284f1f037259bb7347768 (diff) | |
| download | php-git-f943daf2d7eeed98d3ead5c05637c2ea8a2ff0e6.tar.gz | |
Initial patch for 0 mode float conversion. The magic number is better to be improved. Any suggestion where to define it?
Diffstat (limited to 'main/snprintf.c')
| -rw-r--r-- | main/snprintf.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/main/snprintf.c b/main/snprintf.c index 9e86d72221..a69ebb3e31 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -139,12 +139,12 @@ static inline char *php_fcvt(double value, int ndigit, int *decpt, int *sign) /* } /* }}} */ -PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf) /* {{{ */ +static inline char *_php_cvt(double value, int ndigit, char dec_point, char exponent, char *buf, int mode) /* {{{ */ { char *digits, *dst, *src; int i, decpt, sign; - digits = zend_dtoa(value, 2, ndigit, &decpt, &sign, NULL); + digits = zend_dtoa(value, mode, ndigit, &decpt, &sign, NULL); if (decpt == 9999) { /* * Infinity or NaN, convert to inf or nan with sign. @@ -234,6 +234,20 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c } /* }}} */ +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 */ /* ==================================================================== * Copyright (c) 1995-1998 The Apache Group. All rights reserved. |
