masugata Mon Jul 17 04:48:17 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/mbstring mbstring.c
Log:
added option parameter mb_strrpos( ).
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.224.2.22.2.8&r2=1.224.2.22.2.9&diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.224.2.22.2.8
php-src/ext/mbstring/mbstring.c:1.224.2.22.2.9
--- php-src/ext/mbstring/mbstring.c:1.224.2.22.2.8 Fri Jun 16 16:45:46 2006
+++ php-src/ext/mbstring/mbstring.c Mon Jul 17 04:48:17 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.224.2.22.2.8 2006/06/16 16:45:46 masugata Exp $ */
+/* $Id: mbstring.c,v 1.224.2.22.2.9 2006/07/17 04:48:17 masugata Exp $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -1632,7 +1632,7 @@
}
/* }}} */
-/* {{{ proto int mb_strrpos(string haystack, string needle [, string encoding])
+/* {{{ proto int mb_strrpos(string haystack, string needle [, int offset [,
string encoding]])
Find the last occurrence of a character in a string within another */
PHP_FUNCTION(mb_strrpos)
{
@@ -1640,6 +1640,10 @@
mbfl_string haystack, needle;
char *enc_name = NULL;
int enc_name_len;
+ zval *zoffset;
+ long offset = 0, str_flg;
+ char *enc_name2 = NULL;
+ int enc_name_len2;
mbfl_string_init(&haystack);
mbfl_string_init(&needle);
@@ -1648,10 +1652,51 @@
needle.no_language = MBSTRG(current_language);
needle.no_encoding = MBSTRG(current_internal_encoding);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", (char
**)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &enc_name,
&enc_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zs", (char
**)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &zoffset,
&enc_name, &enc_name_len) == FAILURE) {
RETURN_FALSE;
}
+ if(ZEND_NUM_ARGS() >= 3) {
+ if (Z_TYPE_P(zoffset) == IS_STRING) {
+ enc_name2 = Z_STRVAL_P(zoffset);
+ enc_name_len2 = Z_STRLEN_P(zoffset);
+ str_flg = 1;
+
+ if (enc_name2 != NULL) {
+ switch (*enc_name2) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ' ':
+ case '-':
+ case '.':
+ break;
+ default :
+ str_flg = 0;
+ break;
+ }
+ }
+
+ if(str_flg) {
+ convert_to_long(zoffset);
+ offset = Z_LVAL_P(zoffset);
+ } else {
+ enc_name = enc_name2;
+ enc_name_len = enc_name_len2;
+ }
+ } else {
+ convert_to_long(zoffset);
+ offset = Z_LVAL_P(zoffset);
+ }
+ }
+
if (enc_name != NULL) {
haystack.no_encoding = needle.no_encoding =
mbfl_name2no_encoding(enc_name);
if (haystack.no_encoding == mbfl_no_encoding_invalid) {
@@ -1668,7 +1713,7 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
- n = mbfl_strpos(&haystack, &needle, 0, 1);
+ n = mbfl_strpos(&haystack, &needle, offset, 1);
if (n >= 0) {
RETVAL_LONG(n);
} else {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php