[前][次][番号順一覧][スレッド一覧]

ruby-changes:22309

From: naruse <ko1@a...>
Date: Mon, 23 Jan 2012 16:59:39 +0900 (JST)
Subject: [ruby-changes:22309] naruse:r34358 (trunk): * io.c (rb_io_extract_modeenc): set ASCII-8BIT if binmode is specified

naruse	2012-01-23 16:56:20 +0900 (Mon, 23 Jan 2012)

  New Revision: 34358

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34358

  Log:
    * io.c (rb_io_extract_modeenc): set ASCII-8BIT if binmode is specified
      with opthash. [ruby-core:42197] [Bug #5917]

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_io_m17n.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34357)
+++ ChangeLog	(revision 34358)
@@ -1,3 +1,8 @@
+Mon Jan 23 16:35:27 2012  NARUSE, Yui  <naruse@r...>
+
+	* io.c (rb_io_extract_modeenc): set ASCII-8BIT if binmode is specified
+	  with opthash. [ruby-core:42197] [Bug #5917]
+
 Mon Jan 23 10:08:00 2012  Kenta Murata  <mrkn@c...>
 
 	* test/cgi/test_cgi_util.rb (test_cgi_escape_preserve_encoding):
Index: io.c
===================================================================
--- io.c	(revision 34357)
+++ io.c	(revision 34358)
@@ -4859,10 +4859,13 @@
     else {
 	VALUE v;
 	extract_binmode(opthash, &fmode);
+	if (fmode & FMODE_BINMODE) {
 #ifdef O_BINARY
-	if (fmode & FMODE_BINMODE)
             oflags |= O_BINARY;
 #endif
+	    if (!has_enc)
+		rb_io_ext_int_to_encs(rb_ascii8bit_encoding(), NULL, &enc, &enc2);
+	}
 	if (!has_vmode) {
 	    v = rb_hash_aref(opthash, sym_mode);
 	    if (!NIL_P(v)) {
Index: test/ruby/test_io_m17n.rb
===================================================================
--- test/ruby/test_io_m17n.rb	(revision 34357)
+++ test/ruby/test_io_m17n.rb	(revision 34358)
@@ -1042,6 +1042,11 @@
         f.set_encoding("iso-2022-jp")
       }
     }
+    assert_nothing_raised {
+      open(__FILE__, "r", binmode: true) {|f|
+        f.set_encoding("iso-2022-jp")
+      }
+    }
   end
 
   def test_write_conversion_fixenc

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]