]> granicus.if.org Git - php/commitdiff
make strcspn() behave the same way in both Unicode and native mode (bug #42731)
authorAntony Dovgal <tony2001@php.net>
Tue, 2 Oct 2007 11:35:26 +0000 (11:35 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 2 Oct 2007 11:35:26 +0000 (11:35 +0000)
ext/standard/string.c

index bd7f49792db2aa9b717c20ffb56115939f792acf..1a11bb21768b5688fe19692343a9627fd2960e9a 100644 (file)
@@ -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++;