aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-23 07:56:20 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-23 07:56:20 +0000
commite7d83904cb0698d304fb8631ca34d4434152fd17 (patch)
treeba39632fd5558b388a80a10758c633b799ae9766
parent4c9968c9d9775a442346b0bd6d53e4bd95f69c15 (diff)
downloadruby-e7d83904cb0698d304fb8631ca34d4434152fd17.tar.gz
* io.c (rb_io_extract_modeenc): set ASCII-8BIT if binmode is specified
with opthash. [ruby-core:42197] [Bug #5917] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c5
-rw-r--r--test/ruby/test_io_m17n.rb5
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 912ad62e45..cab6f89819 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jan 23 16:35:27 2012 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@cookpad.com>
* test/cgi/test_cgi_util.rb (test_cgi_escape_preserve_encoding):
diff --git a/io.c b/io.c
index 80ec74118b..ea550592bb 100644
--- a/io.c
+++ b/io.c
@@ -4859,10 +4859,13 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
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)) {
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index b7460bf63e..24a11643cd 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -1042,6 +1042,11 @@ EOT
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