[macruby-changes] [3219] MacRuby/trunk/string.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 8 16:15:01 PST 2010


Revision: 3219
          http://trac.macosforge.org/projects/ruby/changeset/3219
Author:   lsansonetti at apple.com
Date:     2010-01-08 16:15:00 -0800 (Fri, 08 Jan 2010)
Log Message:
-----------
rb_str_dup(): in case the receiver is not a pure CF string, send -mutableCopy

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

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2010-01-09 00:11:43 UTC (rev 3218)
+++ MacRuby/trunk/string.c	2010-01-09 00:15:00 UTC (rev 3219)
@@ -325,17 +325,21 @@
 rb_str_dup_imp(VALUE str, SEL sel)
 {
     VALUE dup;
+    VALUE klass = *(VALUE *)str;
 
-    if (*(VALUE *)str == rb_cByteString) {
+    if (klass == rb_cByteString) {
 	dup = rb_bytestring_copy(str);
     }
-    else {
+    else if (klass == rb_cCFString) {
 	dup = (VALUE)CFStringCreateMutableCopy(NULL, 0, (CFStringRef)str);
 	CFMakeCollectable((CFTypeRef)dup);
 	if (*(VALUE *)str != rb_cSymbol) {
 	    *(VALUE *)dup = *(VALUE *)str;
 	}
     }
+    else {
+	dup = (VALUE)objc_msgSend((void *)str, selMutableCopy);
+    }
 
     if (OBJ_TAINTED(str)) {
 	OBJ_TAINT(dup);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100108/847dac55/attachment.html>


More information about the macruby-changes mailing list