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

ruby-changes:36550

From: usa <ko1@a...>
Date: Fri, 28 Nov 2014 16:11:44 +0900 (JST)
Subject: [ruby-changes:36550] usa:r48631 (ruby_2_0_0): merge revision(s) 42709: [Backport #10529]

usa	2014-11-28 16:11:26 +0900 (Fri, 28 Nov 2014)

  New Revision: 48631

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

  Log:
    merge revision(s) 42709: [Backport #10529]
    
    * io.c (copy_stream_body): should write in binary mode.  based on a
      patch by godfat (Lin Jen-Shin) at [ruby-core:56556].
      [ruby-core:56518] [Bug #8767]
    
    * io.c (copy_stream_body): move common open flags.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/io.c
    branches/ruby_2_0_0/test/ruby/test_io.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 48630)
+++ ruby_2_0_0/ChangeLog	(revision 48631)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Fri Nov 28 16:05:09 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (copy_stream_body): should write in binary mode.  based on a
+	  patch by godfat (Lin Jen-Shin) at [ruby-core:56556].
+	  [ruby-core:56518] [Bug #8767]
+
+Fri Nov 28 16:05:09 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (copy_stream_body): move common open flags.
+
 Fri Nov 28 16:01:44 2014  NAKAMURA Usaku  <usa@r...>
 
 	* lib/rubygems/ssl_certs/AddTrustExternalCARoot{-2048,}.pem: add newer
Index: ruby_2_0_0/io.c
===================================================================
--- ruby_2_0_0/io.c	(revision 48630)
+++ ruby_2_0_0/io.c	(revision 48631)
@@ -10208,9 +10208,9 @@ copy_stream_body(VALUE arg) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/io.c#L10208
 #ifdef O_BINARY
     if (src_fptr)
 	SET_BINARY_MODE_WITH_SEEK_CUR(src_fptr);
-    if (dst_fptr)
-	setmode(dst_fd, O_BINARY);
 #endif
+    if (dst_fptr)
+	rb_io_ascii8bit_binmode(dst_io);
 
     if (stp->src_offset == (off_t)-1 && src_fptr && src_fptr->rbuf.len) {
         size_t len = src_fptr->rbuf.len;
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 48630)
+++ ruby_2_0_0/version.h	(revision 48631)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-11-28"
-#define RUBY_PATCHLEVEL 600
+#define RUBY_PATCHLEVEL 601
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 11
Index: ruby_2_0_0/test/ruby/test_io.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_io.rb	(revision 48630)
+++ ruby_2_0_0/test/ruby/test_io.rb	(revision 48631)
@@ -770,6 +770,47 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_io.rb#L770
     }
   end
 
+  def test_copy_stream_write_in_binmode
+    bug8767 = '[ruby-core:56518] [Bug #8767]'
+    mkcdtmpdir {
+      EnvUtil.with_default_internal(Encoding::UTF_8) do
+        # StringIO to object with to_path
+        bytes = "\xDE\xAD\xBE\xEF".force_encoding(Encoding::ASCII_8BIT)
+        src = StringIO.new(bytes)
+        dst = Object.new
+        def dst.to_path
+          "qux"
+        end
+        assert_nothing_raised(bug8767) {
+          IO.copy_stream(src, dst)
+        }
+        assert_equal(bytes, File.binread("qux"), bug8767)
+        assert_equal(4, src.pos, bug8767)
+      end
+    }
+  end
+
+  def test_copy_stream_read_in_binmode
+    bug8767 = '[ruby-core:56518] [Bug #8767]'
+    mkcdtmpdir {
+      EnvUtil.with_default_internal(Encoding::UTF_8) do
+        # StringIO to object with to_path
+        bytes = "\xDE\xAD\xBE\xEF".force_encoding(Encoding::ASCII_8BIT)
+        File.binwrite("qux", bytes)
+        dst = StringIO.new
+        src = Object.new
+        def src.to_path
+          "qux"
+        end
+        assert_nothing_raised(bug8767) {
+          IO.copy_stream(src, dst)
+        }
+        assert_equal(bytes, dst.string.b, bug8767)
+        assert_equal(4, dst.pos, bug8767)
+      end
+    }
+  end
+
   class Rot13IO
     def initialize(io)
       @io = io

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r42709


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

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