diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 9 |
3 files changed, 15 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Mon Mar 11 16:57:00 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * io.c (extract_binmode): raise error even if binmode and textmode + don't conflict. [Bug #5918] [ruby-core:42199] + Mon Mar 11 12:25:12 2013 NARUSE, Yui <naruse@ruby-lang.org> * Merge Onigmo d4bad41e16e3eccd97ccce6f1f96712e557c4518. @@ -5020,6 +5020,8 @@ extract_binmode(VALUE opthash, int *fmode) if (!NIL_P(v)) { if (*fmode & FMODE_TEXTMODE) rb_raise(rb_eArgError, "textmode specified twice"); + if (*fmode & FMODE_BINMODE) + rb_raise(rb_eArgError, "both textmode and binmode specified"); if (RTEST(v)) *fmode |= FMODE_TEXTMODE; } @@ -5027,6 +5029,8 @@ extract_binmode(VALUE opthash, int *fmode) if (!NIL_P(v)) { if (*fmode & FMODE_BINMODE) rb_raise(rb_eArgError, "binmode specified twice"); + if (*fmode & FMODE_TEXTMODE) + rb_raise(rb_eArgError, "both textmode and binmode specified"); if (RTEST(v)) *fmode |= FMODE_BINMODE; } diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index becafaa201..24a7f16947 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1406,9 +1406,12 @@ EOT end def test_both_textmode_binmode - assert_raise(ArgumentError) { open("not-exist", "r", :textmode=>true, :binmode=>true) } - assert_raise(ArgumentError) { open("not-exist", "rt", :binmode=>true) } - assert_raise(ArgumentError) { open("not-exist", "rb", :textmode=>true) } + bug5918 = '[ruby-core:42199]' + assert_raise(ArgumentError, bug5918) { open("not-exist", "r", :textmode=>true, :binmode=>true) } + assert_raise(ArgumentError, bug5918) { open("not-exist", "rt", :binmode=>true) } + assert_raise(ArgumentError, bug5918) { open("not-exist", "rt", :binmode=>false) } + assert_raise(ArgumentError, bug5918) { open("not-exist", "rb", :textmode=>true) } + assert_raise(ArgumentError, bug5918) { open("not-exist", "rb", :textmode=>false) } end def test_textmode_decode_universal_newline_read |