summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2002-10-07 16:46:42 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2002-10-07 16:46:42 +0000
commit931e25297bfcc819eaa7b48f0ace8d244b3a4ee5 (patch)
tree2a097d3c94234bda724c7cd7a017e036a7fce269 /ext/mbstring/php_mbregex.c
parentef9b51bcb04e768075898621a28cf1b5a7a1551c (diff)
downloadphp-git-931e25297bfcc819eaa7b48f0ace8d244b3a4ee5.tar.gz
fixed mb_split (the value of third parameter treated wrongly)
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 5b231212e7..57d39c8db5 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -552,6 +552,8 @@ PHP_FUNCTION(mb_split)
break;
}
+ if (count == 0) count = 1;
+
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
@@ -574,7 +576,7 @@ PHP_FUNCTION(mb_split)
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 @@ PHP_FUNCTION(mb_split)
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 @@ PHP_FUNCTION(mb_split)
} 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;
}
}