diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-29 06:19:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-29 06:19:21 +0000 |
commit | deff2a3e247d9dd42ac55d9ecfeb7f567aac9fd4 (patch) | |
tree | 1387dc138321fdc44b90cddcb87609889966d229 | |
parent | d14c3eb4b8dda24c6cce082da550941540d159c0 (diff) | |
download | ruby-deff2a3e247d9dd42ac55d9ecfeb7f567aac9fd4.tar.gz |
* string.c (rb_str_rpartition): calculation was done in byte indexing.
* test/ruby/test_m17n_comb.rb (TestM17NComb::test_str_start_with):
allow start_with? matching on broken strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | string.c | 7 | ||||
-rw-r--r-- | test/ruby/test_m17n_comb.rb | 2 |
3 files changed, 13 insertions, 3 deletions
@@ -1,3 +1,10 @@ +Fri Feb 29 15:16:31 2008 Yukihiro Matsumoto <matz@ruby-lang.org> + + * string.c (rb_str_rpartition): calculation was done in byte indexing. + + * test/ruby/test_m17n_comb.rb (TestM17NComb::test_str_start_with): + allow start_with? matching on broken strings. + Fri Feb 29 15:12:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * parse.y (opt_block_param): command can start just after block param @@ -1144,6 +1144,7 @@ str_nth(const char *p, const char *e, int nth, rb_encoding *enc, int singlebyte) return (char *)p; } +/* char offset to byte offset */ static int str_offset(const char *p, const char *e, int nth, rb_encoding *enc, int singlebyte) { @@ -1204,6 +1205,7 @@ str_utf8_offset(const char *p, const char *e, int nth) } #endif +/* byte offset to char offset */ long rb_str_sublen(VALUE str, long pos) { @@ -6036,10 +6038,9 @@ rb_str_rpartition(VALUE str, VALUE sep) if (regex) { sep = rb_reg_nth_match(0, rb_backref_get()); } - return rb_ary_new3(3, rb_str_subseq(str, 0, pos), + return rb_ary_new3(3, rb_str_substr(str, 0, pos), sep, - rb_str_subseq(str, pos+RSTRING_LEN(sep), - RSTRING_LEN(str)-pos-RSTRING_LEN(sep))); + rb_str_substr(str,pos+str_strlen(sep,STR_ENC_GET(sep)),RSTRING_LEN(str))); } /* diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb index 1b4f504f39..b3a5bfdc51 100644 --- a/test/ruby/test_m17n_comb.rb +++ b/test/ruby/test_m17n_comb.rb @@ -1563,6 +1563,8 @@ class TestM17NComb < Test::Unit::TestCase assert_raise(ArgumentError, desc) { s1.start_with?(s2) } next end + s1 = s1.dup.force_encoding("ASCII-8BIT") + s2 = s2.dup.force_encoding("ASCII-8BIT") if s1.length < s2.length assert_equal(false, enccall(s1, :start_with?, s2), desc) next |