mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_getc): flush rb_stdout before read fro stdin, which is
connected to a tty. [ruby-core:4378] * rubyio.h (FMODE_TTY): renamed from FMODE_LINEBUF. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f605a6fcb7
commit
d486686eb7
3 changed files with 15 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
Mon Feb 7 23:14:11 2005 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* io.c (io_getc): flush rb_stdout before read fro stdin, which is
|
||||
connected to a tty. [ruby-core:4378]
|
||||
|
||||
* rubyio.h (FMODE_TTY): renamed from FMODE_LINEBUF.
|
||||
|
||||
Mon Feb 7 02:13:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* ext/socket/extconf.rb (sockaddr_storage): winsock2.h have the
|
||||
|
|
13
io.c
13
io.c
|
@ -485,7 +485,7 @@ io_fwrite(str, fptr)
|
|||
}
|
||||
if ((fptr->mode & FMODE_SYNC) ||
|
||||
(fptr->wbuf && fptr->wbuf_capa <= fptr->wbuf_len + len) ||
|
||||
((fptr->mode & FMODE_LINEBUF) && memchr(RSTRING(str)->ptr+offset, '\n', len))) {
|
||||
((fptr->mode & FMODE_TTY) && memchr(RSTRING(str)->ptr+offset, '\n', len))) {
|
||||
/* xxx: use writev to avoid double write if available */
|
||||
if (fptr->wbuf_len && fptr->wbuf_len+len <= fptr->wbuf_capa) {
|
||||
if (fptr->wbuf_capa < fptr->wbuf_off+fptr->wbuf_len+len) {
|
||||
|
@ -801,6 +801,9 @@ static int
|
|||
io_getc(OpenFile *fptr)
|
||||
{
|
||||
int r;
|
||||
if (fptr->fd == 0 && (fptr->mode & FMODE_TTY)) {
|
||||
rb_io_flush(rb_stdout);
|
||||
}
|
||||
if (fptr->rbuf == NULL) {
|
||||
fptr->rbuf_off = 0;
|
||||
fptr->rbuf_len = 0;
|
||||
|
@ -2643,8 +2646,8 @@ rb_fdopen(fd, mode)
|
|||
static void
|
||||
io_check_tty(OpenFile *fptr)
|
||||
{
|
||||
if ((fptr->mode & FMODE_WRITABLE) && isatty(fptr->fd))
|
||||
fptr->mode |= FMODE_LINEBUF|FMODE_DUPLEX;
|
||||
if (isatty(fptr->fd))
|
||||
fptr->mode |= FMODE_TTY|FMODE_DUPLEX;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -3938,9 +3941,7 @@ prep_io(fd, mode, klass, path)
|
|||
}
|
||||
#endif
|
||||
fp->mode = mode;
|
||||
if (fp->mode & FMODE_WRITABLE) {
|
||||
io_check_tty(fp);
|
||||
}
|
||||
io_check_tty(fp);
|
||||
if (path) fp->path = strdup(path);
|
||||
|
||||
return io;
|
||||
|
|
2
rubyio.h
2
rubyio.h
|
@ -46,7 +46,7 @@ typedef struct OpenFile {
|
|||
#define FMODE_CREATE 128
|
||||
#define FMODE_BINMODE 4
|
||||
#define FMODE_SYNC 8
|
||||
#define FMODE_LINEBUF 16
|
||||
#define FMODE_TTY 16
|
||||
#define FMODE_DUPLEX 32
|
||||
|
||||
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
|
||||
|
|
Loading…
Reference in a new issue