summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-13 15:53:27 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-13 15:53:27 +0000
commit9c03800575286a49cc034ffbf92a79937187062b (patch)
treebd2d6cdd8c7025ec45955861ae1ac141a24411c4
parentb76dad515e0039c27bc935ddfcbbd7474d32675a (diff)
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@mail.ru> [ruby-core:69779] [Bug #11319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--io.c3
-rw-r--r--test/ruby/test_io.rb9
-rw-r--r--version.h6
4 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2721840f59..6e0065ebcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Aug 14 00:44:34 2015 Eric Wong <e@80x24.org>
+
+ * 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@mail.ru>
+ [ruby-core:69779] [Bug #11319]
+
Thu Aug 13 01:25:26 2015 Benoit Daloze <eregontp@gmail.com>
* lib/net/ftp.rb (makeport): close the TCPServer
diff --git a/io.c b/io.c
index 00c4ef722f..ed38c97f7f 100644
--- a/io.c
+++ b/io.c
@@ -5038,6 +5038,9 @@ rb_io_oflags_modestr(int oflags)
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+");
}
}
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 935ee24d83..d0ca5e6e51 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2050,6 +2050,15 @@ End
}
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|
diff --git a/version.h b/version.h
index dcb2d755ac..1c485fefb1 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#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"