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

source_changes at macosforge.org source_changes at macosforge.org
Sun Mar 22 12:39:01 PDT 2009


Revision: 1061
          http://trac.macosforge.org/projects/ruby/changeset/1061
Author:   lsansonetti at apple.com
Date:     2009-03-22 12:39:00 -0700 (Sun, 22 Mar 2009)
Log Message:
-----------
reverted r1059 because it's bad (breaks #require)

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

Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c	2009-03-22 19:09:29 UTC (rev 1060)
+++ MacRuby/branches/experimental/io.c	2009-03-22 19:39:00 UTC (rev 1061)
@@ -240,6 +240,38 @@
 #define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
 #define PREP_STDIO_NAME(f) ((f)->path)
 
+static inline int
+rb_io_modenum_flags(int mode)
+{
+    int flags = 0;
+
+    switch (mode & (O_RDONLY|O_WRONLY|O_RDWR)) {
+	case O_RDONLY:
+	    flags = FMODE_READABLE;
+	    break;
+	case O_WRONLY:
+	    flags = FMODE_WRITABLE;
+	    break;
+	case O_RDWR:
+	    flags = FMODE_READWRITE;
+	    break;
+    }
+
+    if (mode & O_APPEND) {
+	flags |= FMODE_APPEND;
+    }
+    if (mode & O_CREAT) {
+	flags |= FMODE_CREATE;
+    }
+#ifdef O_BINARY
+    if (mode & O_BINARY) {
+	flags |= FMODE_BINMODE;
+    }
+#endif
+
+    return flags;
+}
+
 /*
  *  call-seq:
  *     IO.try_convert(obj) -> io or nil
@@ -341,7 +373,6 @@
 rb_io_fptr_finalize(rb_io_t *io_struct)
 {
     io_struct_close(io_struct, true, true);
-    if(io_struct->fp != NULL) pclose(io_struct->fp);
     return 1;
 }
 
@@ -1058,12 +1089,7 @@
 static VALUE
 rb_io_gets_m(VALUE io, SEL sel, int argc, VALUE *argv)
 {
-	VALUE separator, limit;
-	rb_scan_args(argc, argv, "02", &separator, &limit);
-	// TODO: Actually take the separator into account.
-	VALUE result = rb_io_gets(io, sel);
-	rb_lastline_set(result); // TODO: Implement this in roxor
-	return result;
+    rb_notimplement();
 }
 
 /*
@@ -1624,7 +1650,7 @@
     if (path != NULL && strcmp(path, "-") != 0) {
 	klass = rb_cFile;
     }
-    return prep_io(fd, convert_fmode_to_oflags(mode), klass);
+    return prep_io(fd, rb_io_modenum_flags(mode), klass);
 }
 
 static VALUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090322/ac81baf7/attachment-0001.html>


More information about the macruby-changes mailing list