1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (extract_binmode): raise error even if binmode and textmode

don't conflict. [Bug #5918] [ruby-core:42199]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2013-03-11 08:02:36 +00:00
parent a82d24aa82
commit 756cd2852d
3 changed files with 15 additions and 3 deletions

View file

@ -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.

4
io.c
View file

@ -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;
}

View file

@ -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