Project

General

Profile

Bug #4024 ยป io_readlines.patch

nagachika (Tomoyuki Chikanaga), 11/04/2010 11:08 PM

View differences:

io.c (working copy)
long limit;
prepare_getline_args(argc, argv, &rs, &limit, io);
if (limit == 0)
rb_raise(rb_eArgError, "invalid limit: 0 for readlines");
ary = rb_ary_new();
while (!NIL_P(line = rb_io_getline_1(rs, limit, io))) {
rb_ary_push(ary, line);
......
RETURN_ENUMERATOR(io, argc, argv);
prepare_getline_args(argc, argv, &rs, &limit, io);
if (limit == 0)
rb_raise(rb_eArgError, "invalid limit: 0 for each_line");
while (!NIL_P(str = rb_io_getline_1(rs, limit, io))) {
rb_yield(str);
}
test/ruby/test_io.rb (working copy)
GC.start
end
end
def test_readlines_limit_0
bugxxx = "[ruby-dev:xxx]"
t = make_tempfile
assert_raise(ArgumentError, bugxxx) do
open(t.path, "r") do |io|
io.readlines(0)
end
end
end
def test_each_line_limit_0
bugxxx = "[ruby-dev:xxx]"
t = make_tempfile
assert_raise(ArgumentError, bugxxx) do
open(t.path, "r") do |io|
io.each_line(0).next
end
end
end
end
    (1-1/1)