derick Mon Nov 15 08:42:22 2004 EDT Modified files: /php-src configure.in /php-src/ext/standard formatted_print.c /php-src/main php.h php_sprintf.c snprintf.c snprintf.h Log: - MFH4.3: Cleaned up some of the locale mess: * all internal use of sprintf, snprintf and the like will always use the . as thousands seperator (if php.h is included only!). * echo, printf() and sprintf() always render locale-aware * added the %F modifier for non-locale aware rendering for floats http://cvs.php.net/diff.php/php-src/configure.in?r1=1.525&r2=1.526&ty=u Index: php-src/configure.in diff -u php-src/configure.in:1.525 php-src/configure.in:1.526 --- php-src/configure.in:1.525 Wed Nov 3 18:36:49 2004 +++ php-src/configure.in Mon Nov 15 08:42:21 2004 @@ -1,4 +1,4 @@ -dnl ## $Id: configure.in,v 1.525 2004/11/03 23:36:49 derick Exp $ -*- autoconf -*- +dnl ## $Id: configure.in,v 1.526 2004/11/15 13:42:21 derick Exp $ -*- autoconf -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -619,8 +619,8 @@ AC_REPLACE_FUNCS(strlcat strlcpy getopt) AC_FUNC_UTIME_NULL AC_FUNC_ALLOCA -PHP_AC_BROKEN_SPRINTF -PHP_AC_BROKEN_SNPRINTF +dnl PHP_AC_BROKEN_SPRINTF +dnl PHP_AC_BROKEN_SNPRINTF PHP_DECLARED_TIMEZONE PHP_TIME_R_TYPE PHP_READDIR_R_TYPE http://cvs.php.net/diff.php/php-src/ext/standard/formatted_print.c?r1=1.79&r2=1.80&ty=u Index: php-src/ext/standard/formatted_print.c diff -u php-src/ext/standard/formatted_print.c:1.79 php-src/ext/standard/formatted_print.c:1.80 --- php-src/ext/standard/formatted_print.c:1.79 Wed Nov 3 18:36:50 2004 +++ php-src/ext/standard/formatted_print.c Mon Nov 15 08:42:21 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.79 2004/11/03 23:36:50 derick Exp $ */ +/* $Id: formatted_print.c,v 1.80 2004/11/15 13:42:21 derick Exp $ */ #include <math.h> /* modf() */ #include "php.h" @@ -303,13 +303,14 @@ char *cvt; register int i = 0, j = 0; int sign, decpt, cvt_len; + char decimal_point = '.'; #ifdef HAVE_LOCALE_H struct lconv lc; - char decimal_point; + char locale_decimal_point; localeconv_r(&lc); - decimal_point = (lc.decimal_point)[0]; + locale_decimal_point = (lc.decimal_point)[0]; #else - char decimal_point = '.'; + char locale_decimal_point = '.'; #endif PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", @@ -343,12 +344,12 @@ numbuf[i++] = '+'; } - if (fmt == 'f') { + if (fmt == 'f' || fmt == 'F') { if (decpt <= 0) { numbuf[i++] = '0'; if (precision > 0) { int k = precision; - numbuf[i++] = decimal_point; + numbuf[i++] = fmt == 'F' ? decimal_point : locale_decimal_point; while ((decpt++ < 0) && k--) { numbuf[i++] = '0'; } @@ -358,7 +359,7 @@ numbuf[i++] = j < cvt_len ? cvt[j++] : '0'; } if (precision > 0) { - numbuf[i++] = decimal_point; + numbuf[i++] = fmt == 'F' ? decimal_point : locale_decimal_point; while (precision-- > 0) { numbuf[i++] = j < cvt_len ? cvt[j++] : '0'; } @@ -697,6 +698,7 @@ case 'e': case 'f': + case 'F': /* XXX not done */ convert_to_double(tmp); php_sprintf_appenddouble(&result, &outpos, &size, http://cvs.php.net/diff.php/php-src/main/php.h?r1=1.206&r2=1.207&ty=u Index: php-src/main/php.h diff -u php-src/main/php.h:1.206 php-src/main/php.h:1.207 --- php-src/main/php.h:1.206 Tue Nov 2 12:03:19 2004 +++ php-src/main/php.h Mon Nov 15 08:42:22 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.206 2004/11/02 17:03:19 andrey Exp $ */ +/* $Id: php.h,v 1.207 2004/11/15 13:42:22 derick Exp $ */ #ifndef PHP_H #define PHP_H @@ -37,10 +37,8 @@ #include "zend_API.h" -#if PHP_BROKEN_SPRINTF #undef sprintf #define sprintf php_sprintf -#endif /* PHP's DEBUG value must match Zend's ZEND_DEBUG value */ #undef PHP_DEBUG @@ -228,9 +226,7 @@ #define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC #define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF #include "snprintf.h" -#endif #include "spprintf.h" #define EXEC_INPUT_BUF 4096 http://cvs.php.net/diff.php/php-src/main/php_sprintf.c?r1=1.17&r2=1.18&ty=u Index: php-src/main/php_sprintf.c diff -u php-src/main/php_sprintf.c:1.17 php-src/main/php_sprintf.c:1.18 --- php-src/main/php_sprintf.c:1.17 Thu Jan 8 03:17:54 2004 +++ php-src/main/php_sprintf.c Mon Nov 15 08:42:22 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sprintf.c,v 1.17 2004/01/08 08:17:54 andi Exp $ */ +/* $Id: php_sprintf.c,v 1.18 2004/11/15 13:42:22 derick Exp $ */ #include <stdio.h> #include <stdarg.h> @@ -26,8 +26,6 @@ #include "php_config.h" #endif -#if PHP_BROKEN_SPRINTF - int php_sprintf (char*s, const char* format, ...) { @@ -43,8 +41,6 @@ return strlen (s); } -#endif /* PHP_BROKEN_SPRINTF */ - /* * Local variables: * tab-width: 4 http://cvs.php.net/diff.php/php-src/main/snprintf.c?r1=1.34&r2=1.35&ty=u Index: php-src/main/snprintf.c diff -u php-src/main/snprintf.c:1.34 php-src/main/snprintf.c:1.35 --- php-src/main/snprintf.c:1.34 Thu Apr 15 19:08:22 2004 +++ php-src/main/snprintf.c Mon Nov 15 08:42:22 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.c,v 1.34 2004/04/15 23:08:22 helly Exp $ */ +/* $Id: snprintf.c,v 1.35 2004/11/15 13:42:22 derick Exp $ */ /* ==================================================================== * Copyright (c) 1995-1998 The Apache Group. All rights reserved. @@ -466,8 +466,6 @@ return (buf); } -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF - /* * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions * @@ -1157,8 +1155,6 @@ return (cc); } -#endif /* HAVE_SNPRINTF */ - /* * Local variables: * tab-width: 4 http://cvs.php.net/diff.php/php-src/main/snprintf.h?r1=1.27&r2=1.28&ty=u Index: php-src/main/snprintf.h diff -u php-src/main/snprintf.h:1.27 php-src/main/snprintf.h:1.28 --- php-src/main/snprintf.h:1.27 Thu Jan 8 12:33:04 2004 +++ php-src/main/snprintf.h Mon Nov 15 08:42:22 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.h,v 1.27 2004/01/08 17:33:04 sniper Exp $ */ +/* $Id: snprintf.h,v 1.28 2004/11/15 13:42:22 derick Exp $ */ /* @@ -64,20 +64,14 @@ #ifndef SNPRINTF_H #define SNPRINTF_H -#if !defined(HAVE_SNPRINTF) || PHP_BROKEN_SNPRINTF int ap_php_snprintf(char *, size_t, const char *, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); #define snprintf ap_php_snprintf -#endif -#if !defined(HAVE_VSNPRINTF) || PHP_BROKEN_VSNPRINTF int ap_php_vsnprintf(char *, size_t, const char *, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0); #define vsnprintf ap_php_vsnprintf -#endif -#if PHP_BROKEN_SPRINTF int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); #define sprintf php_sprintf -#endif typedef enum { NO = 0, YES = 1
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php