mirror of
https://github.com/php/php-src.git
synced 2025-01-26 21:54:16 +08:00
- MFH: Fixed bug #43993 (mb_substr_count() behaves differently to substr_count() with overlapping needles)
This commit is contained in:
parent
c123d7fea0
commit
98b5795702
@ -1013,6 +1013,7 @@ mbfl_substr_count(
|
||||
if (pc.matched_pos >= 0) {
|
||||
++result;
|
||||
pc.matched_pos = -1;
|
||||
pc.needle_pos = 0;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
|
26
ext/mbstring/tests/bug43993.phpt
Normal file
26
ext/mbstring/tests/bug43993.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #43993 (mb_substr_count() behaves differently to substr_count() with overlapping needles)
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(mb_substr_count("abcabcabca", "abcabc"));
|
||||
var_dump(mb_substr_count("abcabcabca", "abc"));
|
||||
var_dump(mb_substr_count("abcabcabca", "cab"));
|
||||
var_dump(mb_substr_count("abcabcabca", "bca"));
|
||||
var_dump(mb_substr_count("ababababab", "ba"));
|
||||
var_dump(mb_substr_count("ababababab", "ab"));
|
||||
var_dump(mb_substr_count("ababababab", "bc"));
|
||||
var_dump(mb_substr_count("aaaaaaaaaa", "a"));
|
||||
var_dump(mb_substr_count("aaaaaaaaaa", "b"));
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(3)
|
||||
int(2)
|
||||
int(3)
|
||||
int(4)
|
||||
int(5)
|
||||
int(0)
|
||||
int(10)
|
||||
int(0)
|
Loading…
Reference in New Issue
Block a user