summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-15 23:11:26 +0000
committerwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-15 23:11:26 +0000
commit95513750a41d814fcbd12cbf7c7a4b5551371998 (patch)
tree452c08f1acaad34614274e1205b480b903c4ce65 /io.c
parent2ad00495842e4d7de2744d4ffb65a7a133eea87c (diff)
downloadruby-95513750a41d814fcbd12cbf7c7a4b5551371998.tar.gz
ruby-95513750a41d814fcbd12cbf7c7a4b5551371998.tar.xz
ruby-95513750a41d814fcbd12cbf7c7a4b5551371998.zip
* io.c (read_all): don't call io_shift_cbuf until bufffering enough or
econv_finished. [ruby-dev:39696] * io.c (more_char): don't call clear_readconv to read buffer after econv_finished. * io.c (appendline, rb_io_each_codepoint): clear readconv when done. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/io.c b/io.c
index 39ef165f0..5479b9c0f 100644
--- a/io.c
+++ b/io.c
@@ -1625,7 +1625,6 @@ more_char(rb_io_t *fptr)
return 0;
if (res == econv_finished) {
- clear_readconv(fptr);
return -1;
}
@@ -1687,10 +1686,14 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
else rb_str_set_len(str, 0);
make_readconv(fptr, 0);
while (1) {
- if (fptr->cbuf_len) {
+ if (fptr->cbuf_len > fptr->cbuf_capa / 2) {
io_shift_cbuf(fptr, fptr->cbuf_len, &str);
}
if (more_char(fptr) == -1) {
+ if (fptr->cbuf_len) {
+ io_shift_cbuf(fptr, fptr->cbuf_len, &str);
+ }
+ clear_readconv(fptr);
return io_enc_str(str, fptr);
}
}
@@ -2172,6 +2175,7 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
}
}
} while (more_char(fptr) != -1);
+ clear_readconv(fptr);
*lp = limit;
return EOF;
}
@@ -2820,6 +2824,7 @@ rb_io_each_codepoint(VALUE io)
}
}
if (more_char(fptr) == -1) {
+ clear_readconv(fptr);
/* ignore an incomplete character before EOF */
return io;
}