aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--io.c14
2 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 19afef71bc..764e994f3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 24 01:01:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_read): [ruby-dev:24952]
+
Tue Nov 23 08:09:50 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/menu.rb: improve usability of TkOptionMenubutton
diff --git a/io.c b/io.c
index f8237175df..7145e834df 100644
--- a/io.c
+++ b/io.c
@@ -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);