From: Antony Dovgal Date: Tue, 2 Oct 2007 11:35:26 +0000 (+0000) Subject: make strcspn() behave the same way in both Unicode and native mode (bug #42731) X-Git-Tag: RELEASE_2_0_0a1~1683 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da50804c67933d553bd6b122ac8371afd36323ec;p=php make strcspn() behave the same way in both Unicode and native mode (bug #42731) --- diff --git a/ext/standard/string.c b/ext/standard/string.c index bd7f49792d..1a11bb2176 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2306,7 +2306,11 @@ PHPAPI int php_u_strcspn(UChar *s1, UChar *s2, UChar *s1_end, UChar *s2_end) for (i = 0, codepts = 0 ; i < len1 ; ) { U16_NEXT(s1, i, len1, ch); - if (!len2 || u_memchr32(s2, ch, len2)) { + if (len2) { + if (u_memchr32(s2, ch, len2)) { + break; + } + } else if (ch == (UChar32)0x00){ break; } codepts++;