From c09bcd351af03eaadd44552f47a0fc85bf64075a Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 11 Feb 2010 11:45:22 +0000 Subject: * io.c (rb_io_oflags_modestr): return "r" for O_RDONLY|O_APPEND. [ruby-dev:40379] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index da3fc7bb7b..d92e104da7 100644 --- a/io.c +++ b/io.c @@ -4111,11 +4111,14 @@ rb_io_oflags_modestr(int oflags) #else # define MODE_BINARY(a,b) (a) #endif + int accmode = oflags & (O_RDONLY|O_WRONLY|O_RDWR); if (oflags & O_APPEND) { - if ((oflags & O_RDWR) == O_RDWR) { + if (accmode == O_WRONLY) { + return MODE_BINARY("a", "ab"); + } + if (accmode == O_RDWR) { return MODE_BINARY("a+", "ab+"); } - return MODE_BINARY("a", "ab"); } switch (oflags & (O_RDONLY|O_WRONLY|O_RDWR)) { case O_RDONLY: -- cgit v1.2.3