diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-03-20 06:27:22 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-03-20 06:27:22 +0000 |
commit | 85dd7bb0ef28fe4ce63641e653d92e42327b0207 (patch) | |
tree | bcd1e5b816c1a7cdc06f31f28cd967f6b78e9a96 /io.c | |
parent | 5782e5b0006ca5f941e8cdd7101ca07218c9d816 (diff) |
* eval.c (load_dyna): clear ruby_errinfo. (ruby-bugs-ja PR#409)
* io.c (read_all): make str empty if given. (ruby-bugs-ja PR#408)
* io.c (io_read): ditto.
* io.c (rb_io_sysread): ditto.
* range.c: do not override min and max.
* sprintf.c (remove_sign_bits): octal left most digit for negative
numbers may be '3'. (ruby-bugs-ja PR#407)
* sprintf.c (rb_f_sprintf): should prefix sign bits if bignum is
negative, using sign_bits().
* eval.c (avalue_to_mrhs): split argument passing and assignment
conversion.
* eval.c (svalue_to_mrhs): ditto.
* eval.c (avalue_to_svalue): avalue_to_svalue([[1,2]]) should be
[[1,2]], not [1,2] to wrap-around.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -781,8 +781,9 @@ read_all(fptr, siz, str) for (;;) { n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f); if (pos > 0 && n == 0 && bytes == 0) { + rb_str_resize(str,0); if (feof(fptr->f)) return Qnil; - if (!ferror(fptr->f)) return rb_str_new(0, 0); + if (!ferror(fptr->f)) return str; rb_sys_fail(fptr->path); } bytes += n; @@ -827,18 +828,13 @@ io_read(argc, argv, io) else { StringValue(str); rb_str_modify(str); - if (len == 0) { - rb_str_resize(str, 0); - return str; - } - if (len > RSTRING(str)->len) { - rb_str_resize(str,len); - } + rb_str_resize(str,len); } READ_CHECK(fptr->f); n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f); if (n == 0) { + rb_str_resize(str,0); if (feof(fptr->f)) return Qnil; rb_sys_fail(fptr->path); } @@ -1579,8 +1575,12 @@ rb_io_sysread(argc, argv, io) n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len); TRAP_END; - if (n == -1) rb_sys_fail(fptr->path); + if (n == -1) { + rb_str_resize(str, 0); + rb_sys_fail(fptr->path); + } if (n == 0 && ilen > 0) { + rb_str_resize(str, 0); rb_eof_error(); } |