jani Sun May 10 21:04:26 2009 UTC
Modified files:
/php-src/ext/mbstring mbstring.c
/php-src/ext/mbstring/tests zend_multibyte-01.phpt
zend_multibyte-02.phpt
zend_multibyte-03.phpt
zend_multibyte-04.phpt
zend_multibyte-05.phpt
zend_multibyte-06.phpt
zend_multibyte-07.phpt
zend_multibyte-08.phpt
zend_multibyte-09.phpt
zend_multibyte-10.phpt
zend_multibyte-11.phpt
zend_multibyte-12.phpt
zend_multibyte-13.phpt
zend_multibyte-14.phpt
Log:
- Fixed bug #48200 (compile failure with mbstring.c when
--enable-zend-multibyte is used)
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.321&r2=1.322&diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.321
php-src/ext/mbstring/mbstring.c:1.322
--- php-src/ext/mbstring/mbstring.c:1.321 Mon Apr 20 17:06:00 2009
+++ php-src/ext/mbstring/mbstring.c Sun May 10 21:04:26 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.321 2009/04/20 17:06:00 jani Exp $ */
+/* $Id: mbstring.c,v 1.322 2009/05/10 21:04:26 jani Exp $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -94,8 +94,14 @@
/* {{{ prototypes */
ZEND_DECLARE_MODULE_GLOBALS(mbstring)
+
static PHP_GINIT_FUNCTION(mbstring);
static PHP_GSHUTDOWN_FUNCTION(mbstring);
+
+static size_t php_mb_oddlen(const unsigned char *string, size_t length, const
char *encoding TSRMLS_DC);
+static int php_mb_encoding_converter(unsigned char **to, size_t *to_length,
const unsigned char *from, size_t from_length, const char *encoding_to, const
char *encoding_from TSRMLS_DC);
+static char* php_mb_encoding_detector(const unsigned char *arg_string, size_t
arg_length, char *arg_list TSRMLS_DC);
+static int php_mb_set_zend_encoding(TSRMLS_D);
/* }}} */
/* {{{ php_mb_default_identify_list */
@@ -866,7 +872,7 @@
#if HAVE_ONIG
/* {{{ _php_mb_compile_regex */
-void *_php_mb_compile_regex(const char *pattern TSRMLS_DC)
+static void *_php_mb_compile_regex(const char *pattern TSRMLS_DC)
{
php_mb_regex_t *retval;
OnigErrorInfo err_info;
@@ -887,7 +893,7 @@
/* }}} */
/* {{{ _php_mb_match_regex */
-int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
+static int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
{
return onig_search((php_mb_regex_t *)opaque, (const OnigUChar *)str,
(const OnigUChar*)str + str_len, (const OnigUChar *)str,
@@ -896,14 +902,14 @@
/* }}} */
/* {{{ _php_mb_free_regex */
-void _php_mb_free_regex(void *opaque)
+static void _php_mb_free_regex(void *opaque)
{
onig_free((php_mb_regex_t *)opaque);
}
/* }}} */
#elif HAVE_PCRE || HAVE_BUNDLED_PCRE
/* {{{ _php_mb_compile_regex */
-void *_php_mb_compile_regex(const char *pattern TSRMLS_DC)
+static void *_php_mb_compile_regex(const char *pattern TSRMLS_DC)
{
pcre *retval;
const char *err_str;
@@ -918,7 +924,7 @@
/* }}} */
/* {{{ _php_mb_match_regex */
-int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
+static int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
{
return pcre_exec((pcre *)opaque, NULL, str, (int)str_len, 0,
0, NULL, 0) >= 0;
@@ -926,7 +932,7 @@
/* }}} */
/* {{{ _php_mb_free_regex */
-void _php_mb_free_regex(void *opaque)
+static void _php_mb_free_regex(void *opaque)
{
pcre_free(opaque);
}
@@ -4714,7 +4720,6 @@
/* }}} */
#ifdef ZEND_MULTIBYTE
-
/* {{{ php_mb_set_zend_encoding() */
static int php_mb_set_zend_encoding(TSRMLS_D)
{
@@ -4806,9 +4811,7 @@
/* }}} */
/* {{{ int php_mb_encoding_converter() */
-static int php_mb_encoding_converter(unsigned char **to, size_t *to_length,
- const unsigned char *from, size_t from_length,
- const char *encoding_to, const char *encoding_from TSRMLS_DC)
+static int php_mb_encoding_converter(unsigned char **to, size_t *to_length,
const unsigned char *from, size_t from_length, const char *encoding_to, const
char *encoding_from TSRMLS_DC)
{
mbfl_string string, result, *ret;
enum mbfl_no_encoding from_encoding, to_encoding;
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-01.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-01.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-01.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-01.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,23 @@
+--TEST--
+zend multibyte (1)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=Shift_JIS
+mbstring.internal_encoding=Shift_JIS
+--FILE--
+<?php
+ function \\\($ø)
+ {
+ echo $ø;
+ }
+
+ \\\("h~...@\");
+?>
+--EXPECT--
+h~...@\
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-02.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-02.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-02.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-02.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,18 @@
+--TEST--
+zend multibyte (2)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=UTF-8
+mbstring.internal_encoding=CP932
+--FILE--
+<?php
+var_dump(bin2hex("ãã¹ã"));
+?>
+--EXPECT--
+string(12) "836583588367"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-03.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-03.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-03.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-03.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,18 @@
+--TEST--
+zend multibyte (3)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=UTF-8
+mbstring.internal_encoding=EUC-JP
+--FILE--
+<?php
+var_dump(bin2hex("ãã¹ã"));
+?>
+--EXPECT--
+string(12) "a5c6a5b9a5c8"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-04.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-04.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-04.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-04.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,18 @@
+--TEST--
+zend multibyte (4)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=CP932
+mbstring.internal_encoding=UTF-8
+--FILE--
+<?php
+var_dump(bin2hex("eXg"));
+?>
+--EXPECT--
+string(18) "e38386e382b9e38388"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-05.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-05.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-05.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-05.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,21 @@
+--TEST--
+zend multibyte (5)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=EUC-JP
+mbstring.internal_encoding=UTF-8
+--FILE--
+<?php
+// forcefully interpret an UTF-8 encoded string as EUC-JP and then convert it
+// back to UTF-8. There should be only a pair of consecutive bytes that is
+// valid EUC-encoded character "é´»".
+var_dump(bin2hex("ãã¹ã"));
+?>
+--EXPECT--
+string(16) "3f3f3fe9b4bb3f3f"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-06.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-06.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-06.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-06.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,19 @@
+--TEST--
+zend multibyte (6)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=EUC-JP
+mbstring.internal_encoding=CP932
+--FILE--
+<?php
+declare(encoding="UTF-8");
+var_dump(bin2hex("ãã¹ã"));
+?>
+--EXPECT--
+string(12) "836583588367"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-07.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-07.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-07.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-07.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,19 @@
+--TEST--
+zend multibyte (7)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=ISO-8859-1
+mbstring.internal_encoding=EUC-JP
+--FILE--
+<?php
+declare(encoding="UTF-8");
+var_dump(bin2hex("ãã¹ã"));
+?>
+--EXPECT--
+string(12) "a5c6a5b9a5c8"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-08.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-08.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-08.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-08.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,19 @@
+--TEST--
+zend multibyte (8)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=ISO-8859-1
+mbstring.internal_encoding=UTF-8
+--FILE--
+<?php
+declare(encoding="CP932");
+var_dump(bin2hex("eXg"));
+?>
+--EXPECT--
+string(18) "e38386e382b9e38388"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-09.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-09.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-09.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-09.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,22 @@
+--TEST--
+zend multibyte (9)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=cp1251
+mbstring.internal_encoding=UTF-8
+--FILE--
+<?php
+declare(encoding="EUC-JP");
+// forcefully interpret an UTF-8 encoded string as EUC-JP and then convert it
+// back to UTF-8. There should be only a pair of consecutive bytes that is
+// valid EUC-encoded character "é´»".
+var_dump(bin2hex("ãã¹ã"));
+?>
+--EXPECT--
+string(16) "3f3f3fe9b4bb3f3f"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-10.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-10.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-10.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-10.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,16 @@
+--TEST--
+zend multibyte (10)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--FILE--
+<?php
+declare(encoding="ISO-8859-15");
+declare(encoding="ISO-8859-1");
+?>
+--EXPECTF--
+Fatal error: Encoding declaration pragma must be the very first statement in
the script in %s on line 3
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-11.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-11.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-11.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-11.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,17 @@
+--TEST--
+zend multibyte (11)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--FILE--
+<?php
+declare(encoding="ISO-8859-15") {
+ declare(encoding="ISO-8859-1");
+}
+?>
+--EXPECTF--
+Fatal error: Encoding declaration pragma must be the very first statement in
the script in %s on line 3
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-12.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-12.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-12.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-12.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,17 @@
+--TEST--
+zend multibyte (12)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--FILE--
+<?php
+declare(encoding="ISO-8859-15");
+echo 1;
+declare(encoding="ISO-8859-1");
+?>
+--EXPECTF--
+Fatal error: Encoding declaration pragma must be the very first statement in
the script in %s on line 4
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-13.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-13.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-13.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-13.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,23 @@
+--TEST--
+zend multibyte (13)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=UTF-8
+mbstring.internal_encoding=ISO-8859-1
+--FILE--
+<?php
+var_dump(substr(file_get_contents(__FILE__), __COMPILER_HALT_OFFSET__));
+var_dump(bin2hex("äëüáéú"));
+__halt_compiler();test
+test
+--EXPECT--
+string(10) "test
+test
+"
+string(12) "e4ebfce1e9fa"
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/zend_multibyte-14.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/mbstring/tests/zend_multibyte-14.phpt
diff -u /dev/null php-src/ext/mbstring/tests/zend_multibyte-14.phpt:1.2
--- /dev/null Sun May 10 21:04:26 2009
+++ php-src/ext/mbstring/tests/zend_multibyte-14.phpt Sun May 10 21:04:26 2009
@@ -0,0 +1,23 @@
+--TEST--
+zend multibyte (14)
+--SKIPIF--
+<?php
+ini_set("mbstring.script_encoding","SJIS");
+if (ini_set("mbstring.script_encoding","SJIS") != "SJIS") {
+ die("skip zend-multibyte is not available");
+}
+?>
+--INI--
+mbstring.script_encoding=UTF-8
+mbstring.internal_encoding=UTF-8
+--FILE--
+<?php
+var_dump(substr(file_get_contents(__FILE__), __COMPILER_HALT_OFFSET__));
+var_dump(bin2hex("äëüáéú"));
+__halt_compiler();test
+test
+--EXPECT--
+string(10) "test
+test
+"
+string(24) "c3a4c3abc3bcc3a1c3a9c3ba"
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php