iliaa Wed Oct 29 19:49:34 2003 EDT
Modified files:
/php-src NEWS
/php-src/ext/standard string.c php_string.h basic_functions.c
Log:
Added substr_compare().
Index: php-src/NEWS
diff -u php-src/NEWS:1.1484 php-src/NEWS:1.1485
--- php-src/NEWS:1.1484 Wed Oct 29 17:18:24 2003
+++ php-src/NEWS Wed Oct 29 19:49:32 2003
@@ -34,6 +34,7 @@
. array_diff_uassoc(). (Andrey)
. convert_uuencode(). (Ilia)
. convert_uudecode(). (Ilia)
+ . substr_compare(). (Ilia)
. pcntl_wait(). (GeorgeS)
- Added "resume_pos" context option to "ftp://" wrapper. (Sara)
- Added optional parameter to OCIWriteTemporaryLob() to specify the type of LOB
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.399 php-src/ext/standard/string.c:1.400
--- php-src/ext/standard/string.c:1.399 Sun Sep 28 22:23:40 2003
+++ php-src/ext/standard/string.c Wed Oct 29 19:49:33 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.399 2003/09/29 02:23:40 moriyoshi Exp $ */
+/* $Id: string.c,v 1.400 2003/10/30 00:49:33 iliaa Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -4658,6 +4658,35 @@
RETURN_STRINGL(p, (haystack + haystack_len - p), 1);
} else {
RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto int substr_compare(string main_str, string str, int offset [, int length
[, bool case_sensitivity]])
+ Binary safe optionally case insensitive comparison of 2 strings from an offset, up
to length characters */
+PHP_FUNCTION(substr_compare)
+{
+ char *s1, *s2;
+ int s1_len, s2_len;
+ long offset, len=0;
+ zend_bool cs=0;
+ uint cmp_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb", &s1, &s1_len,
&s2, &s2_len, &offset, &len, &cs) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (len && offset >= s1_len) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot
exceed initial string length.");
+ RETURN_FALSE;
+ }
+
+ cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));
+
+ if (!cs) {
+ RETURN_LONG(zend_binary_strncmp(s1 + offset, (s1_len - offset), s2,
s2_len, cmp_len));
+ } else {
+ RETURN_LONG(zend_binary_strncasecmp(s1 + offset, (s1_len - offset),
s2, s2_len, cmp_len));
}
}
/* }}} */
Index: php-src/ext/standard/php_string.h
diff -u php-src/ext/standard/php_string.h:1.79 php-src/ext/standard/php_string.h:1.80
--- php-src/ext/standard/php_string.h:1.79 Thu Jul 24 21:03:39 2003
+++ php-src/ext/standard/php_string.h Wed Oct 29 19:49:33 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_string.h,v 1.79 2003/07/25 01:03:39 pollita Exp $ */
+/* $Id: php_string.h,v 1.80 2003/10/30 00:49:33 iliaa Exp $ */
/* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
@@ -89,6 +89,7 @@
PHP_FUNCTION(str_word_count);
PHP_FUNCTION(str_split);
PHP_FUNCTION(strpbrk);
+PHP_FUNCTION(substr_compare);
#ifdef HAVE_STRCOLL
PHP_FUNCTION(strcoll);
#endif
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.636
php-src/ext/standard/basic_functions.c:1.637
--- php-src/ext/standard/basic_functions.c:1.636 Mon Oct 27 23:02:11 2003
+++ php-src/ext/standard/basic_functions.c Wed Oct 29 19:49:33 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.636 2003/10/28 04:02:11 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.637 2003/10/30 00:49:33 iliaa Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -374,6 +374,7 @@
PHP_FE(str_word_count,
NULL)
PHP_FE(str_split,
NULL)
PHP_FE(strpbrk,
NULL)
+ PHP_FE(substr_compare,
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