summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2009-04-10 16:53:35 +0000
committerStanislav Malyshev <stas@php.net>2009-04-10 16:53:35 +0000
commit5b8a5d7df4b487dcf6fca6855655f5329a54db8e (patch)
treecdf64c04f7e8594fd0dc85ae5231143956db1c21
parent70449f2e13e7acbe2d1af30a7ef293db0a282443 (diff)
downloadphp-git-5b8a5d7df4b487dcf6fca6855655f5329a54db8e.tar.gz
merge grapheme substr fix
-rwxr-xr-xext/intl/grapheme/grapheme_string.c2
-rwxr-xr-xext/intl/tests/grapheme.phpt4
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c
index 5abd33cc98..06388e312f 100755
--- a/ext/intl/grapheme/grapheme_string.c
+++ b/ext/intl/grapheme/grapheme_string.c
@@ -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 );
diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt
index b5c0bdb833..c9982b16f4 100755
--- a/ext/intl/tests/grapheme.phpt
+++ b/ext/intl/tests/grapheme.phpt
@@ -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