Revision
3699
Author
lsansonetti@apple.com
Date
2010-03-04 16:47:47 -0800 (Thu, 04 Mar 2010)

Log Message

fixed IO#inspect

Modified Paths

Diff

Modified: MacRuby/branches/icu/file.c (3698 => 3699)


--- 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 (3698 => 3699)


--- 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 (3698 => 3699)


--- 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;
 }
 
 /*