diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-12 23:46:58 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-12 23:46:58 +0000 |
commit | 0ca7036682dad1caea4e7a4fe8fd908d94c878e8 (patch) | |
tree | 3a90607522169270bc23deb791aa4c2b9fb0988e /io.c | |
parent | b92cee1ddbd8c0025ce2e11e3e02d160294556f9 (diff) | |
download | ruby-0ca7036682dad1caea4e7a4fe8fd908d94c878e8.tar.gz |
* io.c (read_all): should associate default external encoding.
* io.c (io_read): should NOT associate default external encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -1267,6 +1267,16 @@ remain_size(rb_io_t *fptr) } static VALUE +io_enc_str(VALUE str, rb_io_t *fptr) +{ + OBJ_TAINT(str); + if (fptr->enc) { + rb_enc_associate(str, fptr->enc); + } + return str; +} + +static VALUE read_all(rb_io_t *fptr, long siz, VALUE str) { long bytes = 0; @@ -1291,9 +1301,7 @@ read_all(rb_io_t *fptr, long siz, VALUE str) rb_str_resize(str, siz); } if (bytes != siz) rb_str_resize(str, bytes); - OBJ_TAINT(str); - - return str; + return io_enc_str(str, fptr); } void rb_io_set_nonblock(rb_io_t *fptr) @@ -1521,16 +1529,6 @@ rb_io_write_nonblock(VALUE io, VALUE str) return LONG2FIX(n); } -static VALUE -io_enc_str(VALUE str, rb_io_t *fptr) -{ - OBJ_TAINT(str); - if (fptr->enc) { - rb_enc_associate(str, fptr->enc); - } - return str; -} - /* * call-seq: * ios.read([length [, buffer]]) => string, buffer, or nil @@ -1597,7 +1595,8 @@ io_read(int argc, VALUE *argv, VALUE io) return Qnil; } rb_str_resize(str, n); - return io_enc_str(str, fptr); + + return str; } static int |