diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-04 21:57:35 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-04 21:57:35 +0000 |
commit | 7e6cecb76987cb1e61b20b1213dfd889ce8df930 (patch) | |
tree | 817100f7c70afaec29b353a7debd29354c1703aa /io.c | |
parent | 01d06638b96eefdb5f6bd019289f1e479d3c5723 (diff) | |
download | ruby-7e6cecb76987cb1e61b20b1213dfd889ce8df930.tar.gz |
* dln.c (aix_loaderror): should not use member named 'errno' which
might be a macro (e.g. on AIX).
* io.c (read_all): do not depend on lseek position.
[ruby-dev:22026]
* eval.c (rb_eval): preserve $! value when retry happens in the
rescue clause. [ruby-talk:86697]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -762,7 +762,7 @@ remain_size(fptr) ) { pos = io_tell(fptr); - if (st.st_size > pos && pos >= 0) { + if (st.st_size >= pos && pos >= 0) { siz = st.st_size - pos + 1; if (siz > LONG_MAX) { rb_raise(rb_eIOError, "file too big for single read"); @@ -780,25 +780,23 @@ read_all(fptr, siz, str) { long bytes = 0; long n; - off_t pos = 0; if (feof(fptr->f)) return Qnil; READ_CHECK(fptr->f); - if (!siz) siz = BUFSIZ; + if (siz == 0) siz = BUFSIZ; if (NIL_P(str)) { str = rb_tainted_str_new(0, siz); } else { rb_str_resize(str, siz); } - pos = io_tell(fptr); for (;;) { n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f); - if (pos > 0 && n == 0 && bytes == 0) { + if (n == 0 && bytes == 0) { rb_str_resize(str,0); - if (!fptr->f) return Qnil; - if (feof(fptr->f)) return Qnil; - if (!ferror(fptr->f)) return str; + if (!fptr->f) break; + if (feof(fptr->f)) break; + if (!ferror(fptr->f)) break; rb_sys_fail(fptr->path); } bytes += n; |