diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-07 06:44:42 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-07 06:44:42 +0000 |
commit | a435e522598e97005ef3d9d8bcdaa8262d9905a7 (patch) | |
tree | 47f65f619c1aa58974e4e7531ec2530691e5e30d /io.c | |
parent | 638bbb19460b26f7be79c3780c9887bbee7f0d4a (diff) | |
download | ruby-a435e522598e97005ef3d9d8bcdaa8262d9905a7.tar.gz |
* 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
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -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 <sys/stat.h> @@ -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: |