diff options
| author | Hartmut Holzgraefe <hholzgra@php.net> | 2002-06-17 11:50:25 +0000 |
|---|---|---|
| committer | Hartmut Holzgraefe <hholzgra@php.net> | 2002-06-17 11:50:25 +0000 |
| commit | efdde5efe51f4221779a847e813bea9cdce73084 (patch) | |
| tree | 5a2d397db4bb70d2cdda838b1c5892d315945c52 /ext/standard/formatted_print.c | |
| parent | 00b667b61b49531ab22842a9a2da35493c0b2f58 (diff) | |
| download | php-git-efdde5efe51f4221779a847e813bea9cdce73084.tar.gz | |
making printf/sprintf locale-aware without external dependencies
Diffstat (limited to 'ext/standard/formatted_print.c')
| -rw-r--r-- | ext/standard/formatted_print.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 7a11b3a5f0..b2dc5cb700 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -25,6 +25,10 @@ #include "zend_execute.h" #include <stdio.h> +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif + #define ALIGN_LEFT 0 #define ALIGN_RIGHT 1 #define ADJ_WIDTH 1 @@ -274,6 +278,14 @@ php_sprintf_appenddouble(char **buffer, int *pos, char *cvt; register int i = 0, j = 0; int sign, decpt; + char decimal_point = '.'; +#ifdef HAVE_LOCALECONV + struct lconv l; + + localeconv_r(&l); + + decimal_point = l.decimal_point[0]; +#endif PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", *buffer, pos, size, number, width, padding, alignment, fmt)); @@ -308,7 +320,7 @@ php_sprintf_appenddouble(char **buffer, int *pos, numbuf[i++] = '0'; if (precision > 0) { int k = precision; - numbuf[i++] = '.'; + numbuf[i++] = decimal_point; while ((decpt++ < 0) && k--) { numbuf[i++] = '0'; } @@ -317,12 +329,12 @@ php_sprintf_appenddouble(char **buffer, int *pos, while (decpt-- > 0) numbuf[i++] = cvt[j++]; if (precision > 0) - numbuf[i++] = '.'; + numbuf[i++] = decimal_point; } } else { numbuf[i++] = cvt[j++]; if (precision > 0) - numbuf[i++] = '.'; + numbuf[i++] = decimal_point; } while (cvt[j]) { |
