summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-11 11:45:22 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-11 11:45:22 +0000
commitc09bcd351af03eaadd44552f47a0fc85bf64075a (patch)
tree75a11295041de255189d3ebc325d640b0e61c7dd
parente95a439c6dbe863c431eed51fb5591f38e73fba3 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--io.c7
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 09ff1213007..77f199e5984 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Feb 11 20:43:00 2010 Tanaka Akira <akr@fsij.org>
+
+ * io.c (rb_io_oflags_modestr): return "r" for O_RDONLY|O_APPEND.
+ [ruby-dev:40379]
+
Thu Feb 11 19:19:21 2010 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* missing/alloca.c: s/RUBY_LIB/RUBY_LIB_PREFIX/ [ruby-dev:40395]
diff --git a/io.c b/io.c
index da3fc7bb7b9..d92e104da75 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: