derick Mon Nov 15 08:41:41 2004 EDT
Modified files: (Branch: PHP_5_0)
/php-src NEWS configure.in
/php-src/ext/standard formatted_print.c
/php-src/main php.h php_sprintf.c snprintf.c snprintf.h
Log:
- MF4.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/NEWS?r1=1.1760.2.121&r2=1.1760.2.122&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.121 php-src/NEWS:1.1760.2.122
--- php-src/NEWS:1.1760.2.121 Sun Nov 14 13:09:44 2004
+++ php-src/NEWS Mon Nov 15 08:41:40 2004
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2004, PHP 5.0.3
+- Added the %F modifier to *printf to render a non-locale-aware representation
+ of a float with the . as decimal seperator. (Derick)
- Fixed error handling in mysqli_multi_query. (Georg)
- Fixed a problem with SPL iterators aggregating the innner iterator. (Marcus)
- Extended the functionality of is_subclass_of() to accept either a class name
http://cvs.php.net/diff.php/php-src/configure.in?r1=1.514.2.14&r2=1.514.2.15&ty=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.514.2.14 php-src/configure.in:1.514.2.15
--- php-src/configure.in:1.514.2.14 Wed Nov 3 18:27:25 2004
+++ php-src/configure.in Mon Nov 15 08:41:41 2004
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.514.2.14 2004/11/03 23:27:25 derick Exp $ -*- sh
-*-
+dnl ## $Id: configure.in,v 1.514.2.15 2004/11/15 13:41:41 derick Exp $ -*- sh
-*-
dnl ## Process this file with autoconf to produce a configure script.
divert(1)
@@ -587,8 +587,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.77.2.2&r2=1.77.2.3&ty=u
Index: php-src/ext/standard/formatted_print.c
diff -u php-src/ext/standard/formatted_print.c:1.77.2.2
php-src/ext/standard/formatted_print.c:1.77.2.3
--- php-src/ext/standard/formatted_print.c:1.77.2.2 Wed Nov 3 18:27:26 2004
+++ php-src/ext/standard/formatted_print.c Mon Nov 15 08:41:41 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: formatted_print.c,v 1.77.2.2 2004/11/03 23:27:26 derick Exp $ */
+/* $Id: formatted_print.c,v 1.77.2.3 2004/11/15 13:41:41 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.203.2.1&r2=1.203.2.2&ty=u
Index: php-src/main/php.h
diff -u php-src/main/php.h:1.203.2.1 php-src/main/php.h:1.203.2.2
--- php-src/main/php.h:1.203.2.1 Tue Nov 2 12:25:13 2004
+++ php-src/main/php.h Mon Nov 15 08:41:41 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.203.2.1 2004/11/02 17:25:13 andrey Exp $ */
+/* $Id: php.h,v 1.203.2.2 2004/11/15 13:41:41 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
@@ -236,9 +234,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.17.2.1&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.17.2.1
--- 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:41:41 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.17.2.1 2004/11/15 13:41:41 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.34.2.1&ty=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.34 php-src/main/snprintf.c:1.34.2.1
--- php-src/main/snprintf.c:1.34 Thu Apr 15 19:08:22 2004
+++ php-src/main/snprintf.c Mon Nov 15 08:41:41 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.c,v 1.34 2004/04/15 23:08:22 helly Exp $ */
+/* $Id: snprintf.c,v 1.34.2.1 2004/11/15 13:41:41 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.27.2.1&ty=u
Index: php-src/main/snprintf.h
diff -u php-src/main/snprintf.h:1.27 php-src/main/snprintf.h:1.27.2.1
--- php-src/main/snprintf.h:1.27 Thu Jan 8 12:33:04 2004
+++ php-src/main/snprintf.h Mon Nov 15 08:41:41 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.h,v 1.27 2004/01/08 17:33:04 sniper Exp $ */
+/* $Id: snprintf.h,v 1.27.2.1 2004/11/15 13:41:41 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