ruby-changes:7181
From: akr <ko1@a...>
Date: Tue, 19 Aug 2008 01:36:20 +0900 (JST)
Subject: [ruby-changes:7181] Ruby:r18700 (trunk): * io.c (rb_open_file): encoding in mode string was ignored if perm is
akr 2008-08-19 01:33:46 +0900 (Tue, 19 Aug 2008) New Revision: 18700 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18700 Log: * io.c (rb_open_file): encoding in mode string was ignored if perm is specified. Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18699) +++ ChangeLog (revision 18700) @@ -1,3 +1,8 @@ +Tue Aug 19 01:32:37 2008 Tanaka Akira <akr@f...> + + * 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@f...> * io.c (rb_open_file): don't access argv[-1] by Index: io.c =================================================================== --- io.c (revision 18699) +++ io.c (revision 18700) @@ -4506,6 +4506,12 @@ 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); Index: test/ruby/test_io_m17n.rb =================================================================== --- test/ruby/test_io_m17n.rb (revision 18699) +++ test/ruby/test_io_m17n.rb (revision 18700) @@ -121,6 +121,15 @@ } 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/