derick Mon Nov 15 08:40:32 2004 EDT
Modified files: (Branch: PHP_4_3)
/php-src NEWS configure.in
/Zend Zend.m4 acconfig.h zend_sprintf.c
/php-src/ext/standard formatted_print.c var_unserializer.c
/php-src/main php.h php_sprintf.c snprintf.c snprintf.h
Log:
- 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.1247.2.752&r2=1.1247.2.753&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.752 php-src/NEWS:1.1247.2.753
--- php-src/NEWS:1.1247.2.752 Wed Nov 10 19:40:16 2004
+++ php-src/NEWS Mon Nov 15 08:40:28 2004
@@ -1,6 +1,8 @@
PHP 4 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2004, Version 4.3.10
+- Added the %F modifier to *printf to render a non-locale-aware representation
+ of a float with the . as decimal seperator. (Derick)
- Fixed a bug in addslashes() handling of the '\0' character. (Ilia)
- Backported Marcus' foreach() speedup patch from PHP 5.x. (Derick)
- Fixed potential problems with unserializing invalid serialize data. (Marcus)
http://cvs.php.net/diff.php/php-src/configure.in?r1=1.396.2.132&r2=1.396.2.133&ty=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.396.2.132 php-src/configure.in:1.396.2.133
--- php-src/configure.in:1.396.2.132 Wed Nov 3 18:35:57 2004
+++ php-src/configure.in Mon Nov 15 08:40:29 2004
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.396.2.132 2004/11/03 23:35:57 derick Exp $ -*- sh
-*-
+dnl ## $Id: configure.in,v 1.396.2.133 2004/11/15 13:40:29 derick Exp $ -*- sh
-*-
dnl ## Process this file with autoconf to produce a configure script.
divert(1)
@@ -570,8 +570,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/Zend/Zend.m4?r1=1.35.2.6&r2=1.35.2.7&ty=u
Index: Zend/Zend.m4
diff -u Zend/Zend.m4:1.35.2.6 Zend/Zend.m4:1.35.2.7
--- Zend/Zend.m4:1.35.2.6 Tue Oct 7 18:49:27 2003
+++ Zend/Zend.m4 Mon Nov 15 08:40:30 2004
@@ -1,5 +1,5 @@
dnl
-dnl $Id: Zend.m4,v 1.35.2.6 2003/10/07 22:49:27 sniper Exp $
+dnl $Id: Zend.m4,v 1.35.2.7 2004/11/15 13:40:30 derick Exp $
dnl
dnl This file contains Zend specific autoconf functions.
dnl
@@ -66,7 +66,7 @@
AC_FUNC_MEMCMP
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass)
-AC_ZEND_BROKEN_SPRINTF
+dnl AC_ZEND_BROKEN_SPRINTF
AC_CHECK_FUNCS(finite isfinite isinf isnan)
http://cvs.php.net/diff.php/Zend/acconfig.h?r1=1.27.4.2&r2=1.27.4.3&ty=u
Index: Zend/acconfig.h
diff -u Zend/acconfig.h:1.27.4.2 Zend/acconfig.h:1.27.4.3
--- Zend/acconfig.h:1.27.4.2 Mon Mar 29 18:26:31 2004
+++ Zend/acconfig.h Mon Nov 15 08:40:30 2004
@@ -33,11 +33,7 @@
# include <strings.h>
#endif
-#if ZEND_BROKEN_SPRINTF
int zend_sprintf(char *buffer, const char *format, ...);
-#else
-# define zend_sprintf sprintf
-#endif
#include <math.h>
http://cvs.php.net/diff.php/Zend/zend_sprintf.c?r1=1.11.8.1&r2=1.11.8.2&ty=u
Index: Zend/zend_sprintf.c
diff -u Zend/zend_sprintf.c:1.11.8.1 Zend/zend_sprintf.c:1.11.8.2
--- Zend/zend_sprintf.c:1.11.8.1 Tue Dec 31 11:23:05 2002
+++ Zend/zend_sprintf.c Mon Nov 15 08:40:30 2004
@@ -26,7 +26,6 @@
# include <stdarg.h>
#endif
-#if ZEND_BROKEN_SPRINTF
int zend_sprintf(char *buffer, const char *format, ...)
{
va_list args;
@@ -37,4 +36,3 @@
return strlen(buffer);
}
-#endif
http://cvs.php.net/diff.php/php-src/ext/standard/formatted_print.c?r1=1.59.2.13&r2=1.59.2.14&ty=u
Index: php-src/ext/standard/formatted_print.c
diff -u php-src/ext/standard/formatted_print.c:1.59.2.13
php-src/ext/standard/formatted_print.c:1.59.2.14
--- php-src/ext/standard/formatted_print.c:1.59.2.13 Wed Nov 3 18:36:01 2004
+++ php-src/ext/standard/formatted_print.c Mon Nov 15 08:40:31 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: formatted_print.c,v 1.59.2.13 2004/11/03 23:36:01 derick Exp $ */
+/* $Id: formatted_print.c,v 1.59.2.14 2004/11/15 13:40:31 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';
}
@@ -472,7 +473,8 @@
* "b" integer argument is printed as binary
* "c" integer argument is printed as a single character
* "d" argument is an integer
- * "f" the argument is a float
+ * "f" the argument is a float, the decimal separator is locale-aware
+ * "F" the argument is a float, but the decimal separator is always "."
* "o" integer argument is printed as octal
* "s" argument is a string
* "x" integer argument is printed as lowercase hexadecimal
@@ -672,6 +674,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/ext/standard/var_unserializer.c?r1=1.18.4.9&r2=1.18.4.10&ty=u
Index: php-src/ext/standard/var_unserializer.c
diff -u php-src/ext/standard/var_unserializer.c:1.18.4.9
php-src/ext/standard/var_unserializer.c:1.18.4.10
--- php-src/ext/standard/var_unserializer.c:1.18.4.9 Fri Sep 24 17:57:18 2004
+++ php-src/ext/standard/var_unserializer.c Mon Nov 15 08:40:31 2004
@@ -1,5 +1,5 @@
-/* Generated by re2c 0.9.4 on Fri Sep 24 23:45:23 2004 */
-#line 1 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
+/* Generated by re2c 0.5 on Thu Nov 4 01:10:35 2004 */
+#line 1 "/dat/dev/php/php-4.3dev/ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: var_unserializer.c,v 1.18.4.9 2004/09/24 21:57:18 helly Exp $ */
+/* $Id: var_unserializer.c,v 1.18.4.10 2004/11/15 13:40:31 derick Exp $ */
#include "php.h"
#include "ext/standard/php_var.h"
@@ -111,7 +111,7 @@
#define YYMARKER marker
-#line 118 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
+#line 118
@@ -296,8 +296,6 @@
-
-#line 7 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
@@ -375,7 +373,7 @@
goto yy15;
} else {
if(yych <= '}') goto yy13;
- if(yych <= 0xBF) goto yy15;
+ if(yych <= '\277') goto yy15;
goto yy2;
}
}
@@ -389,9 +387,8 @@
if(yych == ':') goto yy80;
goto yy4;
yy4:
-#line 511 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{ return 0; }
-#line 101 "<stdout>"
+#line 511
+ { return 0; }
yy5: yych = *++YYCURSOR;
if(yych == ';') goto yy78;
goto yy4;
@@ -423,16 +420,15 @@
yych = *(YYMARKER = ++YYCURSOR);
if(yych == ':') goto yy16;
goto yy4;
-yy13: ++YYCURSOR;
+yy13: yych = *++YYCURSOR;
goto yy14;
yy14:
-#line 505 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 505
+ {
/* this is the case where we have less data than planned */
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of
serialized data");
return 0; /* not sure if it should be 0 or 1 here? */
}
-#line 142 "<stdout>"
yy15: yych = *++YYCURSOR;
goto yy4;
yy16: yych = *++YYCURSOR;
@@ -452,11 +448,11 @@
yy20: yych = *++YYCURSOR;
if(yych != '"') goto yy2;
goto yy21;
-yy21: ++YYCURSOR;
+yy21: yych = *++YYCURSOR;
goto yy22;
yy22:
-#line 424 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 424
+ {
size_t len, len2, maxlen;
int elements;
char *class_name;
@@ -536,7 +532,6 @@
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
-#line 247 "<stdout>"
yy23: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
@@ -562,18 +557,17 @@
yy27: yych = *++YYCURSOR;
if(yych != '"') goto yy2;
goto yy28;
-yy28: ++YYCURSOR;
+yy28: yych = *++YYCURSOR;
goto yy29;
yy29:
-#line 416 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 416
+ {
INIT_PZVAL(*rval);
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU,
ZEND_STANDARD_CLASS_DEF_PTR));
}
-#line 285 "<stdout>"
yy30: yych = *++YYCURSOR;
if(yych == '+') goto yy31;
if(yych <= '/') goto yy2;
@@ -594,11 +588,11 @@
yy34: yych = *++YYCURSOR;
if(yych != '{') goto yy2;
goto yy35;
-yy35: ++YYCURSOR;
+yy35: yych = *++YYCURSOR;
goto yy36;
yy36:
-#line 398 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 398
+ {
int elements = parse_iv(start + 2);
*p = YYCURSOR;
@@ -615,7 +609,6 @@
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
-#line 328 "<stdout>"
yy37: yych = *++YYCURSOR;
if(yych == '+') goto yy38;
if(yych <= '/') goto yy2;
@@ -636,11 +629,11 @@
yy41: yych = *++YYCURSOR;
if(yych != '"') goto yy2;
goto yy42;
-yy42: ++YYCURSOR;
+yy42: yych = *++YYCURSOR;
goto yy43;
yy43:
-#line 370 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 370
+ {
size_t len, maxlen;
char *str;
@@ -667,7 +660,6 @@
ZVAL_STRINGL(*rval, str, len, 1);
return 1;
}
-#line 381 "<stdout>"
yy44: yych = *++YYCURSOR;
if(yych <= '/'){
if(yych <= ','){
@@ -753,17 +745,16 @@
goto yy2;
}
}
-yy54: ++YYCURSOR;
+yy54: yych = *++YYCURSOR;
goto yy55;
yy55:
-#line 363 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 363
+ {
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_DOUBLE(*rval, atof(start + 2));
return 1;
}
-#line 479 "<stdout>"
yy56: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
@@ -820,11 +811,11 @@
yy64: yych = *++YYCURSOR;
if(yych != ';') goto yy2;
goto yy65;
-yy65: ++YYCURSOR;
+yy65: yych = *++YYCURSOR;
goto yy66;
yy66:
-#line 346 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 346
+ {
*p = YYCURSOR;
INIT_PZVAL(*rval);
#if defined(HAVE_ATOF_ACCEPTS_NAN) && defined(HAVE_ATOF_ACCEPTS_INF)
@@ -840,7 +831,6 @@
#endif
return 1;
}
-#line 558 "<stdout>"
yy67: yych = *++YYCURSOR;
if(yych == 'N') goto yy64;
goto yy2;
@@ -866,17 +856,16 @@
if(yych <= '9') goto yy70;
if(yych != ';') goto yy2;
goto yy72;
-yy72: ++YYCURSOR;
+yy72: yych = *++YYCURSOR;
goto yy73;
yy73:
-#line 339 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 339
+ {
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_LONG(*rval, parse_iv(start + 2));
return 1;
}
-#line 595 "<stdout>"
yy74: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
if(yych >= '2') goto yy2;
@@ -884,28 +873,26 @@
yy75: yych = *++YYCURSOR;
if(yych != ';') goto yy2;
goto yy76;
-yy76: ++YYCURSOR;
+yy76: yych = *++YYCURSOR;
goto yy77;
yy77:
-#line 332 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 332
+ {
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_BOOL(*rval, parse_iv(start + 2));
return 1;
}
-#line 613 "<stdout>"
-yy78: ++YYCURSOR;
+yy78: yych = *++YYCURSOR;
goto yy79;
yy79:
-#line 325 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 325
+ {
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_NULL(*rval);
return 1;
}
-#line 624 "<stdout>"
yy80: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
@@ -928,11 +915,11 @@
if(yych <= '9') goto yy82;
if(yych != ';') goto yy2;
goto yy84;
-yy84: ++YYCURSOR;
+yy84: yych = *++YYCURSOR;
goto yy85;
yy85:
-#line 304 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
-{
+#line 304
+ {
int id;
*p = YYCURSOR;
@@ -952,9 +939,8 @@
return 1;
}
-#line 672 "<stdout>"
}
-#line 513 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
+#line 513
return 0;
http://cvs.php.net/diff.php/php-src/main/php.h?r1=1.178.2.8&r2=1.178.2.9&ty=u
Index: php-src/main/php.h
diff -u php-src/main/php.h:1.178.2.8 php-src/main/php.h:1.178.2.9
--- php-src/main/php.h:1.178.2.8 Wed Sep 24 19:22:32 2003
+++ php-src/main/php.h Mon Nov 15 08:40:31 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php.h,v 1.178.2.8 2003/09/24 23:22:32 iliaa Exp $ */
+/* $Id: php.h,v 1.178.2.9 2004/11/15 13:40:31 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
@@ -230,9 +228,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.12.8.2&r2=1.12.8.3&ty=u
Index: php-src/main/php_sprintf.c
diff -u php-src/main/php_sprintf.c:1.12.8.2 php-src/main/php_sprintf.c:1.12.8.3
--- php-src/main/php_sprintf.c:1.12.8.2 Tue Feb 25 04:45:47 2003
+++ php-src/main/php_sprintf.c Mon Nov 15 08:40:31 2004
@@ -16,14 +16,12 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_sprintf.c,v 1.12.8.2 2003/02/25 09:45:47 sniper Exp $ */
+/* $Id: php_sprintf.c,v 1.12.8.3 2004/11/15 13:40:31 derick Exp $ */
#include <stdio.h>
#include <stdarg.h>
#include "php_config.h"
-#if PHP_BROKEN_SPRINTF
-
int
php_sprintf (char*s, const char* format, ...)
{
@@ -39,8 +37,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.17.4.9&r2=1.17.4.10&ty=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.17.4.9 php-src/main/snprintf.c:1.17.4.10
--- php-src/main/snprintf.c:1.17.4.9 Mon Sep 29 19:44:17 2003
+++ php-src/main/snprintf.c Mon Nov 15 08:40:31 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: snprintf.c,v 1.17.4.9 2003/09/29 23:44:17 iliaa Exp $ */
+/* $Id: snprintf.c,v 1.17.4.10 2004/11/15 13:40:31 derick Exp $ */
/* ====================================================================
* Copyright (c) 1995-1998 The Apache Group. All rights reserved.
@@ -462,8 +462,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
*
@@ -988,8 +986,6 @@
return (cc);
}
-#endif /* HAVE_SNPRINTF */
-
/*
* Local variables:
* tab-width: 4
http://cvs.php.net/diff.php/php-src/main/snprintf.h?r1=1.18.4.3&r2=1.18.4.4&ty=u
Index: php-src/main/snprintf.h
diff -u php-src/main/snprintf.h:1.18.4.3 php-src/main/snprintf.h:1.18.4.4
--- php-src/main/snprintf.h:1.18.4.3 Thu Aug 28 01:25:26 2003
+++ php-src/main/snprintf.h Mon Nov 15 08:40:31 2004
@@ -62,20 +62,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