iliaa Mon Oct 1 15:25:01 2007 UTC
Modified files:
/php-src/main snprintf.c spprintf.c
/php-src/ext/json json.c
Log:
MFB: Fixed bug #42785 (json_encode() formats doubles according to locale
rather then following standard syntax).
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.c?r1=1.59&r2=1.60&diff_format=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.59 php-src/main/snprintf.c:1.60
--- php-src/main/snprintf.c:1.59 Tue Sep 4 11:19:33 2007
+++ php-src/main/snprintf.c Mon Oct 1 15:25:01 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.c,v 1.59 2007/09/04 11:19:33 derick Exp $ */
+/* $Id: snprintf.c,v 1.60 2007/10/01 15:25:01 iliaa Exp $ */
#include "php.h"
@@ -1051,6 +1051,7 @@
case 'g':
+ case 'k':
case 'G':
case 'H':
switch(modifier) {
@@ -1091,7 +1092,7 @@
lconv = localeconv();
}
#endif
- s = php_gcvt(fp_num, precision,
*fmt=='H' ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e',
&num_buf[1]);
+ s = php_gcvt(fp_num, precision, (*fmt
== 'H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt ==
'H')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
else if (print_sign)
http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.c?r1=1.49&r2=1.50&diff_format=u
Index: php-src/main/spprintf.c
diff -u php-src/main/spprintf.c:1.49 php-src/main/spprintf.c:1.50
--- php-src/main/spprintf.c:1.49 Fri Aug 3 14:30:59 2007
+++ php-src/main/spprintf.c Mon Oct 1 15:25:01 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spprintf.c,v 1.49 2007/08/03 14:30:59 tony2001 Exp $ */
+/* $Id: spprintf.c,v 1.50 2007/10/01 15:25:01 iliaa Exp $ */
/* This is the spprintf implementation.
* It has emerged from apache snprintf. See original header:
@@ -690,6 +690,7 @@
case 'g':
+ case 'k':
case 'G':
case 'H':
switch(modifier) {
@@ -730,7 +731,7 @@
lconv = localeconv();
}
#endif
- s = php_gcvt(fp_num, precision,
*fmt=='H' ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e',
&num_buf[1]);
+ s = php_gcvt(fp_num, precision,
(*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt ==
'H')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
else if (print_sign)
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.30&r2=1.31&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.30 php-src/ext/json/json.c:1.31
--- php-src/ext/json/json.c:1.30 Thu Sep 27 18:28:39 2007
+++ php-src/ext/json/json.c Mon Oct 1 15:25:01 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: json.c,v 1.30 2007/09/27 18:28:39 dmitry Exp $ */
+/* $Id: json.c,v 1.31 2007/10/01 15:25:01 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -363,9 +363,9 @@
double dbl = Z_DVAL_P(val);
if (!zend_isinf(dbl) && !zend_isnan(dbl)) {
- len = spprintf(&d, 0, "%.*g", (int) EG(precision), dbl);
- smart_str_appendl(buf, d, len);
- efree(d);
+ len = spprintf(&d, 0, "%.*k", (int)
EG(precision), dbl);
+ smart_str_appendl(buf, d, len);
+ efree(d);
} else {
zend_error(E_WARNING, "[json]
(json_encode_r) double %.9g does not conform to the JSON spec, encoded as 0.",
dbl);
smart_str_appendc(buf, '0');
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php