iliaa Tue Feb 11 17:47:26 2003 EDT
Modified files:
/php4/ext/standard string.c php_string.h basic_functions.c
Log:
Added strpbrk(), which is essentially a wrapper around C's strpbrk function
that allows searching through a string for a character list.
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.355 php4/ext/standard/string.c:1.356
--- php4/ext/standard/string.c:1.355 Sat Feb 8 10:26:17 2003
+++ php4/ext/standard/string.c Tue Feb 11 17:47:25 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.355 2003/02/08 15:26:17 sniper Exp $ */
+/* $Id: string.c,v 1.356 2003/02/11 22:47:25 iliaa Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -4379,6 +4379,30 @@
}
/* }}} */
+/* {{{ proto array strpbrk(string haystack, string char_list)
+ Search a string for any of a set of characters */
+PHP_FUNCTION(strpbrk)
+{
+ char *haystack, *char_list;
+ int haystack_len, char_list_len;
+ char *p;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &haystack,
+&haystack_len, &char_list, &char_list_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (!char_list_len) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The character list cannot
+be empty.");
+ RETURN_FALSE;
+ }
+
+ if ((p = strpbrk(haystack, char_list))) {
+ RETURN_STRINGL(p, (haystack + haystack_len - p), 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
/*
* Local variables:
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.70 php4/ext/standard/php_string.h:1.71
--- php4/ext/standard/php_string.h:1.70 Fri Feb 7 16:36:18 2003
+++ php4/ext/standard/php_string.h Tue Feb 11 17:47:26 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_string.h,v 1.70 2003/02/07 21:36:18 iliaa Exp $ */
+/* $Id: php_string.h,v 1.71 2003/02/11 22:47:26 iliaa Exp $ */
/* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
@@ -88,6 +88,7 @@
PHP_FUNCTION(str_shuffle);
PHP_FUNCTION(str_word_count);
PHP_FUNCTION(str_split);
+PHP_FUNCTION(strpbrk);
#ifdef HAVE_STRCOLL
PHP_FUNCTION(strcoll);
#endif
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.576
php4/ext/standard/basic_functions.c:1.577
--- php4/ext/standard/basic_functions.c:1.576 Sun Feb 9 15:43:05 2003
+++ php4/ext/standard/basic_functions.c Tue Feb 11 17:47:26 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.576 2003/02/09 20:43:05 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.577 2003/02/11 22:47:26 iliaa Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -343,6 +343,7 @@
PHP_FE(str_shuffle,
NULL)
PHP_FE(str_word_count,
NULL)
PHP_FE(str_split,
NULL)
+ PHP_FE(strpbrk,
+ NULL)
#ifdef HAVE_STRCOLL
PHP_FE(strcoll,
NULL)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php