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

ruby-changes:41968

From: nagachika <ko1@a...>
Date: Wed, 9 Mar 2016 04:19:26 +0900 (JST)
Subject: [ruby-changes:41968] nagachika:r54042 (ruby_2_2): merge revision(s) 53435: [Backport #11945]

nagachika	2016-03-09 04:19:22 +0900 (Wed, 09 Mar 2016)

  New Revision: 54042

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

  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_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/ext/stringio/stringio.c
    branches/ruby_2_2/test/stringio/test_stringio.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ext/stringio/stringio.c
===================================================================
--- ruby_2_2/ext/stringio/stringio.c	(revision 54041)
+++ ruby_2_2/ext/stringio/stringio.c	(revision 54042)
@@ -497,7 +497,17 @@ strio_set_lineno(VALUE self, VALUE linen https://github.com/ruby/ruby/blob/trunk/ruby_2_2/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
 
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 54041)
+++ ruby_2_2/version.h	(revision 54042)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.5"
 #define RUBY_RELEASE_DATE "2016-03-09"
-#define RUBY_PATCHLEVEL 246
+#define RUBY_PATCHLEVEL 247
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/test/stringio/test_stringio.rb
===================================================================
--- ruby_2_2/test/stringio/test_stringio.rb	(revision 54041)
+++ ruby_2_2/test/stringio/test_stringio.rb	(revision 54042)
@@ -586,4 +586,13 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_2/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_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 54041)
+++ ruby_2_2/ChangeLog	(revision 54042)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Wed Mar  9 04:15:20 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]
+
 Wed Mar  9 04:05:36 2016  Eric Wong  <e@8...>
 
 	* io.c (io_getpartial): remove unused kwarg from template

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


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

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