io.c: reduce isatty on Cygwin [ci skip]
* io.c (prep_io): reduce isatty call (and its system call) on Cygwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dd2ebf4d78
commit
047604ad9b
@ -1,3 +1,8 @@
|
|||||||
|
Mon Oct 10 12:37:06 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (prep_io): reduce isatty call (and its system call) on
|
||||||
|
Cygwin.
|
||||||
|
|
||||||
Sun Oct 9 23:05:53 2016 Prathamesh Sonpatki <csonpatki@gmail.com>
|
Sun Oct 9 23:05:53 2016 Prathamesh Sonpatki <csonpatki@gmail.com>
|
||||||
|
|
||||||
* array.c, class.c: Fixed documentation where Fixnum was referred
|
* array.c, class.c: Fixed documentation where Fixnum was referred
|
||||||
|
19
io.c
19
io.c
@ -5518,11 +5518,13 @@ rb_fdopen(int fd, const char *modestr)
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
io_check_tty(rb_io_t *fptr)
|
io_check_tty(rb_io_t *fptr)
|
||||||
{
|
{
|
||||||
if (isatty(fptr->fd))
|
int t = isatty(fptr->fd);
|
||||||
|
if (t)
|
||||||
fptr->mode |= FMODE_TTY|FMODE_DUPLEX;
|
fptr->mode |= FMODE_TTY|FMODE_DUPLEX;
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE rb_io_internal_encoding(VALUE);
|
static VALUE rb_io_internal_encoding(VALUE);
|
||||||
@ -7370,14 +7372,13 @@ prep_io(int fd, int fmode, VALUE klass, const char *path)
|
|||||||
|
|
||||||
MakeOpenFile(io, fp);
|
MakeOpenFile(io, fp);
|
||||||
fp->fd = fd;
|
fp->fd = fd;
|
||||||
#ifdef __CYGWIN__
|
|
||||||
if (!isatty(fd)) {
|
|
||||||
fmode |= FMODE_BINMODE;
|
|
||||||
setmode(fd, O_BINARY);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
fp->mode = fmode;
|
fp->mode = fmode;
|
||||||
io_check_tty(fp);
|
if (!io_check_tty(fp)) {
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
fp->fmode |= FMODE_BINMODE;
|
||||||
|
setmode(fd, O_BINARY);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (path) fp->pathv = rb_obj_freeze(rb_str_new_cstr(path));
|
if (path) fp->pathv = rb_obj_freeze(rb_str_new_cstr(path));
|
||||||
rb_update_max_fd(fd);
|
rb_update_max_fd(fd);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user