[macruby-changes] [2517] MacRuby/trunk/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 8 19:24:05 PDT 2009
Revision: 2517
http://trac.macosforge.org/projects/ruby/changeset/2517
Author: lsansonetti at apple.com
Date: 2009-09-08 19:24:04 -0700 (Tue, 08 Sep 2009)
Log Message:
-----------
File.read: support the optional hash argument
Modified Paths:
--------------
MacRuby/trunk/io.c
Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c 2009-09-09 02:23:32 UTC (rev 2516)
+++ MacRuby/trunk/io.c 2009-09-09 02:24:04 UTC (rev 2517)
@@ -1121,6 +1121,10 @@
return rb_str_new2("");
}
+ if (size > 1000000000) {
+ rb_raise(rb_eArgError, "given size `%ld' is too big", size);
+ }
+
CFMutableDataRef data = rb_bytestring_wrapped_data(outbuf);
CFDataIncreaseLength(data, size);
UInt8 *buf = CFDataGetMutableBytePtr(data);
@@ -2799,7 +2803,7 @@
static VALUE
rb_io_initialize(VALUE io, SEL sel, int argc, VALUE *argv)
{
- rb_secure(4);
+ rb_secure(4);
VALUE file_descriptor, mode;
int mode_flags, fd;
@@ -3694,10 +3698,12 @@
static VALUE
rb_io_s_read(VALUE recv, SEL sel, int argc, VALUE *argv)
{
- VALUE fname, length, offset, opt;
- rb_scan_args(argc, argv, "13", &fname, &length, &offset, &opt);
+ // TODO handle optional hash
+ /*VALUE opt =*/ pop_last_hash(&argc, argv);
- // TODO honor opt
+ VALUE fname, length, offset;
+ rb_scan_args(argc, argv, "13", &fname, &length, &offset, NULL);
+
SafeStringValue(fname);
VALUE io = rb_file_open(io_alloc(recv, 0), 1, &fname);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090908/1ddb2d03/attachment.html>
More information about the macruby-changes
mailing list