cvs: php-src(PHP_5_2) /ext/standard formatted_print.c /main snprintf.c spprintf.c
| From: | Dmitry Stogov | Date: | Tue, 19 Dec 2006 13:13:29 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/standard formatted_print.c /main snprintf.c spprintf.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-42179@lists.php.net to get a copy of this message | ||
dmitry Tue Dec 19 13:13:29 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/main snprintf.c spprintf.c
/php-src/ext/standard formatted_print.c
Log:
Support for systems without locale.h
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.c?r1=1.37.2.4.2.4&r2=1.37.2.4.2.5&diff_format=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.37.2.4.2.4 php-src/main/snprintf.c:1.37.2.4.2.5
--- php-src/main/snprintf.c:1.37.2.4.2.4 Tue Dec 19 11:54:38 2006
+++ php-src/main/snprintf.c Tue Dec 19 13:13:28 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.c,v 1.37.2.4.2.4 2006/12/19 11:54:38 dmitry Exp $ */
+/* $Id: snprintf.c,v 1.37.2.4.2.5 2006/12/19 13:13:28 dmitry Exp $ */
#include "php.h"
@@ -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 @@
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 @@
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 @@
/*
* * 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)
http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.c?r1=1.25.2.2.2.3&r2=1.25.2.2.2.4&diff_format=u
Index: php-src/main/spprintf.c
diff -u php-src/main/spprintf.c:1.25.2.2.2.3 php-src/main/spprintf.c:1.25.2.2.2.4
--- php-src/main/spprintf.c:1.25.2.2.2.3 Tue Dec 19 11:54:38 2006
+++ php-src/main/spprintf.c Tue Dec 19 13:13:28 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spprintf.c,v 1.25.2.2.2.3 2006/12/19 11:54:38 dmitry Exp $ */
+/* $Id: spprintf.c,v 1.25.2.2.2.4 2006/12/19 13:13:28 dmitry Exp $ */
/* This is the spprintf implementation.
* It has emerged from apache snprintf. See original header:
@@ -92,6 +92,9 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
+#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
+#else
+#define LCONV_DECIMAL_POINT '.'
#endif
#include "snprintf.h"
@@ -199,7 +202,9 @@
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
@@ -554,9 +559,11 @@
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):'.',
@@ -606,9 +613,11 @@
/*
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
+#ifdef HAVE_LOCALE_H
if (!lconv) {
lconv = localeconv();
}
+#endif
s = php_gcvt(fp_num, precision, *lconv->decimal_point, (*fmt ==
'G')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/formatted_print.c?r1=1.82.2.1.2.8&r2=1.82.2.1.2.9&diff_format=u
Index: php-src/ext/standard/formatted_print.c
diff -u php-src/ext/standard/formatted_print.c:1.82.2.1.2.8
php-src/ext/standard/formatted_print.c:1.82.2.1.2.9
--- php-src/ext/standard/formatted_print.c:1.82.2.1.2.8 Tue Dec 19 11:54:38 2006
+++ php-src/ext/standard/formatted_print.c Tue Dec 19 13:13:29 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: formatted_print.c,v 1.82.2.1.2.8 2006/12/19 11:54:38 dmitry Exp $ */
+/* $Id: formatted_print.c,v 1.82.2.1.2.9 2006/12/19 13:13:29 dmitry Exp $ */
#include <math.h> /* modf() */
#include "php.h"
@@ -27,6 +27,9 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
+#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
+#else
+#define LCONV_DECIMAL_POINT '.'
#endif
#define ALIGN_LEFT 0
@@ -198,7 +201,9 @@
char num_buf[NUM_BUF_SIZE];
char *s = NULL;
int s_len = 0, is_negative = 0;
+#ifdef HAVE_LOCALE_H
struct lconv *lconv;
+#endif
PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n",
*buffer, pos, size, number, width, padding, alignment, fmt));
@@ -230,9 +235,11 @@
case 'E':
case 'f':
case 'F':
+#ifdef HAVE_LOCALE_H
lconv = localeconv();
+#endif
s = php_conv_fp((fmt == 'f')?'F':fmt, number, 0, precision,
- (fmt == 'f')?(*lconv->decimal_point):'.',
+ (fmt == 'f')?LCONV_DECIMAL_POINT:'.',
&is_negative, &num_buf[1], &s_len);
if (is_negative) {
num_buf[0] = '-';
@@ -252,8 +259,10 @@
/*
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
+#ifdef HAVE_LOCALE_H
lconv = localeconv();
- s = php_gcvt(number, precision, *lconv->decimal_point, (fmt ==
'G')?'E':'e', &num_buf[1]);
+#endif
+ s = php_gcvt(number, precision, LCONV_DECIMAL_POINT, (fmt ==
'G')?'E':'e', &num_buf[1]);
is_negative = 0;
if (*s == '-') {
is_negative = 1;