зеркало из https://github.com/github/ruby.git
* io.c (argf_next_argv): open in default text mode.
[ruby-core:39234] [Bug #5268] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a46d29bb4e
Коммит
74f724de1a
|
@ -1,3 +1,8 @@
|
|||
Sat Sep 3 23:52:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (argf_next_argv): open in default text mode.
|
||||
[ruby-core:39234] [Bug #5268]
|
||||
|
||||
Sat Sep 3 18:40:57 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||
|
||||
* lib/thread.rb (SizedQueue#max=) raise ArgumentError if max is not
|
||||
|
|
15
io.c
15
io.c
|
@ -6843,6 +6843,7 @@ argf_next_argv(VALUE argf)
|
|||
char *fn;
|
||||
rb_io_t *fptr;
|
||||
int stdout_binmode = 0;
|
||||
int fmode;
|
||||
|
||||
if (TYPE(rb_stdout) == T_FILE) {
|
||||
GetOpenFile(rb_stdout, fptr);
|
||||
|
@ -6951,19 +6952,25 @@ argf_next_argv(VALUE argf)
|
|||
rb_stdout = write_io;
|
||||
if (stdout_binmode) rb_io_binmode(rb_stdout);
|
||||
}
|
||||
ARGF.current_file = prep_io(fr, FMODE_READABLE, rb_cFile, fn);
|
||||
fmode = FMODE_READABLE;
|
||||
if (!ARGF.binmode) fmode |= DEFAULT_TEXTMODE;
|
||||
ARGF.current_file = prep_io(fr, fmode, rb_cFile, fn);
|
||||
if (!NIL_P(write_io)) {
|
||||
rb_io_set_write_io(ARGF.current_file, write_io);
|
||||
}
|
||||
}
|
||||
if (ARGF.binmode) rb_io_ascii8bit_binmode(ARGF.current_file);
|
||||
GetOpenFile(ARGF.current_file, fptr);
|
||||
if (ARGF.encs.enc) {
|
||||
rb_io_t *fptr;
|
||||
|
||||
GetOpenFile(ARGF.current_file, fptr);
|
||||
fptr->encs = ARGF.encs;
|
||||
clear_codeconv(fptr);
|
||||
}
|
||||
else {
|
||||
fptr->encs.ecflags &= ~ECONV_NEWLINE_DECORATOR_MASK;
|
||||
if (!ARGF.binmode) {
|
||||
fptr->encs.ecflags |= ECONV_DEFAULT_NEWLINE_DECORATOR;
|
||||
}
|
||||
}
|
||||
ARGF.next_p = 0;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -641,12 +641,23 @@ class TestArgf < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_binmode
|
||||
bug5268 = '[ruby-core:39234]'
|
||||
open(@t3.path, "wb") {|f| f.write "5\r\n6\r\n"}
|
||||
ruby('-e', "ARGF.binmode; STDOUT.binmode; puts ARGF.read", @t1.path, @t2.path, @t3.path) do |f|
|
||||
f.binmode
|
||||
assert_equal("1\n2\n3\n4\n5\n6\n", f.read)
|
||||
assert_equal("1\n2\n3\n4\n5\r\n6\r\n", f.read, bug5268)
|
||||
end
|
||||
end
|
||||
|
||||
def test_textmode
|
||||
bug5268 = '[ruby-core:39234]'
|
||||
open(@t3.path, "wb") {|f| f.write "5\r\n6\r\n"}
|
||||
ruby('-e', "STDOUT.binmode; puts ARGF.read", @t1.path, @t2.path, @t3.path) do |f|
|
||||
f.binmode
|
||||
assert_equal("1\n2\n3\n4\n5\n6\n", f.read, bug5268)
|
||||
end
|
||||
end unless IO::BINARY.zero?
|
||||
|
||||
def test_skip
|
||||
ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
|
||||
ARGF.skip
|
||||
|
|
Загрузка…
Ссылка в новой задаче