From 62a7c8fb13487b34dcc4c5531231bb5544584231 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 2 Jul 2006 02:25:11 +0000 Subject: [PATCH] * io.c (io_reopen): STDOUT.reopen(filename, "w+") didn't work. (rb_io_reopen): STDOUT.reopen(File.open(filename, "w+")) didn't work. This commit is a result of hacks at the CodeFest Akihabara 2006 hosted by FSIJ. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ io.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2beaf99de..93b7f079c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 2 11:22:03 2006 Tanaka Akira + + * io.c (io_reopen): STDOUT.reopen(filename, "w+") didn't work. + (rb_io_reopen): STDOUT.reopen(File.open(filename, "w+")) didn't work. + Sat Jul 1 23:55:42 2006 Yukihiro Matsumoto * eval.c (PUSH_FRAME): initialize frame->self. [ruby-dev:28911] diff --git a/io.c b/io.c index e8007819b2..3d0e1632ca 100644 --- a/io.c +++ b/io.c @@ -3425,7 +3425,8 @@ io_reopen(VALUE io, VALUE nfile) if (fptr == orig) return io; #if !defined __CYGWIN__ if (IS_PREP_STDIO(fptr)) { - if ((fptr->mode & FMODE_READWRITE) != (orig->mode & FMODE_READWRITE)) { + if (((fptr->mode & FMODE_READWRITE) & (orig->mode & FMODE_READWRITE)) != + (fptr->mode & FMODE_READWRITE)) { rb_raise(rb_eArgError, "%s can't change access mode from \"%s\" to \"%s\"", PREP_STDIO_NAME(fptr), rb_io_flags_mode(fptr->mode), @@ -3536,7 +3537,8 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file) if (!NIL_P(nmode)) { int flags = rb_io_mode_flags(StringValuePtr(nmode)); if (IS_PREP_STDIO(fptr) && - (fptr->mode & FMODE_READWRITE) != (flags & FMODE_READWRITE)) { + ((fptr->mode & FMODE_READWRITE) & (flags & FMODE_READWRITE)) != + (fptr->mode & FMODE_READWRITE)) { rb_raise(rb_eArgError, "%s can't change access mode from \"%s\" to \"%s\"", PREP_STDIO_NAME(fptr), rb_io_flags_mode(fptr->mode),