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 | c8d3cae421b6ff37f030d362db8f48561daba545 (patch) | |
| tree | 094359a45b08d3b735fe1d7a5d1d6edf28cf8323 | |
| parent | 3b68e2bd1c933d98f0b51ccf815ada251db02291 (diff) | |
| download | ruby-c8d3cae421b6ff37f030d362db8f48561daba545.tar.gz ruby-c8d3cae421b6ff37f030d362db8f48561daba545.tar.xz ruby-c8d3cae421b6ff37f030d362db8f48561daba545.zip | |
* io.c (rb_io_external_encoding): should return nil for
pass-through write IO. [ruby-dev:32740]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | io.c | 6 |
2 files changed, 11 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Tue Dec 25 15:42:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org> + + * io.c (rb_io_external_encoding): should return nil for + pass-through write IO. [ruby-dev:32740] + Tue Dec 25 15:24:57 2007 Tanaka Akira <akr@fsij.org> * io.c (appendline): initialize rslen to 1 if rsptr is 0. @@ -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)); } |
