ruby-changes:3906
From: ko1@a...
Date: Thu, 7 Feb 2008 16:40:51 +0900 (JST)
Subject: [ruby-changes:3906] akr - Ruby:r15396 (trunk): * io.c (io_reopen): don't change access mode for stdin, stdout and
akr 2008-02-07 16:40:25 +0900 (Thu, 07 Feb 2008)
New Revision: 15396
Modified files:
trunk/ChangeLog
trunk/bootstraptest/test_io.rb
trunk/io.c
Log:
* io.c (io_reopen): don't change access mode for stdin, stdout and
stderr. [ruby-core:15360]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_io.rb?r1=15396&r2=15395&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15396&r2=15395&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=15396&r2=15395&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15395)
+++ ChangeLog (revision 15396)
@@ -1,3 +1,8 @@
+Thu Feb 7 16:33:51 2008 Tanaka Akira <akr@f...>
+
+ * io.c (io_reopen): don't change access mode for stdin, stdout and
+ stderr. [ruby-core:15360]
+
Thu Feb 7 16:33:48 2008 Nobuyoshi Nakada <nobu@r...>
* string.c (str_replace_shared): replaces string with sharing.
Index: bootstraptest/test_io.rb
===================================================================
--- bootstraptest/test_io.rb (revision 15395)
+++ bootstraptest/test_io.rb (revision 15396)
@@ -36,3 +36,19 @@
}
r.gets("abab")
}
+
+assert_equal 'ok', %q{
+ require 'tmpdir'
+ begin
+ tmpname = "#{Dir.tmpdir}/ruby-btest-#{$$}-#{rand(0x100000000).to_s(36)}"
+ rw = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL)
+ rescue Errno::EEXIST
+ retry
+ end
+ save = STDIN.dup
+ STDIN.reopen(rw)
+ STDIN.reopen(save)
+ rw.close
+ File.unlink(tmpname)
+ :ok
+}
Index: io.c
===================================================================
--- io.c (revision 15395)
+++ io.c (revision 15396)
@@ -4132,7 +4132,13 @@
}
/* copy rb_io_t structure */
- fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);
+ if (fptr->mode & FMODE_PREP) {
+ int mask = FMODE_PREP|FMODE_READWRITE;
+ fptr->mode = (orig->mode & ~mask)|(fptr->mode & mask);
+ }
+ else {
+ fptr->mode = orig->mode;
+ }
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (fptr->path) free(fptr->path);
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/