[macruby-changes] [3699] MacRuby/branches/icu

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 4 16:47:48 PST 2010


Revision: 3699
          http://trac.macosforge.org/projects/ruby/changeset/3699
Author:   lsansonetti at apple.com
Date:     2010-03-04 16:47:47 -0800 (Thu, 04 Mar 2010)
Log Message:
-----------
fixed IO#inspect

Modified Paths:
--------------
    MacRuby/branches/icu/file.c
    MacRuby/branches/icu/include/ruby/io.h
    MacRuby/branches/icu/io.c

Modified: MacRuby/branches/icu/file.c
===================================================================
--- MacRuby/branches/icu/file.c	2010-03-05 00:33:32 UTC (rev 3698)
+++ MacRuby/branches/icu/file.c	2010-03-05 00:47:47 UTC (rev 3699)
@@ -168,7 +168,7 @@
 rb_file_path(VALUE obj, SEL sel)
 {
     rb_io_t *io = ExtractIOStruct(obj);
-    return io->path == NULL ? Qnil : (VALUE)io->path;
+    return io->path == 0 ? Qnil : io->path;
 }
 
 static VALUE
@@ -825,7 +825,7 @@
 
     rb_secure(2);
     GetOpenFile(obj, fptr);
-    if (fptr->path == NULL) {
+    if (fptr->path == 0) {
 	return Qnil;
     }
     if (lstat(RSTRING_PTR(fptr->path), &st) == -1) {

Modified: MacRuby/branches/icu/include/ruby/io.h
===================================================================
--- MacRuby/branches/icu/include/ruby/io.h	2010-03-05 00:33:32 UTC (rev 3698)
+++ MacRuby/branches/icu/include/ruby/io.h	2010-03-05 00:47:47 UTC (rev 3699)
@@ -29,7 +29,7 @@
     int read_fd;
     int write_fd;
 
-    CFStringRef path;
+    VALUE path;
     pid_t pid;
     int lineno;
     int mode;

Modified: MacRuby/branches/icu/io.c
===================================================================
--- MacRuby/branches/icu/io.c	2010-03-05 00:33:32 UTC (rev 3698)
+++ MacRuby/branches/icu/io.c	2010-03-05 00:47:47 UTC (rev 3699)
@@ -849,15 +849,21 @@
 rb_io_inspect(VALUE io, SEL sel)
 {
     rb_io_t *io_struct = ExtractIOStruct(io);
-    if ((io_struct == NULL) || (io_struct->path == NULL)) {
+    if (io_struct == NULL || io_struct->path == 0) {
         return rb_any_to_s(io);
     }
-    const char *status = (rb_io_is_open(io_struct) ? "" : " (closed)");
 
-    CFStringRef s = CFStringCreateWithFormat(NULL, NULL, CFSTR("#<%s:%@%s>"),
-	    rb_obj_classname(io), io_struct->path, status);
-    CFMakeCollectable(s);
-    return (VALUE)s;
+    VALUE str = rb_str_new2("#<");
+    rb_str_cat2(str, rb_obj_classname(io));
+    rb_str_cat2(str, ":");
+    rb_str_concat(str, io_struct->path);
+    if (!rb_io_is_open(io_struct)) {
+	rb_str_cat2(str, " (closed)>");
+    }
+    else {
+	rb_str_cat2(str, ">");
+    }
+    return str;
 }
 
 /*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100304/4f608d21/attachment.html>


More information about the macruby-changes mailing list