[macruby-changes] [4899] MacRuby/trunk/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Nov 9 06:16:11 PST 2010
Revision: 4899
http://trac.macosforge.org/projects/ruby/changeset/4899
Author: watson1978 at gmail.com
Date: 2010-11-09 06:16:09 -0800 (Tue, 09 Nov 2010)
Log Message:
-----------
must not pass 0 to limit with rb_io_readlines and rb_io_each_line. merged from Ruby1.9 rev.29694.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
r, w = IO.pipe
w.puts "foo"
w.puts "bar"
w.puts "baz"
w.close
assert_raise(ArgumentError) { r.readlines(0) }
assert_raise(ArgumentError) { r.readlines('b', 0) }
assert_raise(ArgumentError) { r.each_line(0){|x| p x} }
assert_raise(ArgumentError) { r.each_line('b', 0){|x| p x} }
puts :ok
}}}
Modified Paths:
--------------
MacRuby/trunk/io.c
Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c 2010-11-09 10:05:36 UTC (rev 4898)
+++ MacRuby/trunk/io.c 2010-11-09 14:16:09 UTC (rev 4899)
@@ -1634,6 +1634,9 @@
long limit;
prepare_getline_args(argc, argv, &rs, &limit, io);
+ if (limit == 0) {
+ rb_raise(rb_eArgError, "invalid limit: 0 for readlines");
+ }
VALUE lines = rb_ary_new();
while (true) {
@@ -1682,6 +1685,9 @@
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 (true) {
VALUE line = rb_io_getline_1(rs, limit, io);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101109/06d83268/attachment.html>
More information about the macruby-changes
mailing list