ruby-changes:39530
From: usa <ko1@a...>
Date: Mon, 17 Aug 2015 17:46:16 +0900 (JST)
Subject: [ruby-changes:39530] usa:r51611 (ruby_2_1): merge revision(s) 51066: [Backport #11319]
usa 2015-08-17 17:45:57 +0900 (Mon, 17 Aug 2015) New Revision: 51611 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51611 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_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/io.c branches/ruby_2_1/test/ruby/test_io.rb branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 51610) +++ ruby_2_1/ChangeLog (revision 51611) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Mon Aug 17 17:43:56 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] + Mon Aug 17 17:42:18 2015 Benoit Daloze <eregontp@g...> * lib/net/ftp.rb (makeport): close the TCPServer Index: ruby_2_1/io.c =================================================================== --- ruby_2_1/io.c (revision 51610) +++ ruby_2_1/io.c (revision 51611) @@ -4958,6 +4958,9 @@ rb_io_oflags_modestr(int oflags) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/io.c#L4958 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_1/version.h =================================================================== --- ruby_2_1/version.h (revision 51610) +++ ruby_2_1/version.h (revision 51611) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.7" #define RUBY_RELEASE_DATE "2015-08-17" -#define RUBY_PATCHLEVEL 393 +#define RUBY_PATCHLEVEL 394 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_1/test/ruby/test_io.rb =================================================================== --- ruby_2_1/test/ruby/test_io.rb (revision 51610) +++ ruby_2_1/test/ruby/test_io.rb (revision 51611) @@ -1979,6 +1979,15 @@ End https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_io.rb#L1979 } 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_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r51066 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/