diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-23 16:04:16 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-23 16:04:16 +0000 |
commit | e66752a0ed87b1bd3127032f27289fe897c643cd (patch) | |
tree | 20e11e8af7b1bc06345bee30ae009a3fcf3a87cf /io.c | |
parent | d852a4e317e163c920b0b69aff59cb5edea08a18 (diff) | |
download | ruby-e66752a0ed87b1bd3127032f27289fe897c643cd.tar.gz |
* io.c (io_read): [ruby-dev:24952]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1197,17 +1197,19 @@ io_read(argc, argv, io) rb_scan_args(argc, argv, "02", &length, &str); + if (!NIL_P(length)) { + len = NUM2LONG(length); + if (len < 0) { + rb_raise(rb_eArgError, "negative length %ld given", len); + } + } + GetOpenFile(io, fptr); rb_io_check_readable(fptr); + if (NIL_P(length)) { return read_all(fptr, remain_size(fptr), str); } - - len = NUM2LONG(length); - if (len < 0) { - rb_raise(rb_eArgError, "negative length %ld given", len); - } - if (feof(fptr->f)) return Qnil; if (NIL_P(str)) { str = rb_str_new(0, len); |