diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-28 05:55:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-28 05:55:22 +0000 |
commit | ffa153f282b8fb94734a3b33ba83cc8566a0231f (patch) | |
tree | b509df29a5c4ccc6aa8e4440c96ec536af223139 | |
parent | 7a4f70463d13fa2c508dcf3180b98f56559f592b (diff) |
io.c: preserve encodings
* io.c (rb_io_extract_encoding_option): preserve encodings in
warning messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | io.c | 6 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 11 |
2 files changed, 14 insertions, 3 deletions
@@ -5194,9 +5194,9 @@ rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2 if ((extenc != Qundef || intenc != Qundef) && !NIL_P(encoding)) { if (!NIL_P(ruby_verbose)) { int idx = rb_to_encoding_index(encoding); - rb_warn("Ignoring encoding parameter '%s': %s_encoding is used", - idx < 0 ? StringValueCStr(encoding) : rb_enc_name(rb_enc_from_index(idx)), - extenc == Qundef ? "internal" : "external"); + if (idx >= 0) encoding = rb_enc_from_encoding(rb_enc_from_index(idx)); + rb_warn("Ignoring encoding parameter '%"PRIsVALUE"': %s_encoding is used", + encoding, extenc == Qundef ? "internal" : "external"); } encoding = Qnil; } diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index e9e6a1cf83..7f54762ebe 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -312,6 +312,17 @@ EOT } end + def test_ignored_encoding_option + enc = "\u{30a8 30f3 30b3 30fc 30c7 30a3 30f3 30b0}" + pattern = /#{enc}/ + assert_warning(pattern) { + open(IO::NULL, external_encoding: "us-ascii", encoding: enc) + } + assert_warning(pattern) { + open(IO::NULL, internal_encoding: "us-ascii", encoding: enc) + } + end + def test_io_new_enc with_tmpdir { generate_file("tmp", "\xa1") |