]> granicus.if.org Git - php/commitdiff
Fix in grapheme_extract
authorKirti Velankar <kirtig@php.net>
Mon, 27 Apr 2009 18:18:04 +0000 (18:18 +0000)
committerKirti Velankar <kirtig@php.net>
Mon, 27 Apr 2009 18:18:04 +0000 (18:18 +0000)
ext/intl/grapheme/grapheme_string.c
ext/intl/tests/grapheme.phpt

index 06388e312f4be3a83dd797f00ebb91dac8a3f533..edac518c6e3556b9ae84ecda312a681bc1194d7b 100755 (executable)
@@ -852,10 +852,11 @@ PHP_FUNCTION(grapheme_extract)
         */
        
        if ( -1 != grapheme_ascii_check(pstr, size + 1 < str_len ? size + 1 : str_len ) ) {
+        long nsize = ( size < str_len ? size : str_len ); 
                if ( NULL != next ) {
-                       ZVAL_LONG(next, start+size);
+                       ZVAL_LONG(next, start+nsize);
                }
-               RETURN_STRINGL(((char *)pstr), size, 1);
+               RETURN_STRINGL(((char *)pstr), nsize, 1);
        }
 
        /* convert the strings to UTF-16. */
index c9982b16f4cc1a1c6b6fc8be2b9c8bf33b446c56..d65c90900d00e455ab1835d50158f6f99da92077 100755 (executable)
@@ -560,7 +560,7 @@ function ut_main()
                array( "abc", 1, 1, 2, "b" ),
                array( "abc", 1, 2, 3, "c" ),
                array( "abc", 0, 2, 2, "" ),
-
+        array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ),
 
                array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ),
                array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ),
@@ -1095,6 +1095,7 @@ extract from "abc" "1" graphemes - grapheme_extract starting at byte position 0
 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 1 with $next = b == b $next=2 == 2 
 extract from "abc" "1" graphemes - grapheme_extract starting at byte position 2 with $next = c == c $next=3 == 3 
 extract from "abc" "0" graphemes - grapheme_extract starting at byte position 2 with $next =  ==  $next=2 == 2 
+extract from "http%3A%2F%2Fnews.bbc.co.uk%2F2%2Fhi%2Fmiddle_east%2F7831588.stm" "48" graphemes - grapheme_extract starting at byte position 48 with $next = tm == tm $next=50 == 50 
 extract from "a%CC%8Abc" "3" graphemes - grapheme_extract = a%CC%8Abc == a%CC%8Abc
 extract from "a%CC%8Abc" "2" graphemes - grapheme_extract = a%CC%8Ab == a%CC%8Ab
 extract from "a%CC%8Abc" "1" graphemes - grapheme_extract = a%CC%8A == a%CC%8A