cvs: php-src /ext/standard formatted_print.c /main snprintf.c spprintf.c

From: Date: Tue, 19 Dec 2006 13:13:48 +0000
Subject: cvs: php-src /ext/standard formatted_print.c /main snprintf.c spprintf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-42180@lists.php.net to get a copy of this message
dmitry Tue Dec 19 13:13:48 2006 UTC Modified files: /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.45&r2=1.46&diff_format=u Index: php-src/main/snprintf.c diff -u php-src/main/snprintf.c:1.45 php-src/main/snprintf.c:1.46 --- php-src/main/snprintf.c:1.45 Tue Dec 19 11:55:16 2006 +++ php-src/main/snprintf.c Tue Dec 19 13:13:48 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.c,v 1.45 2006/12/19 11:55:16 dmitry Exp $ */ +/* $Id: snprintf.c,v 1.46 2006/12/19 13:13:48 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 @@ -941,12 +946,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 = '-'; @@ -993,10 +1000,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.39&r2=1.40&diff_format=u Index: php-src/main/spprintf.c diff -u php-src/main/spprintf.c:1.39 php-src/main/spprintf.c:1.40 --- php-src/main/spprintf.c:1.39 Tue Dec 19 11:55:16 2006 +++ php-src/main/spprintf.c Tue Dec 19 13:13:48 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.c,v 1.39 2006/12/19 11:55:16 dmitry Exp $ */ +/* $Id: spprintf.c,v 1.40 2006/12/19 13:13:48 dmitry Exp $ */ /* This is the spprintf implementation. * It has emerged from apache snprintf. See original header: @@ -93,6 +93,9 @@ #ifdef HAVE_LOCALE_H #include <locale.h> +#define LCONV_DECIMAL_POINT (*lconv->decimal_point) +#else +#define LCONV_DECIMAL_POINT '.' #endif #include "snprintf.h" @@ -230,7 +233,9 @@ char char_buf[2]; /* for printing %% and %<unknown> */ zend_bool free_s; /* free string if allocated here */ +#ifdef HAVE_LOCALE_H struct lconv *lconv = NULL; +#endif /* * Flag variables @@ -644,12 +649,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 = '-'; @@ -696,10 +703,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/ext/standard/formatted_print.c?r1=1.90&r2=1.91&diff_format=u Index: php-src/ext/standard/formatted_print.c diff -u php-src/ext/standard/formatted_print.c:1.90 php-src/ext/standard/formatted_print.c:1.91 --- php-src/ext/standard/formatted_print.c:1.90 Tue Dec 19 11:55:16 2006 +++ php-src/ext/standard/formatted_print.c Tue Dec 19 13:13:48 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.90 2006/12/19 11:55:16 dmitry Exp $ */ +/* $Id: formatted_print.c,v 1.91 2006/12/19 13:13:48 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;

« previous php.cvs (#42180) next »