Skip to content

Commit 813b5f4

Browse files
committed
merge revision(s) 51066: [Backport ruby#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 <[email protected]> [ruby-core:69779] [Bug ruby#11319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 190241f commit 813b5f4

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Mon Aug 17 17:43:56 2015 Eric Wong <[email protected]>
2+
3+
* io.c (rb_io_oflags_modestr): handle O_TRUNC correctly
4+
* test/ruby/test_io.rb (test_reopen_stdio): new test
5+
Patch-by: cremno phobia <[email protected]>
6+
[ruby-core:69779] [Bug #11319]
7+
18
Mon Aug 17 17:42:18 2015 Benoit Daloze <[email protected]>
29

310
* lib/net/ftp.rb (makeport): close the TCPServer

io.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4958,6 +4958,9 @@ rb_io_oflags_modestr(int oflags)
49584958
case O_WRONLY:
49594959
return MODE_BINARY("w", "wb");
49604960
case O_RDWR:
4961+
if (oflags & O_TRUNC) {
4962+
return MODE_BINARY("w+", "wb+");
4963+
}
49614964
return MODE_BINARY("r+", "rb+");
49624965
}
49634966
}

test/ruby/test_io.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,15 @@ def test_reopen_inherit
19791979
}
19801980
end
19811981

1982+
def test_reopen_stdio
1983+
mkcdtmpdir {
1984+
fname = 'bug11319'
1985+
File.write(fname, 'hello')
1986+
system(EnvUtil.rubybin, '-e', "STDOUT.reopen('#{fname}', 'w+')")
1987+
assert_equal('', File.read(fname))
1988+
}
1989+
end
1990+
19821991
def test_reopen_mode
19831992
feature7067 = '[ruby-core:47694]'
19841993
make_tempfile {|t|

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.7"
22
#define RUBY_RELEASE_DATE "2015-08-17"
3-
#define RUBY_PATCHLEVEL 393
3+
#define RUBY_PATCHLEVEL 394
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 8

0 commit comments

Comments
 (0)