moriyoshi               Mon Oct  7 12:46:43 2002 EDT

  Modified files:              
    /php4/ext/mbstring  php_mbregex.c 
  Log:
  fixed mb_split (the value of third parameter treated wrongly)
  
  
Index: php4/ext/mbstring/php_mbregex.c
diff -u php4/ext/mbstring/php_mbregex.c:1.10 php4/ext/mbstring/php_mbregex.c:1.11
--- php4/ext/mbstring/php_mbregex.c:1.10        Mon Oct  7 12:15:36 2002
+++ php4/ext/mbstring/php_mbregex.c     Mon Oct  7 12:46:42 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mbregex.c,v 1.10 2002/10/07 16:15:36 moriyoshi Exp $ */
+/* $Id: php_mbregex.c,v 1.11 2002/10/07 16:46:42 moriyoshi Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -552,6 +552,8 @@
                break;
        }
 
+       if (count == 0) count = 1; 
+
        if (array_init(return_value) == FAILURE) {
                RETURN_FALSE;
        }
@@ -574,7 +576,7 @@
        pos = 0;
        err = 0;
        /* churn through str, generating array entries as we go */
-       while ((count != 0) &&
+       while ((--count != 0) &&
                   (err = mbre_search(&re, string, string_len, pos, string_len - pos, 
&regs)) >= 0) {
                if ( regs.beg[0] == regs.end[0] ) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular 
expression");
@@ -583,7 +585,7 @@
 
                n = regs.beg[0];
                /* add it to the array */
-               if (n < string_len && n <= pos) {
+               if (n < string_len && n >= pos) {
                        n -= pos;
                        add_next_index_stringl(return_value, &string[pos], n, 1);
                } else {
@@ -597,10 +599,8 @@
                } else {
                        pos++;
                }
-               /* if we're only looking for a certain number of points,
-                  stop looking once we hit it */
-               if (count > 0) {
-                       count--;
+               if (count < 0) {
+                       count = 0;
                }
        }
 



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

Reply via email to