[macruby-changes] [4790] MacRuby/trunk/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Oct 12 20:51:07 PDT 2010
Revision: 4790
http://trac.macosforge.org/projects/ruby/changeset/4790
Author: watson1978 at gmail.com
Date: 2010-10-12 20:51:05 -0700 (Tue, 12 Oct 2010)
Log Message:
-----------
IO#sysread should throw an EOFError.
Test Script:
{{{
file = "tmp.txt"
File.open(file, "w") {|f| f.write "hello"}
File.open(file) {|f|
s = "xxx"
t = f.sysread(10, s)
p s == "hello"
p t == "hello"
begin
t = f.sysread(10, s)
rescue EOFError => err
p true
end
p s == ""
p t == ""
begin
t = f.sysread(0, s)
t = f.sysread(0)
rescue
p false
else
p true
end
}
File.delete(file)
}}}
Modified Paths:
--------------
MacRuby/trunk/io.c
Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c 2010-10-12 04:46:19 UTC (rev 4789)
+++ MacRuby/trunk/io.c 2010-10-13 03:51:05 UTC (rev 4790)
@@ -1156,7 +1156,11 @@
}
// Resize the buffer to whatever was read
rb_bstr_resize(buffer, r);
-
+
+ if (r == 0 && count > 0) {
+ rb_eof_error();
+ }
+
return buffer;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101012/57dee2ac/attachment.html>
More information about the macruby-changes
mailing list