mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (copy_stream_fallback_body): use read method unless readpartial
is available. [ruby-dev:36124] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
07e08245d3
commit
6c2108e2ac
3 changed files with 18 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Sep 5 18:37:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (copy_stream_fallback_body): use read method unless readpartial
|
||||||
|
is available. [ruby-dev:36124]
|
||||||
|
|
||||||
Fri Sep 5 18:16:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Sep 5 18:16:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/iconv/iconv.c (iconv_create): strips glibc style option before
|
* ext/iconv/iconv.c (iconv_create): strips glibc style option before
|
||||||
|
|
12
io.c
12
io.c
|
@ -7216,6 +7216,13 @@ copy_stream_fallback_body(VALUE arg)
|
||||||
VALUE buf = rb_str_buf_new(buflen);
|
VALUE buf = rb_str_buf_new(buflen);
|
||||||
long rest = stp->copy_length;
|
long rest = stp->copy_length;
|
||||||
off_t off = stp->src_offset;
|
off_t off = stp->src_offset;
|
||||||
|
ID read_method = id_readpartial;
|
||||||
|
|
||||||
|
if (stp->src_fd == -1) {
|
||||||
|
if (!rb_respond_to(stp->src, read_method)) {
|
||||||
|
read_method = id_read;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
long numwrote;
|
long numwrote;
|
||||||
|
@ -7229,7 +7236,7 @@ copy_stream_fallback_body(VALUE arg)
|
||||||
l = buflen < rest ? buflen : rest;
|
l = buflen < rest ? buflen : rest;
|
||||||
}
|
}
|
||||||
if (stp->src_fd == -1) {
|
if (stp->src_fd == -1) {
|
||||||
rb_funcall(stp->src, id_readpartial, 2, INT2FIX(l), buf);
|
rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ssize_t ss;
|
ssize_t ss;
|
||||||
|
@ -7248,6 +7255,9 @@ copy_stream_fallback_body(VALUE arg)
|
||||||
numwrote = NUM2LONG(n);
|
numwrote = NUM2LONG(n);
|
||||||
stp->total += numwrote;
|
stp->total += numwrote;
|
||||||
rest -= numwrote;
|
rest -= numwrote;
|
||||||
|
if (read_method == id_read && RSTRING_LEN(buf) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
|
@ -977,8 +977,8 @@ end
|
||||||
@f = f
|
@f = f
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(n)
|
def read(*args)
|
||||||
@f.read(n)
|
@f.read(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(str)
|
def write(str)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue