[macruby-changes] [172] MacRuby/trunk/file.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 25 17:26:22 PDT 2008


Revision: 172
          http://trac.macosforge.org/projects/ruby/changeset/172
Author:   lsansonetti at apple.com
Date:     2008-04-25 17:26:22 -0700 (Fri, 25 Apr 2008)

Log Message:
-----------
fixing File.join

Modified Paths:
--------------
    MacRuby/trunk/file.c

Modified: MacRuby/trunk/file.c
===================================================================
--- MacRuby/trunk/file.c	2008-04-25 22:11:27 UTC (rev 171)
+++ MacRuby/trunk/file.c	2008-04-26 00:26:22 UTC (rev 172)
@@ -3028,14 +3028,28 @@
 static VALUE
 rb_file_join(VALUE ary, VALUE sep)
 {
-    long len, i;
+#if WITH_OBJC
+    VALUE mstr;
+    if (RARRAY_LEN(ary) == 0) {
+	mstr = rb_str_new(0, 0);
+    }
+    else {
+	VALUE str;
+	str = (VALUE)CFStringCreateByCombiningStrings(NULL, (CFArrayRef)ary,
+		(CFStringRef)sep);
+	mstr = rb_str_dup(str);
+	CFRelease((CFTypeRef)str);
+    }
+    return mstr;
+#else
+    long len, i, count;
     VALUE result, tmp;
     char *name, *tail;
 
     if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
 
     len = 1;
-    for (i=0; i<RARRAY_LEN(ary); i++) {
+    for (i=0, count=RARRAY_LEN(ary); i<count; i++) {
 	if (TYPE(RARRAY_AT(ary, i)) == T_STRING) {
 	    len += RSTRING_LEN(RARRAY_AT(ary, i));
 	}
@@ -3080,6 +3094,7 @@
     }
 
     return result;
+#endif
 }
 
 /*

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080425/1971eafb/attachment.html


More information about the macruby-changes mailing list