ruby-changes:41853
From: usa <ko1@a...>
Date: Thu, 25 Feb 2016 18:22:34 +0900 (JST)
Subject: [ruby-changes:41853] usa:r53927 (ruby_2_1): merge revision(s) 53435: [Backport #11945]
usa 2016-02-25 18:23:15 +0900 (Thu, 25 Feb 2016) New Revision: 53927 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53927 Log: merge revision(s) 53435: [Backport #11945] * ext/stringio/stringio.c (strio_binmode): implement to set encoding * test/stringio/test_stringio.rb (test_binmode): new test [ruby-core:72699] [Bug #11945] Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/ext/stringio/stringio.c branches/ruby_2_1/test/stringio/test_stringio.rb branches/ruby_2_1/version.h Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 53926) +++ ruby_2_1/version.h (revision 53927) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.9" #define RUBY_RELEASE_DATE "2016-02-25" -#define RUBY_PATCHLEVEL 448 +#define RUBY_PATCHLEVEL 449 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_1/test/stringio/test_stringio.rb =================================================================== --- ruby_2_1/test/stringio/test_stringio.rb (revision 53926) +++ ruby_2_1/test/stringio/test_stringio.rb (revision 53927) @@ -586,4 +586,13 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/stringio/test_stringio.rb#L586 assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line(0){} } assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line("a",0){} } end + + def test_binmode + s = StringIO.new + s.set_encoding('utf-8') + assert_same s, s.binmode + + bug_11945 = '[ruby-core:72699] [Bug #11945]' + assert_equal Encoding::ASCII_8BIT, s.external_encoding, bug_11945 + end end Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 53926) +++ ruby_2_1/ChangeLog (revision 53927) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Thu Feb 25 18:21:55 2016 Eric Wong <e@8...> + + * ext/stringio/stringio.c (strio_binmode): implement to set encoding + * test/stringio/test_stringio.rb (test_binmode): new test + [ruby-core:72699] [Bug #11945] + Thu Feb 25 18:12:00 2016 Eric Wong <e@8...> * io.c (io_getpartial): remove unused kwarg from template Index: ruby_2_1/ext/stringio/stringio.c =================================================================== --- ruby_2_1/ext/stringio/stringio.c (revision 53926) +++ ruby_2_1/ext/stringio/stringio.c (revision 53927) @@ -497,7 +497,17 @@ strio_set_lineno(VALUE self, VALUE linen https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ext/stringio/stringio.c#L497 return lineno; } -#define strio_binmode strio_self +static VALUE +strio_binmode(VALUE self) +{ + struct StringIO *ptr = StringIO(self); + rb_encoding *enc = rb_ascii8bit_encoding(); + + if (WRITABLE(self)) { + rb_enc_associate(ptr->string, enc); + } + return self; +} #define strio_fcntl strio_unimpl Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53435 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/