summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2004-11-15 13:40:31 +0000
committerDerick Rethans <derick@php.net>2004-11-15 13:40:31 +0000
commit963d068fd522d3514218971d927c5a64a1c408cd (patch)
treeac69ccde2c29156c53a6a14169c509ebee167c30
parent189654d882393eb134fc8b812961b5e93bd63e76 (diff)
downloadphp-git-963d068fd522d3514218971d927c5a64a1c408cd.tar.gz
- 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
-rw-r--r--NEWS2
-rw-r--r--configure.in4
-rw-r--r--ext/standard/formatted_print.c17
-rw-r--r--ext/standard/var_unserializer.c94
-rw-r--r--main/php.h4
-rw-r--r--main/php_sprintf.c4
-rw-r--r--main/snprintf.c4
-rw-r--r--main/snprintf.h6
8 files changed, 54 insertions, 81 deletions
diff --git a/NEWS b/NEWS
index 4ca49c8fa1..1deb1a5eef 100644
--- a/NEWS
+++ b/NEWS
@@ -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)
diff --git a/configure.in b/configure.in
index d51e4df212..b7495f0f2f 100644
--- a/configure.in
+++ b/configure.in
@@ -570,8 +570,8 @@ fi
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
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index 9a5affe059..4a7d86d7c4 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -303,13 +303,14 @@ php_sprintf_appenddouble(char **buffer, int *pos,
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 @@ php_sprintf_appenddouble(char **buffer, int *pos,
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 @@ php_sprintf_appenddouble(char **buffer, int *pos,
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 @@ php_sprintf_getnumber(char *buffer, int *pos)
* "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 @@ php_formatted_print(int ht, int *len, int use_array TSRMLS_DC)
case 'e':
case 'f':
+ case 'F':
/* XXX not done */
convert_to_double(tmp);
php_sprintf_appenddouble(&result, &outpos, &size,
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 65165b9bd2..46b79bdc6b 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -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 |
@@ -111,7 +111,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
#define YYMARKER marker
-#line 118 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
+#line 118
@@ -296,8 +296,6 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
-
-#line 7 "<stdout>"
{
YYCTYPE yych;
unsigned int yyaccept;
@@ -375,7 +373,7 @@ yy0:
goto yy15;
} else {
if(yych <= '}') goto yy13;
- if(yych <= 0xBF) goto yy15;
+ if(yych <= '\277') goto yy15;
goto yy2;
}
}
@@ -389,9 +387,8 @@ yy3: yyaccept = 0;
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 @@ yy12: yyaccept = 0;
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 @@ yy19: if(yybm[0+yych] & 128) goto yy18;
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 @@ yy22:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
-#line 247 "<stdout>"
yy23: yych = *++YYCURSOR;
if(yych <= ','){
if(yych != '+') goto yy2;
@@ -562,18 +557,17 @@ yy26: if(yych <= '/') goto yy2;
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 @@ yy33: if(yych <= '/') goto yy2;
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 @@ yy36:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
-#line 328 "<stdout>"
yy37: yych = *++YYCURSOR;
if(yych == '+') goto yy38;
if(yych <= '/') goto yy2;
@@ -636,11 +629,11 @@ yy40: if(yych <= '/') goto yy2;
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 @@ yy43:
ZVAL_STRINGL(*rval, str, len, 1);
return 1;
}
-#line 381 "<stdout>"
yy44: yych = *++YYCURSOR;
if(yych <= '/'){
if(yych <= ','){
@@ -753,17 +745,16 @@ yy53: if(yych <= ';'){
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 @@ yy63: yych = *++YYCURSOR;
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 @@ yy66:
#endif
return 1;
}
-#line 558 "<stdout>"
yy67: yych = *++YYCURSOR;
if(yych == 'N') goto yy64;
goto yy2;
@@ -866,17 +856,16 @@ yy71: if(yych <= '/') goto yy2;
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 @@ yy74: yych = *++YYCURSOR;
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 @@ yy83: if(yych <= '/') goto yy2;
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 @@ yy85:
return 1;
}
-#line 672 "<stdout>"
}
-#line 513 "/usr/src/PHP_4_3_0/ext/standard/var_unserializer.re"
+#line 513
return 0;
diff --git a/main/php.h b/main/php.h
index caa59712af..1ea18721e2 100644
--- a/main/php.h
+++ b/main/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 @@ char *strerror(int);
#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
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
index 6f252c8e48..9db5c0de68 100644
--- a/main/php_sprintf.c
+++ b/main/php_sprintf.c
@@ -22,8 +22,6 @@
#include <stdarg.h>
#include "php_config.h"
-#if PHP_BROKEN_SPRINTF
-
int
php_sprintf (char*s, const char* format, ...)
{
@@ -39,8 +37,6 @@ php_sprintf (char*s, const char* format, ...)
return strlen (s);
}
-#endif /* PHP_BROKEN_SPRINTF */
-
/*
* Local variables:
* tab-width: 4
diff --git a/main/snprintf.c b/main/snprintf.c
index b9383c57da..177ef46356 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -462,8 +462,6 @@ ap_php_gcvt(double number, int ndigit, char *buf, boolean_e altform)
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 @@ int ap_php_vsnprintf(char *buf, size_t len, const char *format, va_list ap)
return (cc);
}
-#endif /* HAVE_SNPRINTF */
-
/*
* Local variables:
* tab-width: 4
diff --git a/main/snprintf.h b/main/snprintf.h
index ff92a80a6b..75ddb7968b 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -62,20 +62,14 @@ Example:
#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