diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 16:33:46 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 16:33:46 +0000 |
commit | 4aa0fea5d6d76ec0e84beafd1f14717c626a8a4e (patch) | |
tree | c31859931992245ab5b0e75de06d8110a866b373 | |
parent | d12741ce98bf96ac53f2c593eea08869c9b2f1ac (diff) | |
download | ruby-4aa0fea5d6d76ec0e84beafd1f14717c626a8a4e.tar.gz ruby-4aa0fea5d6d76ec0e84beafd1f14717c626a8a4e.tar.xz ruby-4aa0fea5d6d76ec0e84beafd1f14717c626a8a4e.zip |
* io.c (rb_open_file): encoding in mode string was ignored if perm is
specified.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | io.c | 6 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 9 |
3 files changed, 20 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Tue Aug 19 01:32:37 2008 Tanaka Akira <akr@fsij.org> + + * io.c (rb_open_file): encoding in mode string was ignored if perm is + specified. + Tue Aug 19 01:02:19 2008 Tanaka Akira <akr@fsij.org> * io.c (rb_open_file): don't access argv[-1] by @@ -4506,6 +4506,12 @@ rb_open_file(int argc, VALUE *argv, VALUE io) fmode = NIL_P(perm) ? 0666 : NUM2UINT(perm); rb_file_sysopen_internal(io, RSTRING_PTR(fname), flags, fmode); + + if (!FIXNUM_P(vmode)) { + rb_io_t *fptr; + GetOpenFile(io, fptr); + rb_io_mode_enc(fptr, StringValueCStr(vmode)); + } } else { mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode); diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index fbf386548..0a3c403c7 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -121,6 +121,15 @@ EOT } end + def test_open_w_enc_enc_perm + with_tmpdir { + open("tmp", "w:euc-jp:utf-8", 0600) {|f| + assert_equal(Encoding::EUC_JP, f.external_encoding) + assert_equal(Encoding::UTF_8, f.internal_encoding) + } + } + end + def test_stdin assert_equal(Encoding.default_external, STDIN.external_encoding) assert_equal(nil, STDIN.internal_encoding) |