ruby-changes:44310
From: nobu <ko1@a...>
Date: Mon, 10 Oct 2016 12:37:15 +0900 (JST)
Subject: [ruby-changes:44310] nobu:r56383 (trunk): io.c: reduce isatty on Cygwin [ci skip]
nobu 2016-10-10 12:37:09 +0900 (Mon, 10 Oct 2016) New Revision: 56383 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56383 Log: io.c: reduce isatty on Cygwin [ci skip] * io.c (prep_io): reduce isatty call (and its system call) on Cygwin. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 56382) +++ ChangeLog (revision 56383) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Oct 10 12:37:06 2016 Nobuyoshi Nakada <nobu@r...> + + * io.c (prep_io): reduce isatty call (and its system call) on + Cygwin. + Sun Oct 9 23:05:53 2016 Prathamesh Sonpatki <csonpatki@g...> * array.c, class.c: Fixed documentation where Fixnum was referred Index: io.c =================================================================== --- io.c (revision 56382) +++ io.c (revision 56383) @@ -5518,11 +5518,13 @@ rb_fdopen(int fd, const char *modestr) https://github.com/ruby/ruby/blob/trunk/io.c#L5518 return file; } -static void +static int io_check_tty(rb_io_t *fptr) { - if (isatty(fptr->fd)) + int t = isatty(fptr->fd); + if (t) fptr->mode |= FMODE_TTY|FMODE_DUPLEX; + return t; } static VALUE rb_io_internal_encoding(VALUE); @@ -7370,14 +7372,13 @@ prep_io(int fd, int fmode, VALUE klass, https://github.com/ruby/ruby/blob/trunk/io.c#L7372 MakeOpenFile(io, fp); fp->fd = fd; + fp->mode = fmode; + if (!io_check_tty(fp)) { #ifdef __CYGWIN__ - if (!isatty(fd)) { - fmode |= FMODE_BINMODE; + fp->fmode |= FMODE_BINMODE; setmode(fd, O_BINARY); - } #endif - fp->mode = fmode; - io_check_tty(fp); + } if (path) fp->pathv = rb_obj_freeze(rb_str_new_cstr(path)); rb_update_max_fd(fd); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/