ruby-changes:27668
From: naruse <ko1@a...>
Date: Mon, 11 Mar 2013 17:02:49 +0900 (JST)
Subject: [ruby-changes:27668] naruse:r39720 (trunk): * io.c (extract_binmode): raise error even if binmode and textmode
naruse 2013-03-11 17:02:36 +0900 (Mon, 11 Mar 2013) New Revision: 39720 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39720 Log: * io.c (extract_binmode): raise error even if binmode and textmode don't conflict. [Bug #5918] [ruby-core:42199] Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39719) +++ ChangeLog (revision 39720) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Mar 11 16:57:00 2013 NARUSE, Yui <naruse@r...> + + * 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@r...> * Merge Onigmo d4bad41e16e3eccd97ccce6f1f96712e557c4518. Index: io.c =================================================================== --- io.c (revision 39719) +++ io.c (revision 39720) @@ -5020,6 +5020,8 @@ extract_binmode(VALUE opthash, int *fmod https://github.com/ruby/ruby/blob/trunk/io.c#L5020 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 *fmod https://github.com/ruby/ruby/blob/trunk/io.c#L5029 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; } Index: test/ruby/test_io_m17n.rb =================================================================== --- test/ruby/test_io_m17n.rb (revision 39719) +++ test/ruby/test_io_m17n.rb (revision 39720) @@ -1406,9 +1406,12 @@ EOT https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io_m17n.rb#L1406 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/