Revision
3219
Author
lsansonetti@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

Diff

Modified: MacRuby/trunk/string.c (3218 => 3219)


--- 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);