summaryrefslogtreecommitdiff
path: root/main/snprintf.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-12-19 13:13:29 +0000
committerDmitry Stogov <dmitry@php.net>2006-12-19 13:13:29 +0000
commit5d8183f0b22e72ce8fc3cb632ecfd253a634c6c3 (patch)
tree8d76d7d19d8508eafcfc0b6a9b58730fc20cb974 /main/snprintf.c
parentd6db0ccc12f603d67c9d954087bae7fef46d261d (diff)
downloadphp-git-5d8183f0b22e72ce8fc3cb632ecfd253a634c6c3.tar.gz
Support for systems without locale.h
Diffstat (limited to 'main/snprintf.c')
-rw-r--r--main/snprintf.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/main/snprintf.c b/main/snprintf.c
index 6f07022383..f3f6dae90b 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -38,6 +38,9 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
+#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
+#else
+#define LCONV_DECIMAL_POINT '.'
#endif
/*
@@ -584,7 +587,9 @@ static int format_converter(register buffy * odp, const char *fmt,
char num_buf[NUM_BUF_SIZE];
char char_buf[2]; /* for printing %% and %<unknown> */
+#ifdef HAVE_LOCALE_H
struct lconv *lconv = NULL;
+#endif
/*
* Flag variables
@@ -942,12 +947,14 @@ static int format_converter(register buffy * odp, const char *fmt,
s = "inf";
s_len = 3;
} else {
+#ifdef HAVE_LOCALE_H
if (!lconv) {
lconv = localeconv();
}
+#endif
s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
- (*fmt == 'f')?(*lconv->decimal_point):'.',
+ (*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
&is_negative, &num_buf[1], &s_len);
if (is_negative)
prefix_char = '-';
@@ -994,10 +1001,12 @@ static int format_converter(register buffy * odp, const char *fmt,
/*
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
+#ifdef HAVE_LOCALE_H
if (!lconv) {
lconv = localeconv();
}
- s = php_gcvt(fp_num, precision, *lconv->decimal_point, (*fmt == 'G')?'E':'e', &num_buf[1]);
+#endif
+ 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)