ruby-changes:4149
From: ko1@a...
Date: Fri, 29 Feb 2008 15:19:44 +0900 (JST)
Subject: [ruby-changes:4149] matz - Ruby:r15639 (trunk): * string.c (rb_str_rpartition): calculation was done in byte indexing.
matz 2008-02-29 15:19:21 +0900 (Fri, 29 Feb 2008) New Revision: 15639 Modified files: trunk/ChangeLog trunk/string.c trunk/test/ruby/test_m17n_comb.rb Log: * 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. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n_comb.rb?r1=15639&r2=15638&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=15639&r2=15638&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15639&r2=15638&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15638) +++ ChangeLog (revision 15639) @@ -1,3 +1,10 @@ +Fri Feb 29 15:16:31 2008 Yukihiro Matsumoto <matz@r...> + + * 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@r...> * parse.y (opt_block_param): command can start just after block param Index: string.c =================================================================== --- string.c (revision 15638) +++ string.c (revision 15639) @@ -1144,6 +1144,7 @@ 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 @@ } #endif +/* byte offset to char offset */ long rb_str_sublen(VALUE str, long pos) { @@ -6036,10 +6038,9 @@ 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))); } /* Index: test/ruby/test_m17n_comb.rb =================================================================== --- test/ruby/test_m17n_comb.rb (revision 15638) +++ test/ruby/test_m17n_comb.rb (revision 15639) @@ -1563,6 +1563,8 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/