andrei          Fri Sep 29 21:00:08 2006 UTC

  Modified files:              
    /php-src/ext/standard       string.c 
  Log:
  Heck, might as well commit this..
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.593&r2=1.594&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.593 php-src/ext/standard/string.c:1.594
--- php-src/ext/standard/string.c:1.593 Sat Sep 23 12:22:07 2006
+++ php-src/ext/standard/string.c       Fri Sep 29 21:00:07 2006
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c,v 1.593 2006/09/23 12:22:07 tony2001 Exp $ */
+/* $Id: string.c,v 1.594 2006/09/29 21:00:07 andrei Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -2156,6 +2156,42 @@
 
 /* {{{ php_u_stristr
    Unicode version of case insensitve strstr */
+PHPAPI UChar *php_u_stristr(UChar *str, UChar *pat, int str_len, int pat_len)
+{
+       UChar *str_fold, *pat_fold;
+       int str_fold_len, pat_fold_len;
+       UChar *result, *found;
+       int offset;
+       UErrorCode status = U_ZERO_ERROR;
+
+       zend_case_fold_string(&str_fold, &str_fold_len, str, str_len, 
U_FOLD_CASE_DEFAULT, &status);
+       if (str_fold_len == str_len) {
+               zend_case_fold_string(&pat_fold, &pat_fold_len, pat, pat_len, 
U_FOLD_CASE_DEFAULT, &status);
+               found = u_strFindFirst(str_fold, str_fold_len, pat_fold, 
pat_fold_len);
+               if (found) {
+                       result = str + (found - str_fold);
+               } else {
+                       result = NULL;
+               }
+               efree(pat_fold);
+       } else {
+               usearch_setText(UG(root_search), str, str_len, &status);
+               usearch_setPattern(UG(root_search), pat, pat_len, &status);
+               usearch_setOffset(UG(root_search), 0, &status);
+
+               offset = usearch_first(UG(root_search), &status);
+               if (offset != USEARCH_DONE) {
+                       result = str + offset;
+               } else {
+                       result = NULL;
+               }
+       }
+       efree(str_fold);
+
+       return result;
+}
+
+#if 0
 PHPAPI UChar *php_u_stristr(UChar *s, UChar *t, int s_len, int t_len)
 {
        int32_t i,j, last;
@@ -2201,6 +2237,7 @@
        }
        return NULL;
 }
+#endif
 /* }}} */
 
 /* {{{ php_stristr

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to