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

ruby-changes:39487

From: nagachika <ko1@a...>
Date: Fri, 14 Aug 2015 00:53:53 +0900 (JST)
Subject: [ruby-changes:39487] nagachika:r51568 (ruby_2_2): merge revision(s) 51066: [Backport #11319]

nagachika	2015-08-14 00:53:27 +0900 (Fri, 14 Aug 2015)

  New Revision: 51568

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

  Log:
    merge revision(s) 51066: [Backport #11319]
    
    * io.c (rb_io_oflags_modestr): handle O_TRUNC correctly
    
    * test/ruby/test_io.rb (test_reopen_stdio): new test
      Patch-by: cremno phobia <cremno@m...>
      [ruby-core:69779] [Bug #11319]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/io.c
    branches/ruby_2_2/test/ruby/test_io.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 51567)
+++ ruby_2_2/ChangeLog	(revision 51568)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Fri Aug 14 00:44:34 2015  Eric Wong  <e@8...>
+
+	* io.c (rb_io_oflags_modestr): handle O_TRUNC correctly
+	* test/ruby/test_io.rb (test_reopen_stdio): new test
+	  Patch-by: cremno phobia <cremno@m...>
+	  [ruby-core:69779] [Bug #11319]
+
 Thu Aug 13 01:25:26 2015  Benoit Daloze  <eregontp@g...>
 
 	* lib/net/ftp.rb (makeport): close the TCPServer
Index: ruby_2_2/io.c
===================================================================
--- ruby_2_2/io.c	(revision 51567)
+++ ruby_2_2/io.c	(revision 51568)
@@ -5038,6 +5038,9 @@ rb_io_oflags_modestr(int oflags) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/io.c#L5038
       case O_WRONLY:
 	return MODE_BINARY("w", "wb");
       case O_RDWR:
+	if (oflags & O_TRUNC) {
+	    return MODE_BINARY("w+", "wb+");
+	}
 	return MODE_BINARY("r+", "rb+");
     }
 }
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 51567)
+++ ruby_2_2/version.h	(revision 51568)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.3"
-#define RUBY_RELEASE_DATE "2015-08-13"
-#define RUBY_PATCHLEVEL 163
+#define RUBY_RELEASE_DATE "2015-08-14"
+#define RUBY_PATCHLEVEL 164
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 13
+#define RUBY_RELEASE_DAY 14
 
 #include "ruby/version.h"
 
Index: ruby_2_2/test/ruby/test_io.rb
===================================================================
--- ruby_2_2/test/ruby/test_io.rb	(revision 51567)
+++ ruby_2_2/test/ruby/test_io.rb	(revision 51568)
@@ -2050,6 +2050,15 @@ End https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_io.rb#L2050
     }
   end
 
+  def test_reopen_stdio
+    mkcdtmpdir {
+      fname = 'bug11319'
+      File.write(fname, 'hello')
+      system(EnvUtil.rubybin, '-e', "STDOUT.reopen('#{fname}', 'w+')")
+      assert_equal('', File.read(fname))
+    }
+  end
+
   def test_reopen_mode
     feature7067 = '[ruby-core:47694]'
     make_tempfile {|t|

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


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

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