diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 06:44:58 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 06:44:58 +0000 |
commit | 72bf77fb30fbc97e9dcbfe50d0f62f2f40c93ae3 (patch) | |
tree | 094359a45b08d3b735fe1d7a5d1d6edf28cf8323 /io.c | |
parent | 9f98c9a9c2e6d25787e3d935f3724a31e2ea429a (diff) | |
download | ruby-72bf77fb30fbc97e9dcbfe50d0f62f2f40c93ae3.tar.gz |
* io.c (rb_io_external_encoding): should return nil for
pass-through write IO. [ruby-dev:32740]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -5921,6 +5921,7 @@ rb_io_s_read(int argc, VALUE *argv, VALUE io) * io.external_encoding => encoding * * Returns the Encoding object that represents the encoding of the file. + * If io is write mode and no encoding is specified, returns <code>nil</code>. */ static VALUE @@ -5935,6 +5936,11 @@ rb_io_external_encoding(VALUE io) if (!fptr->enc && fptr->fd == 0) { fptr->enc = rb_default_external_encoding(); } + if (fptr->mode & FMODE_WRITABLE) { + if (fptr->enc) + return rb_enc_from_encoding(fptr->enc); + return Qnil; + } return rb_enc_from_encoding(io_read_encoding(fptr)); } |