felipe Fri Feb 1 12:28:44 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/standard string.c basic_functions.c
Log:
MFH: New parameter 'before_needle'
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.69.2.13&r2=1.445.2.14.2.69.2.14&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.445.2.14.2.69.2.13
php-src/ext/standard/string.c:1.445.2.14.2.69.2.14
--- php-src/ext/standard/string.c:1.445.2.14.2.69.2.13 Fri Jan 25 01:31:10 2008
+++ php-src/ext/standard/string.c Fri Feb 1 12:28:43 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.445.2.14.2.69.2.13 2008/01/25 01:31:10 iliaa Exp $ */
+/* $Id: string.c,v 1.445.2.14.2.69.2.14 2008/02/01 12:28:43 felipe Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -1687,7 +1687,7 @@
}
/* }}} */
-/* {{{ proto string stristr(string haystack, string needle)
+/* {{{ proto string stristr(string haystack, string needle[, bool part])
Finds first occurrence of a string within another, case insensitive */
PHP_FUNCTION(stristr)
{
@@ -1696,9 +1696,10 @@
int found_offset;
char *haystack_orig;
char needle_char[2];
+ zend_bool part = 0;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &haystack,
&needle) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|b", &haystack,
&needle, &part) == FAILURE) {
+ return;
}
SEPARATE_ZVAL(haystack);
@@ -1732,7 +1733,11 @@
if (found) {
found_offset = found - Z_STRVAL_PP(haystack);
- RETVAL_STRINGL(haystack_orig + found_offset,
Z_STRLEN_PP(haystack) - found_offset, 1);
+ if (part) {
+ RETVAL_STRINGL(haystack_orig, found_offset, 1);
+ } else {
+ RETVAL_STRINGL(haystack_orig + found_offset,
Z_STRLEN_PP(haystack) - found_offset, 1);
+ }
} else {
RETVAL_FALSE;
}
@@ -1741,7 +1746,7 @@
}
/* }}} */
-/* {{{ proto string strstr(string haystack, string needle)
+/* {{{ proto string strstr(string haystack, string needle[, bool part])
Finds first occurrence of a string within another */
PHP_FUNCTION(strstr)
{
@@ -1749,9 +1754,10 @@
char *found = NULL;
char needle_char[2];
long found_offset;
+ zend_bool part = 0;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &haystack,
&needle) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|b", &haystack,
&needle, &part) == FAILURE) {
+ return;
}
convert_to_string_ex(haystack);
@@ -1779,7 +1785,11 @@
if (found) {
found_offset = found - Z_STRVAL_PP(haystack);
- RETURN_STRINGL(found, Z_STRLEN_PP(haystack) - found_offset, 1);
+ if (part) {
+ RETURN_STRINGL(Z_STRVAL_PP(haystack), found_offset, 1);
+ } else {
+ RETURN_STRINGL(found, Z_STRLEN_PP(haystack) -
found_offset, 1);
+ }
} else {
RETURN_FALSE;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.64.2.16&r2=1.725.2.31.2.64.2.17&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.16
php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.17
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.16 Sat Jan 19
19:27:21 2008
+++ php-src/ext/standard/basic_functions.c Fri Feb 1 12:28:44 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.16 2008/01/19 19:27:21 davidc
Exp $ */
+/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.17 2008/02/01 12:28:44 felipe
Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -2536,15 +2536,17 @@
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO(arginfo_stristr, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_stristr, 0, 0, 2)
ZEND_ARG_INFO(0, haystack)
ZEND_ARG_INFO(0, needle)
+ ZEND_ARG_INFO(0, part)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO(arginfo_strstr, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_strstr, 0, 0, 2)
ZEND_ARG_INFO(0, haystack)
ZEND_ARG_INFO(0, needle)
+ ZEND_ARG_INFO(0, part)
ZEND_END_ARG_INFO()
static
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php