ruby-changes:3063
From: ko1@a...
Date: 24 Dec 2007 05:14:26 +0900
Subject: [ruby-changes:3063] matz - Ruby:r14555 (trunk): * string.c (tr_trans): should associate new encoding if modified.
matz 2007-12-24 05:13:55 +0900 (Mon, 24 Dec 2007) New Revision: 14555 Modified files: trunk/ChangeLog trunk/string.c trunk/test/ruby/test_m17n.rb Log: * string.c (tr_trans): should associate new encoding if modified. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=14555&r2=14554 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14555&r2=14554 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n.rb?r1=14555&r2=14554 Index: ChangeLog =================================================================== --- ChangeLog (revision 14554) +++ ChangeLog (revision 14555) @@ -1,3 +1,7 @@ +Mon Dec 24 05:13:04 2007 Yukihiro Matsumoto <matz@r...> + + * string.c (tr_trans): should associate new encoding if modified. + Mon Dec 24 04:04:12 2007 GOTOU Yuuzou <gotoyuzo@n...> * test/net/http/test_https.rb: should rescue LoadError. Index: string.c =================================================================== --- string.c (revision 14554) +++ string.c (revision 14555) @@ -3654,8 +3654,11 @@ STR_SET_NOEMBED(str); RSTRING(str)->as.heap.aux.capa = max; } - - if (modify) return str; + + if (modify) { + rb_enc_associate(str, enc); + return str; + } return Qnil; } Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 14554) +++ test/ruby/test_m17n.rb (revision 14555) @@ -1763,11 +1763,7 @@ next end t = s1.tr(s2, s3) - if s3.empty? - assert_equal(0, t.length, desc) - next - end - assert_equal(s1.length, t.length, desc) + assert_operator(s1.length, :>=, t.length, desc) } end @@ -1799,12 +1795,7 @@ end t = nil - assert_nothing_raised(desc) { t = s1.tr_s(s2, s3) } - - if s3.empty? - assert_equal(0, t.length, desc) - next - end + assert_nothing_raised(desc) { t = s1.tr_s(s1, s3) } assert_operator(s1.length, :>=, t.length, desc) } end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml