summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-26 17:22:26 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-26 17:22:26 +0000
commit1a0b7d0fb6e05704c94d7916aebbaca7c288a86f (patch)
tree3b804e54858598bb1e1412c8aaee4063d32211ac /io.c
parent98d6d636e33f2f5bf067df64ae617d86e1f610bc (diff)
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/io.c b/io.c
index d1b8eee15c..cc086a8f97 100644
--- a/io.c
+++ b/io.c
@@ -2022,12 +2022,14 @@ rb_io_each_byte(VALUE io)
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 @@ rb_io_getc(VALUE io)
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 @@ rb_io_getc(VALUE io)
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;