* io.c (argf_readlines): forward to current_file for arguments

check.  http://twitter.com/nagachika/status/3634254856589312


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-11-14 03:05:29 +00:00
Родитель 261903223a
Коммит f2dd4eb3cc
3 изменённых файлов: 37 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sun Nov 14 12:05:24 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (argf_readlines): forward to current_file for arguments
check. http://twitter.com/nagachika/status/3634254856589312
Sun Nov 14 08:48:06 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/setup.mak (-basic-vars-, -runtime-): suppress trailing

18
io.c
Просмотреть файл

@ -7172,13 +7172,23 @@ rb_f_readlines(int argc, VALUE *argv, VALUE recv)
static VALUE
argf_readlines(int argc, VALUE *argv, VALUE argf)
{
VALUE line, ary;
int lineno = ARGF.lineno;
VALUE lines, ary;
ary = rb_ary_new();
while (!NIL_P(line = argf_getline(argc, argv, argf))) {
rb_ary_push(ary, line);
while (next_argv()) {
if (ARGF_GENERIC_INPUT_P()) {
lines = rb_funcall3(ARGF.current_file, rb_intern("readlines"), argc, argv);
}
else {
lines = rb_io_readlines(argc, argv, ARGF.current_file);
argf_close(ARGF.current_file);
}
ARGF.next_p = 1;
rb_ary_concat(ary, lines);
ARGF.lineno = lineno + RARRAY_LEN(ary);
ARGF.last_lineno = ARGF.lineno;
}
return ary;
}

Просмотреть файл

@ -694,4 +694,22 @@ class TestArgf < Test::Unit::TestCase
assert_equal([@t1.path, @t2.path, @t3.path].inspect, f.gets.chomp)
end
end
def test_readlines_limit_0
bug4024 = '[ruby-dev:42538]'
t = make_tempfile
argf = ARGF.class.new(t.path)
assert_raise(ArgumentError, bug4024) do
argf.readlines(0)
end
end
def test_each_line_limit_0
bug4024 = '[ruby-dev:42538]'
t = make_tempfile
argf = ARGF.class.new(t.path)
assert_raise(ArgumentError, bug4024) do
argf.each_line(0).next
end
end
end