[前][次][番号順一覧][スレッド一覧]

ruby-changes:42279

From: naruse <ko1@a...>
Date: Tue, 29 Mar 2016 14:00:49 +0900 (JST)
Subject: [ruby-changes:42279] naruse:r54353 (ruby_2_3): merge revision(s) 53435: [Backport #11945]

naruse	2016-03-29 14:00:42 +0900 (Tue, 29 Mar 2016)

  New Revision: 54353

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54353

  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_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/ext/stringio/stringio.c
    branches/ruby_2_3/test/stringio/test_stringio.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 54352)
+++ ruby_2_3/ChangeLog	(revision 54353)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Tue Mar 29 13:56:36 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]
+
 Tue Mar 29 13:50:30 2016  Eric Wong  <e@8...>
 
 	* io.c (io_getpartial): remove unused kwarg from template
Index: ruby_2_3/test/stringio/test_stringio.rb
===================================================================
--- ruby_2_3/test/stringio/test_stringio.rb	(revision 54352)
+++ ruby_2_3/test/stringio/test_stringio.rb	(revision 54353)
@@ -644,4 +644,13 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/stringio/test_stringio.rb#L644
     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_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 54352)
+++ ruby_2_3/version.h	(revision 54353)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.0"
 #define RUBY_RELEASE_DATE "2016-03-29"
-#define RUBY_PATCHLEVEL 11
+#define RUBY_PATCHLEVEL 12
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_3/ext/stringio/stringio.c
===================================================================
--- ruby_2_3/ext/stringio/stringio.c	(revision 54352)
+++ ruby_2_3/ext/stringio/stringio.c	(revision 54353)
@@ -493,7 +493,18 @@ strio_set_lineno(VALUE self, VALUE linen https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/stringio/stringio.c#L493
     return lineno;
 }
 
-#define strio_binmode strio_self
+static VALUE
+strio_binmode(VALUE self)
+{
+    struct StringIO *ptr = StringIO(self);
+    rb_encoding *enc = rb_ascii8bit_encoding();
+
+    ptr->enc = enc;
+    if (WRITABLE(self)) {
+	rb_enc_associate(ptr->string, enc);
+    }
+    return self;
+}
 
 #define strio_fcntl strio_unimpl
 

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53435


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]