mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_extract_modeenc): fail only if conflicting
text/binary modes given explicitly. [ruby-dev:45268][Bug #6055] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f56c6318de
commit
4341c58c39
3 changed files with 18 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Feb 23 02:33:00 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (rb_io_extract_modeenc): fail only if conflicting
|
||||
text/binary modes given explicitly. [ruby-dev:45268][Bug #6055]
|
||||
|
||||
Wed Feb 22 23:27:08 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* test/iconv/test_option.rb: enabled. [ruby-core:42802][Bug #6061]
|
||||
|
|
7
io.c
7
io.c
|
@ -4817,7 +4817,7 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
|
|||
|
||||
vmode_handle:
|
||||
if (NIL_P(vmode)) {
|
||||
fmode = FMODE_READABLE | DEFAULT_TEXTMODE;
|
||||
fmode = FMODE_READABLE;
|
||||
oflags = O_RDONLY;
|
||||
}
|
||||
else if (!NIL_P(intmode = rb_check_to_integer(vmode, "to_int"))) {
|
||||
|
@ -4867,6 +4867,11 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
|
|||
if (!has_enc)
|
||||
rb_io_ext_int_to_encs(rb_ascii8bit_encoding(), NULL, &enc, &enc2);
|
||||
}
|
||||
#if DEFAULT_TEXTMODE
|
||||
else if (NIL_P(vmode)) {
|
||||
fmode |= DEFAULT_TEXTMODE;
|
||||
}
|
||||
#endif
|
||||
if (!has_vmode) {
|
||||
v = rb_hash_aref(opthash, sym_mode);
|
||||
if (!NIL_P(v)) {
|
||||
|
|
|
@ -2023,15 +2023,18 @@ End
|
|||
|
||||
def test_open_mode
|
||||
feature4742 = "[ruby-core:36338]"
|
||||
bug6055 = '[ruby-dev:45268]'
|
||||
|
||||
mkcdtmpdir do
|
||||
refute_nil(f = File.open('symbolic', 'w'))
|
||||
assert_not_nil(f = File.open('symbolic', 'w'))
|
||||
f.close
|
||||
refute_nil(f = File.open('numeric', File::WRONLY|File::TRUNC|File::CREAT))
|
||||
assert_not_nil(f = File.open('numeric', File::WRONLY|File::TRUNC|File::CREAT))
|
||||
f.close
|
||||
refute_nil(f = File.open('hash-symbolic', :mode => 'w'))
|
||||
assert_not_nil(f = File.open('hash-symbolic', :mode => 'w'))
|
||||
f.close
|
||||
refute_nil(f = File.open('hash-numeric', :mode => File::WRONLY|File::TRUNC|File::CREAT), feature4742)
|
||||
assert_not_nil(f = File.open('hash-numeric', :mode => File::WRONLY|File::TRUNC|File::CREAT), feature4742)
|
||||
f.close
|
||||
assert_nothing_raised(bug6055) {f = File.open('hash-symbolic', binmode: true)}
|
||||
f.close
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue