[前][次][番号順一覧][スレッド一覧]

ruby-changes:14782

From: akr <ko1@a...>
Date: Thu, 11 Feb 2010 20:56:10 +0900 (JST)
Subject: [ruby-changes:14782] Ruby:r26644 (trunk): * io.c (rb_io_oflags_modestr): return "r" for O_RDONLY|O_APPEND.

akr	2010-02-11 20:45:22 +0900 (Thu, 11 Feb 2010)

  New Revision: 26644

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26644

  Log:
    * io.c (rb_io_oflags_modestr): return "r" for O_RDONLY|O_APPEND.
      [ruby-dev:40379]

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26643)
+++ ChangeLog	(revision 26644)
@@ -1,3 +1,8 @@
+Thu Feb 11 20:43:00 2010  Tanaka Akira  <akr@f...>
+
+	* 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@m...>
 
 	* missing/alloca.c: s/RUBY_LIB/RUBY_LIB_PREFIX/ [ruby-dev:40395]
Index: io.c
===================================================================
--- io.c	(revision 26643)
+++ io.c	(revision 26644)
@@ -4111,11 +4111,14 @@
 #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:

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]