masugata Thu Dec 21 17:26:05 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/mbstring mbstring.c
Log:
Fixed bug #39361, #39400 (mbstring function overloading problem).
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.224.2.22.2.17&r2=1.224.2.22.2.18&diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.224.2.22.2.17
php-src/ext/mbstring/mbstring.c:1.224.2.22.2.18
--- php-src/ext/mbstring/mbstring.c:1.224.2.22.2.17 Fri Nov 3 19:55:50 2006
+++ php-src/ext/mbstring/mbstring.c Thu Dec 21 17:26:05 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.224.2.22.2.17 2006/11/03 19:55:50 iliaa Exp $ */
+/* $Id: mbstring.c,v 1.224.2.22.2.18 2006/12/21 17:26:05 masugata Exp $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -1346,7 +1346,7 @@
MBSTRG(current_filter_illegal_mode) =
MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_PP(arg1);
} else {
- php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Unknown character.");
+ php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Unknown character.");
RETVAL_FALSE;
}
}
@@ -1605,11 +1605,11 @@
}
if (offset < 0 || (unsigned long)offset > haystack.len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is out of
range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not
contained in string.");
RETURN_FALSE;
}
if (needle.len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}
@@ -1639,7 +1639,7 @@
/* }}} */
/* {{{ proto int mb_strrpos(string haystack, string needle [, int offset [,
string encoding]])
- Find the last occurrence of a character in a string within another */
+ Find position of last occurrence of a string within another */
PHP_FUNCTION(mb_strrpos)
{
int n;
@@ -1712,11 +1712,9 @@
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
RETURN_FALSE;
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, offset, 1);
@@ -1770,6 +1768,10 @@
RETURN_FALSE;
}
+ if(offset > old_haystack_len){
+ RETURN_FALSE;
+ }
+
n = php_mb_stripos(1, old_haystack, old_haystack_len, old_needle,
old_needle_len, offset, from_encoding TSRMLS_CC);
if (n >= 0) {
@@ -1810,7 +1812,7 @@
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty delimiter.");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, 0, 0);
@@ -1868,11 +1870,9 @@
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
RETURN_FALSE;
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, 0, 1);
@@ -1920,6 +1920,11 @@
RETURN_FALSE;
}
+ if(!needle.len){
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty delimiter.");
+ RETURN_FALSE;
+ }
+
haystack.no_encoding = needle.no_encoding =
mbfl_name2no_encoding(from_encoding);
if (haystack.no_encoding == mbfl_no_encoding_invalid) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding
\"%s\"", from_encoding);
@@ -2033,7 +2038,7 @@
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty substring.");
RETURN_FALSE;
}
@@ -4225,6 +4230,7 @@
str[i] = ret->val;
len[i] = ret->len;
}
+
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
@@ -4334,7 +4340,6 @@
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty
haystack");
break;
}
@@ -4345,7 +4350,6 @@
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty
needle");
break;
}
@@ -4356,7 +4360,7 @@
}
if (offset < 0 || (unsigned long)offset > haystack.len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is
out of range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not
contained in string.");
break;
}
@@ -4507,6 +4511,7 @@
*to = ret->val;
*to_length = ret->len;
}
+
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php