From a435e522598e97005ef3d9d8bcdaa8262d9905a7 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 7 Dec 2004 06:44:42 +0000 Subject: * io.c (io_fwrite): avoid context switch before writing to stderr. [ruby-dev:25080] * rubyio.h: refine deprecated declaration. * configure.in, file.c, io.c: remove useless check: fseeko, etc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index d40e21cc20..c95b67d379 100644 --- a/io.c +++ b/io.c @@ -57,12 +57,6 @@ #if !HAVE_OFF_T && !defined(off_t) # define off_t long #endif -#if !HAVE_FSEEKO && !defined(fseeko) -# define fseeko fseek -#endif -#if !HAVE_FTELLO && !defined(ftello) -# define ftello ftell -#endif #include @@ -475,7 +469,7 @@ io_fwrite(str, fptr) (fptr->wbuf && fptr->wbuf_capa <= fptr->wbuf_len + len) || ((fptr->mode & FMODE_LINEBUF) && memchr(RSTRING(str)->ptr+offset, '\n', len))) { /* xxx: use writev to avoid double write if available */ - if (fptr->wbuf_len+len <= fptr->wbuf_capa) { + if (fptr->wbuf_len && fptr->wbuf_len+len <= fptr->wbuf_capa) { if (fptr->wbuf_capa < fptr->wbuf_off+fptr->wbuf_len+len) { MEMMOVE(fptr->wbuf, fptr->wbuf+fptr->wbuf_off, char, fptr->wbuf_len); fptr->wbuf_off = 0; @@ -488,7 +482,9 @@ io_fwrite(str, fptr) return -1L; if (n == 0) return len; - if (!rb_thread_fd_writable(fptr->fd)) { + /* avoid context switch between "a" and "\n" in STDERR.puts "a". + [ruby-dev:25080] */ + if (fptr->f != stderr && !rb_thread_fd_writable(fptr->fd)) { rb_io_check_closed(fptr); } retry: -- cgit v1.2.3