[macruby-changes] [1607] MacRuby/branches/experimental/io.c

source_changes at macosforge.org source_changes at macosforge.org
Tue May 26 22:36:47 PDT 2009


Revision: 1607
          http://trac.macosforge.org/projects/ruby/changeset/1607
Author:   lsansonetti at apple.com
Date:     2009-05-26 22:36:47 -0700 (Tue, 26 May 2009)
Log Message:
-----------
IO#read should return nil if we read EOF

Modified Paths:
--------------
    MacRuby/branches/experimental/io.c

Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c	2009-05-27 02:50:36 UTC (rev 1606)
+++ MacRuby/branches/experimental/io.c	2009-05-27 05:36:47 UTC (rev 1607)
@@ -1105,13 +1105,14 @@
     rb_io_assert_readable(io_struct);
     
     if (NIL_P(outbuf)) {
-        outbuf = rb_bytestring_new();
-    } else if(CLASS_OF(outbuf) != rb_cByteString) {
-		// TODO: Get the magical pointer incantations right.
-		rb_raise(rb_eIOError, "writing to non-bytestrings is not supported at this time.");
+	outbuf = rb_bytestring_new();
     }
-    
-    if(NIL_P(len)) {
+    else if (CLASS_OF(outbuf) != rb_cByteString) {
+	// TODO: Get the magical pointer incantations right.
+	rb_raise(rb_eIOError, "writing to non-bytestrings is not supported at this time.");
+    }
+
+    if (NIL_P(len)) {
         return rb_io_read_all(io_struct, outbuf);
     }
 
@@ -1119,16 +1120,14 @@
     if (size == 0) {
 	return rb_str_new2("");
     }
-    
 
-
     CFMutableDataRef data = rb_bytestring_wrapped_data(outbuf);
     CFDataIncreaseLength(data, size);
     UInt8 *buf = CFDataGetMutableBytePtr(data);
 
     long data_read = rb_io_read_internal(io_struct, buf, size);
-    if (data_read < size) {
-	rb_eof_error();
+    if (data_read == 0) {
+	return Qnil;
     }
     CFDataSetLength(data, data_read);
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090526/c6feee41/attachment-0001.html>


More information about the macruby-changes mailing list