diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-29 23:24:56 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-29 23:24:56 +0000 |
commit | af9e072c7ee0e1be48eedccf442d85dec097964c (patch) | |
tree | b5e19a0965829d689f7903fd6523d04128815b48 /io.c | |
parent | 75571dc912c956f764c77b4f22792ea07eae368f (diff) |
io.c: reopen stdio streams correctly when given "w+"
* 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 #11319]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -5046,6 +5046,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+"); } } |