summaryrefslogtreecommitdiff
path: root/main/spprintf.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-12-19 11:54:38 +0000
committerDmitry Stogov <dmitry@php.net>2006-12-19 11:54:38 +0000
commitc43fc2afc8fbd3e1fe6a86ac29f8ff81febe79f0 (patch)
treed6c3c4d229c933050bc8c936c8834a18d964f360 /main/spprintf.c
parent39a7719f859a0a01b7f8fa47c35df77901e25ef0 (diff)
downloadphp-git-c43fc2afc8fbd3e1fe6a86ac29f8ff81febe79f0.tar.gz
Fixed bug #39815 (SOAP double encoding is not locale-independent)
Diffstat (limited to 'main/spprintf.c')
-rw-r--r--main/spprintf.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/main/spprintf.c b/main/spprintf.c
index 6e378a7842..a0d499fdf2 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -90,6 +90,10 @@
#include <inttypes.h>
#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
#include "snprintf.h"
#define FALSE 0
@@ -195,6 +199,8 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
char num_buf[NUM_BUF_SIZE];
char char_buf[2]; /* for printing %% and %<unknown> */
+ struct lconv *lconv = NULL;
+
/*
* Flag variables
*/
@@ -527,6 +533,7 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
case 'f':
+ case 'F':
case 'e':
case 'E':
switch(modifier) {
@@ -547,8 +554,12 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
s = "inf";
s_len = 3;
} else {
- s = ap_php_conv_fp(*fmt, fp_num, alternate_form,
+ if (!lconv) {
+ lconv = localeconv();
+ }
+ s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
+ (*fmt == 'f')?(*lconv->decimal_point):'.',
&is_negative, &num_buf[1], &s_len);
if (is_negative)
prefix_char = '-';
@@ -595,7 +606,10 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
/*
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
- s = bsd_gcvt(fp_num, precision, &num_buf[1]);
+ if (!lconv) {
+ lconv = localeconv();
+ }
+ s = php_gcvt(fp_num, precision, *lconv->decimal_point, (*fmt == 'G')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
else if (print_sign)
@@ -607,8 +621,6 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
if (alternate_form && (q = strchr(s, '.')) == NULL)
s[s_len++] = '.';
- if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL)
- *q = 'E';
break;