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

ruby-changes:15776

From: nobu <ko1@a...>
Date: Mon, 10 May 2010 00:36:00 +0900 (JST)
Subject: [ruby-changes:15776] Ruby:r27705 (trunk): * ext/io/console/console.c (ttymode): reverted previous commit.

nobu	2010-05-10 00:35:43 +0900 (Mon, 10 May 2010)

  New Revision: 27705

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

  Log:
    * ext/io/console/console.c (ttymode): reverted previous commit.

  Modified files:
    trunk/ChangeLog
    trunk/ext/io/console/console.c
    trunk/version.h

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27704)
+++ ChangeLog	(revision 27705)
@@ -1,3 +1,7 @@
+Mon May 10 00:35:41 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/io/console/console.c (ttymode): reverted previous commit.
+
 Sun May  9 23:53:14 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/ruby.h (RB_GC_GUARD_PTR): get rid of removal by
Index: ext/io/console/console.c
===================================================================
--- ext/io/console/console.c	(revision 27704)
+++ ext/io/console/console.c	(revision 27705)
@@ -173,23 +173,6 @@
 
 #define FD_PER_IO 2
 
-#if defined HAVE_DUP3
-#define dup_private(fd) dup3((fd), -1, O_CLOEXEC)
-#elif defined F_DUPFD_CLOEXEC
-#define dup_private(fd) fcntl((fd), F_DUPFD_CLOEXEC)
-#elif defined O_CLOEXEC
-static inline int
-dup_private(int fd)
-{
-    fd = dup(fd);
-    if (fd != -1) fcntl(fd, F_SETFD, O_CLOEXEC);
-    return fd;
-}
-#define dup_private(fd) dup_private(fd)
-#else
-#define dup_private(fd) dup(fd)
-#endif
-
 static VALUE
 ttymode(VALUE io, VALUE (*func)(VALUE), void (*setter)(conmode *))
 {
@@ -197,7 +180,6 @@
     int status = -1;
     int error = 0;
     int fd[FD_PER_IO];
-    int tmpfd, dupped = 0;
     conmode t[FD_PER_IO];
     VALUE result = Qnil;
 
@@ -205,10 +187,6 @@
     fd[0] = GetReadFD(fptr);
     if (fd[0] != -1) {
 	if (set_ttymode(fd[0], t+0, setter)) {
-	    if ((tmpfd = dup_private(fd[0])) != -1) {
-		fd[0] = tmpfd;
-		dupped |= 1 << 0;
-	    }
 	    status = 0;
 	}
 	else {
@@ -219,10 +197,6 @@
     fd[1] = GetWriteFD(fptr);
     if (fd[1] != -1 && fd[1] != fd[0]) {
 	if (set_ttymode(fd[1], t+1, setter)) {
-	    if ((tmpfd = dup_private(fd[1])) != -1) {
-		fd[1] = tmpfd;
-		dupped |= 1 << 1;
-	    }
 	    status = 0;
 	}
 	else {
@@ -233,19 +207,18 @@
     if (status == 0) {
 	result = rb_protect(func, io, &status);
     }
-    if (fd[0] != -1) {
+    GetOpenFile(io, fptr);
+    if (fd[0] != -1 && fd[0] == GetReadFD(fptr)) {
 	if (!setattr(fd[0], t+0)) {
 	    error = errno;
 	    status = -1;
 	}
-	if (dupped & (1 << 0)) close(fd[0]);
     }
-    if (fd[1] != -1 && fd[1] != fd[0]) {
+    if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(fptr)) {
 	if (!setattr(fd[1], t+1)) {
 	    error = errno;
 	    status = -1;
 	}
-	if (dupped & (1 << 1)) close(fd[1]);
     }
     if (status) {
 	if (status == -1) {
Index: version.h
===================================================================
--- version.h	(revision 27704)
+++ version.h	(revision 27705)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_RELEASE_DATE "2010-05-09"
+#define RUBY_RELEASE_DATE "2010-05-10"
 #define RUBY_PATCHLEVEL -1
 #define RUBY_BRANCH_NAME "trunk"
 
@@ -8,7 +8,7 @@
 #define RUBY_VERSION_TEENY 1
 #define RUBY_RELEASE_YEAR 2010
 #define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 9
+#define RUBY_RELEASE_DAY 10
 
 #include "ruby/version.h"
 

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

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