From: Moriyoshi Koizumi Date: Fri, 1 Aug 2008 22:58:20 +0000 (+0000) Subject: - MFH: Fixed bug #43993 (mb_substr_count() behaves differently to substr_count()... X-Git-Tag: php-5.2.7RC1~154 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=840e508dc64a8de4891c7dab745d839362347091;p=php - MFH: Fixed bug #43993 (mb_substr_count() behaves differently to substr_count() with overlapping needles) --- diff --git a/NEWS b/NEWS index 9c539ddde5..95118e9674 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,8 @@ PHP NEWS (Dmitry, Tony) - Fixed bug #44127 (UNIX abstract namespace socket connect does not work). (Jani) +- Fixed bug #43993 (mb_substr_count() behaves differently to substr_count() with + overlapping needles). (Moriyoshi) - Fixed bug #41348 (OCI8: allow compilation with Oracle 8.1). (Chris Jones) 01 May 2008, PHP 5.2.6 diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c index 97d2f048cc..50a0853665 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c @@ -1013,6 +1013,7 @@ mbfl_substr_count( if (pc.matched_pos >= 0) { ++result; pc.matched_pos = -1; + pc.needle_pos = 0; } n--; } diff --git a/ext/mbstring/tests/bug43993.phpt b/ext/mbstring/tests/bug43993.phpt new file mode 100644 index 0000000000..662045d3a9 --- /dev/null +++ b/ext/mbstring/tests/bug43993.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #43993 (mb_substr_count() behaves differently to substr_count() with overlapping needles) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(1) +int(3) +int(2) +int(3) +int(4) +int(5) +int(0) +int(10) +int(0)