]> granicus.if.org Git - php/commitdiff
merge grapheme substr fix
authorStanislav Malyshev <stas@php.net>
Fri, 10 Apr 2009 16:53:35 +0000 (16:53 +0000)
committerStanislav Malyshev <stas@php.net>
Fri, 10 Apr 2009 16:53:35 +0000 (16:53 +0000)
ext/intl/grapheme/grapheme_string.c
ext/intl/tests/grapheme.phpt

index 5abd33cc985caaf36c02372cb96060404030738a..06388e312f4be3a83dd797f00ebb91dac8a3f533 100755 (executable)
@@ -542,7 +542,7 @@ PHP_FUNCTION(grapheme_substr)
                length += iter_val;
        }
        
-       if ( UBRK_DONE == sub_str_end_pos ) {
+       if ( UBRK_DONE == sub_str_end_pos && length < 0) {
        
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: length not contained in string", 1 TSRMLS_CC );
        
index b5c0bdb833b647c2c22a8fc8e3b7fb802d581dd5..c9982b16f4cc1a1c6b6fc8be2b9c8bf33b446c56 100755 (executable)
@@ -334,7 +334,9 @@ function ut_main()
                array( "abc", 0, 2, "ab" ),
                array( "Abc", -4, 1, "false" ),
                array( "ababc", 1, 2, "ba" ),
+               array( "ababc", 0, 10, "ababc" ),
                
+               array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ),
                array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ),
                array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ),
                array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ),
@@ -953,6 +955,8 @@ substring of "Abc" from "1" - grapheme_substr with length 1 = b == b
 substring of "abc" from "0" - grapheme_substr with length 2 = ab == ab
 substring of "Abc" from "-4" - grapheme_substr with length 1 = false == false
 substring of "ababc" from "1" - grapheme_substr with length 2 = ba == ba
+substring of "ababc" from "0" - grapheme_substr with length 10 = ababc == ababc
+substring of "aa%CC%8Abco%CC%88Opq" from "0" - grapheme_substr with length 10 = aa%CC%8Abco%CC%88Opq == aa%CC%8Abco%CC%88Opq
 substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr = Opq == Opq
 substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -1 = Op == Op
 substring of "aa%CC%8Abco%CC%88Opq" from "5" - grapheme_substr with length -2 = O == O