diff options
| author | Andrey Hristov <andrey@php.net> | 1999-05-26 18:45:53 +0000 |
|---|---|---|
| committer | Andrey Hristov <andrey@php.net> | 1999-05-26 18:45:53 +0000 |
| commit | ff29e85724f6807bd2404d1822a3c512e3ddb656 (patch) | |
| tree | ee34151ff5f62ccf4d5f95ffb97afd38ad066bfa | |
| parent | 0062ae621834c38b7cb065e37dc8d8bbce8448f3 (diff) | |
| download | php-git-ff29e85724f6807bd2404d1822a3c512e3ddb656.tar.gz | |
Fixing a couple of long standing bugs.
| -rw-r--r-- | ext/ereg/ereg.c | 8 | ||||
| -rw-r--r-- | ext/standard/reg.c | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c index bd049e1fb0..8a7d97c9bb 100644 --- a/ext/ereg/ereg.c +++ b/ext/ereg/ereg.c @@ -563,7 +563,7 @@ PHP_FUNCTION(split) } /* churn through str, generating array entries as we go */ - while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) { + while ((count == -1 || count > 0) && !(err = regexec(&re, strp, 1, subs, 0))) { if (subs[0].rm_so == 0 && subs[0].rm_eo) { /* match is at start of string, return empty string */ add_next_index_stringl(return_value, empty_string, 0, 1); @@ -604,9 +604,11 @@ PHP_FUNCTION(split) } /* otherwise we just have one last element to add to the array */ - size = endp - strp; + if (count == -1) { + size = endp - strp; - add_next_index_stringl(return_value, strp, size, 1); + add_next_index_stringl(return_value, strp, size, 1); + } regfree(&re); diff --git a/ext/standard/reg.c b/ext/standard/reg.c index bd049e1fb0..8a7d97c9bb 100644 --- a/ext/standard/reg.c +++ b/ext/standard/reg.c @@ -563,7 +563,7 @@ PHP_FUNCTION(split) } /* churn through str, generating array entries as we go */ - while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) { + while ((count == -1 || count > 0) && !(err = regexec(&re, strp, 1, subs, 0))) { if (subs[0].rm_so == 0 && subs[0].rm_eo) { /* match is at start of string, return empty string */ add_next_index_stringl(return_value, empty_string, 0, 1); @@ -604,9 +604,11 @@ PHP_FUNCTION(split) } /* otherwise we just have one last element to add to the array */ - size = endp - strp; + if (count == -1) { + size = endp - strp; - add_next_index_stringl(return_value, strp, size, 1); + add_next_index_stringl(return_value, strp, size, 1); + } regfree(&re); |
