summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-27 08:31:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-27 08:31:08 +0000
commitc45908e41f47c88674b73a754ecd0535449b667a (patch)
treea27bb0f2ca80fa80b9582ddcb8312eee673b0bd5 /io.c
parentcd3d4a01f248fad1a73ff0b66b7a8d1653f64c19 (diff)
* file.c (rb_find_file): $LOAD_PATH must not be empty.
* file.c (rb_find_file_ext): ditto. * range.c (range_eq): class check should be based on range.class, instead of Range to work with Range.dup. * range.c (range_eql): ditto. * class.c (rb_mod_dup): need to preserve metaclass and flags. * object.c (rb_cstr_to_dbl): had a buffer overrun. * marshal.c (w_class): integrate singleton check into a funciton to follow DRY principle. * marshal.c (w_uclass): should check singleton method. * object.c (rb_obj_dup): dmark and dfree functions must be match for T_DATA type. * object.c (rb_obj_dup): class of the duped object must be match to the class of the original. * re.c (rb_reg_quote): do not escape \t, \f, \r, \n, for they are not regular expression metacharacters. * time.c (time_s_alloc): use time_free instead of free (null check, also serves for type mark). * time.c (time_s_at): check dfree function too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/io.c b/io.c
index 5fcd46b..3d9a438 100644
--- a/io.c
+++ b/io.c
@@ -643,14 +643,16 @@ read_all(fptr, siz)
VALUE str;
long bytes = 0;
long n;
+ long pos = 0;
if (feof(fptr->f)) return Qnil;
READ_CHECK(fptr->f);
if (!siz) siz = BUFSIZ;
str = rb_tainted_str_new(0, siz);
+ pos = ftell(fptr->f);
for (;;) {
n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f);
- if (n == 0 && bytes == 0) {
+ if (pos > 0 && n == 0 && bytes == 0) {
if (feof(fptr->f)) return Qnil;
rb_sys_fail(fptr->path);
}
@@ -2249,14 +2251,14 @@ rb_io_reopen(argc, argv, file)
}
static VALUE
-rb_io_clone(io)
+rb_io_become(clone, io)
VALUE io;
{
OpenFile *fptr, *orig;
int fd;
char *mode;
- VALUE clone = rb_obj_clone(io);
+ io = rb_io_get_io(io);
GetOpenFile(io, orig);
MakeOpenFile(clone, fptr);
@@ -3777,7 +3779,7 @@ Init_IO()
rb_define_hooked_variable("$.", &lineno, 0, lineno_setter);
rb_define_virtual_variable("$_", rb_lastline_get, rb_lastline_set);
- rb_define_method(rb_cIO, "clone", rb_io_clone, 0);
+ rb_define_method(rb_cIO, "become", rb_io_become, 1);
rb_define_method(rb_cIO, "reopen", rb_io_reopen, -1);
rb_define_method(rb_cIO, "print", rb_io_print, -1);