1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@53927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2016-02-25 09:23:15 +00:00
parent 2b0014ca25
commit cfdb3f5c26
4 changed files with 27 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Thu Feb 25 18:21:55 2016 Eric Wong <e@80x24.org>
* 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@80x24.org>
* io.c (io_getpartial): remove unused kwarg from template

View file

@ -497,7 +497,17 @@ strio_set_lineno(VALUE self, VALUE lineno)
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

View file

@ -586,4 +586,13 @@ class TestStringIO < Test::Unit::TestCase
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

View file

@ -1,6 +1,6 @@
#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