ruby-changes:28004
From: usa <ko1@a...>
Date: Tue, 2 Apr 2013 13:13:42 +0900 (JST)
Subject: [ruby-changes:28004] usa:r40056 (ruby_1_9_3): merge revision(s) 35112,35121: [Backport #6190]
usa 2013-04-02 13:13:32 +0900 (Tue, 02 Apr 2013) New Revision: 40056 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40056 Log: merge revision(s) 35112,35121: [Backport #6190] * transcode.c (str_encode_bang, encoded_dup): if nothing was transcoded, just set encoding but leave coderange unchanged as forcee_encoding. [ruby-core:43557][Bug #6190] * transcode.c (documentation for str_encode): Explain that transcoding to the same encoding is a no-op (i.e. no exceptions, no replacements,...). [ruby-core:43557][Bug #6190] Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/ruby/test_m17n.rb branches/ruby_1_9_3/transcode.c branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 40055) +++ ruby_1_9_3/ChangeLog (revision 40056) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Tue Apr 2 13:13:19 2013 Martin Duerst <duerst@i...> + + * transcode.c (documentation for str_encode): Explain + that transcoding to the same encoding is a no-op + (i.e. no exceptions, no replacements,...). + [ruby-core:43557][Bug #6190] + +Tue Apr 2 13:13:19 2013 Nobuyoshi Nakada <nobu@r...> + + * transcode.c (str_encode_bang, encoded_dup): if nothing was + transcoded, just set encoding but leave coderange unchanged as + forcee_encoding. [ruby-core:43557][Bug #6190] + Tue Apr 2 13:07:29 2013 Tanaka Akira <akr@f...> * time.c (num_exact): use to_r method only if to_int method is Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 40055) +++ ruby_1_9_3/version.h (revision 40056) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 407 +#define RUBY_PATCHLEVEL 408 #define RUBY_RELEASE_DATE "2013-04-02" #define RUBY_RELEASE_YEAR 2013 Index: ruby_1_9_3/test/ruby/test_m17n.rb =================================================================== --- ruby_1_9_3/test/ruby/test_m17n.rb (revision 40055) +++ ruby_1_9_3/test/ruby/test_m17n.rb (revision 40056) @@ -1369,6 +1369,14 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_m17n.rb#L1369 assert_equal(true, s.valid_encoding?) s << "\xff".force_encoding("utf-16be") assert_equal(false, s.valid_encoding?, bug4018) + + bug6190 = '[ruby-core:43557]' + s = "\xe9" + s = s.encode("utf-8", "utf-8") + assert_equal(false, s.valid_encoding?, bug6190) + s = "\xe9" + s.encode!("utf-8", "utf-8") + assert_equal(false, s.valid_encoding?, bug6190) end def test_getbyte Index: ruby_1_9_3/transcode.c =================================================================== --- ruby_1_9_3/transcode.c (revision 40055) +++ ruby_1_9_3/transcode.c (revision 40056) @@ -2805,6 +2805,10 @@ str_encode_bang(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/transcode.c#L2805 encidx = str_transcode(argc, argv, &newstr); if (encidx < 0) return str; + if (newstr == str) { + rb_enc_associate_index(str, encidx); + return str; + } rb_str_shared_replace(str, newstr); return str_encode_associate(str, encidx); } @@ -2831,6 +2835,10 @@ static VALUE encoded_dup(VALUE newstr, V https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/transcode.c#L2835 * in the source encoding. The last form by default does not raise * exceptions but uses replacement strings. * + * Please note that conversion from an encoding +enc+ to the + * same encoding +enc+ is a no-op, i.e. the receiver is returned without + * any changes, and no exceptions are raised, even if there are invalid bytes. + * * The +options+ Hash gives details for conversion and can have the following * keys: * @@ -2891,6 +2899,8 @@ encoded_dup(VALUE newstr, VALUE str, int https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/transcode.c#L2899 if (encidx < 0) return rb_str_dup(str); if (newstr == str) { newstr = rb_str_dup(str); + rb_enc_associate_index(newstr, encidx); + return newstr; } else { RBASIC(newstr)->klass = rb_obj_class(str); Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r35112,35121 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/