moriyoshi Mon Oct 7 12:48:16 2002 EDT Modified files: (Branch: PHP_4_3) /php4/ext/mbstring php_mbregex.c Log: fixed mb_split() Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.5.2.3 php4/ext/mbstring/php_mbregex.c:1.5.2.4 --- php4/ext/mbstring/php_mbregex.c:1.5.2.3 Mon Oct 7 12:17:22 2002 +++ php4/ext/mbstring/php_mbregex.c Mon Oct 7 12:48:15 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mbregex.c,v 1.5.2.3 2002/10/07 16:17:22 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.5.2.4 2002/10/07 16:48:15 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, ®s)) >= 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