ruby-changes:1789
From: ko1@a...
Date: 27 Aug 2007 02:23:02 +0900
Subject: [ruby-changes:1789] matz - Ruby:r13280 (trunk): * io.c (rb_io_each_byte): caused infinite loop.
matz 2007-08-27 02:22:26 +0900 (Mon, 27 Aug 2007) New Revision: 13280 Modified files: trunk/ChangeLog trunk/io.c trunk/lib/delegate.rb trunk/test/ruby/test_fnmatch.rb Log: * io.c (rb_io_each_byte): caused infinite loop. [ruby-dev:31652] * io.c (rb_io_getc): should return nil at EOF, not EOFError. * lib/delegate.rb (SimpleDelegator::__setobj__): use raise argument to specify backtrace. * test/ruby/test_fnmatch.rb (TestFnmatch::bracket_test): String#include? no longer works for Fixnum. use #chr. [ruby-dev:31652] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/delegate.rb?r1=13280&r2=13279 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13280&r2=13279 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=13280&r2=13279 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_fnmatch.rb?r1=13280&r2=13279 Index: ChangeLog =================================================================== --- ChangeLog (revision 13279) +++ ChangeLog (revision 13280) @@ -1,3 +1,16 @@ +Mon Aug 27 00:41:13 2007 Yukihiro Matsumoto <matz@r...> + + * io.c (rb_io_each_byte): caused infinite loop. [ruby-dev:31652] + + * io.c (rb_io_getc): should return nil at EOF, not EOFError. + + * lib/delegate.rb (SimpleDelegator::__setobj__): use raise + argument to specify backtrace. + + * test/ruby/test_fnmatch.rb (TestFnmatch::bracket_test): + String#include? no longer works for Fixnum. use #chr. + [ruby-dev:31652] + Sun Aug 26 12:27:14 2007 Koichi Sasada <ko1@a...> * cont.c: fix to remove Fiber.new until fiber.so is not loaded. Index: io.c =================================================================== --- io.c (revision 13279) +++ io.c (revision 13280) @@ -2022,12 +2022,14 @@ rb_yield(INT2FIX(*p & 0xff)); p++; } + fptr->rbuf_off += fptr->rbuf_len; + fptr->rbuf_len = 0; rb_io_check_readable(fptr); READ_CHECK(fptr); if (io_fillbuf(fptr) < 0) { break; } - } + } return io; } @@ -2090,7 +2092,7 @@ READ_CHECK(fptr); if (io_fillbuf(fptr) < 0) { - rb_eof_error(); + return Qnil; } n = rb_enc_mbclen(fptr->rbuf+fptr->rbuf_off, enc); if (n < fptr->rbuf_len) { @@ -2103,7 +2105,7 @@ left = fptr->rbuf_len; MEMCPY(RSTRING_PTR(str), fptr->rbuf+fptr->rbuf_off, char, left); if (io_fillbuf(fptr) < 0) { - rb_eof_error(); + return Qnil; } MEMCPY(RSTRING_PTR(str)+left, fptr->rbuf, char, n-left); fptr->rbuf_off += left; Index: lib/delegate.rb =================================================================== --- lib/delegate.rb (revision 13279) +++ lib/delegate.rb (revision 13280) @@ -283,8 +283,7 @@ begin @delegate_dc_obj.__send(:#{method}, *args, &block) rescue - $@[0,2] = nil - raise + raise $!, $@[2..-1] end end EOS Index: test/ruby/test_fnmatch.rb =================================================================== --- test/ruby/test_fnmatch.rb (revision 13279) +++ test/ruby/test_fnmatch.rb (revision 13280) @@ -4,9 +4,9 @@ def bracket_test(s, t) # `s' should start with neither '!' nor '^' 0x21.upto(0x7E) do |i| - assert_equal(t.include?(i), File.fnmatch("[#{s}]", i.chr, File::FNM_DOTMATCH)) - assert_equal(t.include?(i), !File.fnmatch("[^#{s}]", i.chr, File::FNM_DOTMATCH)) - assert_equal(t.include?(i), !File.fnmatch("[!#{s}]", i.chr, File::FNM_DOTMATCH)) + assert_equal(t.include?(i.chr), File.fnmatch("[#{s}]", i.chr, File::FNM_DOTMATCH)) + assert_equal(t.include?(i.chr), !File.fnmatch("[^#{s}]", i.chr, File::FNM_DOTMATCH)) + assert_equal(t.include?(i.chr), !File.fnmatch("[!#{s}]", i.chr, File::FNM_DOTMATCH)) end end def test_fnmatch -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml