summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-20 09:23:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-20 09:23:26 +0000
commit2b2910c71346c40fa867a1ae79efd0c804d9dba7 (patch)
treeb1873b9b10b09402656105f9cec4b2b48aade3f0 /io.c
parent04946de81b657c439c46f3f3780182b3cc7f4821 (diff)
* io.c (rb_io_reopen): flush before reopening a file.
reported by Mathieu Bouchard. [ruby-core:7396] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/io.c b/io.c
index dd1058455a..e00325fa0d 100644
--- a/io.c
+++ b/io.c
@@ -3416,6 +3416,10 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
return file;
}
+ if (fptr->mode & FMODE_WRITABLE) {
+ io_fflush(fptr);
+ }
+
if (fptr->stdio_file) {
if (freopen(RSTRING(fname)->ptr, mode, fptr->stdio_file) == 0) {
rb_sys_fail(fptr->path);