1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00

Fixed bug in str_word_count() when charlist if specified and "word" starts

with a character found inside the charlist.
This commit is contained in:
Ilia Alshanetsky
2005-07-23 19:44:13 +00:00
parent 9859780570
commit 29bf2d3a09
2 changed files with 11 additions and 9 deletions

View File

@@ -4739,8 +4739,8 @@ PHP_FUNCTION(str_word_count)
}
while (p < e) {
if (isalpha(*p++)) {
s = p - 1;
if (isalpha(*p) || (char_list && ch[(unsigned char)*p])) {
s = ++p - 1;
while (isalpha(*p) || *p == '\'' || (*p == '-' && isalpha(*(p+1))) || (char_list && ch[(unsigned char)*p])) {
p++;
}
@@ -4761,7 +4761,9 @@ PHP_FUNCTION(str_word_count)
word_count++;
break;
}
}
} else {
p++;
}
}
if (!type) {

View File

@@ -118,7 +118,7 @@ array(6) {
[2]=>
string(1) "r"
[3]=>
string(1) "s"
string(2) "1s"
[4]=>
string(3) "bar"
[5]=>
@@ -130,7 +130,7 @@ array(5) {
[1]=>
string(3) "B4r"
[2]=>
string(1) "s"
string(2) "1s"
[3]=>
string(3) "bar"
[4]=>
@@ -181,8 +181,8 @@ array(6) {
string(1) "B"
[6]=>
string(1) "r"
[9]=>
string(1) "s"
[8]=>
string(2) "1s"
[11]=>
string(3) "bar"
[15]=>
@@ -193,8 +193,8 @@ array(5) {
string(3) "F0o"
[4]=>
string(3) "B4r"
[9]=>
string(1) "s"
[8]=>
string(2) "1s"
[11]=>
string(3) "bar"
[15]=>