[macruby-changes] [2374] MacRuby/trunk/hash.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 25 13:34:45 PDT 2009


Revision: 2374
          http://trac.macosforge.org/projects/ruby/changeset/2374
Author:   lsansonetti at apple.com
Date:     2009-08-25 13:34:45 -0700 (Tue, 25 Aug 2009)
Log Message:
-----------
Hash#initialize_copy/replace: check if receiver can be modified

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

Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c	2009-08-25 20:25:04 UTC (rev 2373)
+++ MacRuby/trunk/hash.c	2009-08-25 20:34:45 UTC (rev 2374)
@@ -977,14 +977,16 @@
 static VALUE
 rb_hash_replace(VALUE hash, SEL sel, VALUE hash2)
 {
+    rb_hash_modify(hash);
     hash2 = to_hash(hash2);
-    if (hash == hash2) return hash;
+    if (hash == hash2) {
+	return hash;
+    }
     rb_hash_clear(hash, 0);
     rb_hash_foreach(hash2, replace_i, hash);
-    {
-	struct rb_objc_hash_struct *s = rb_objc_hash_get_struct(hash2);
-	if (s != NULL)
-	    rb_objc_hash_set_struct(hash, s->ifnone, s->has_proc_default);
+    struct rb_objc_hash_struct *s = rb_objc_hash_get_struct(hash2);
+    if (s != NULL) {
+	rb_objc_hash_set_struct(hash, s->ifnone, s->has_proc_default);
     }
 
     return hash;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090825/c330c88a/attachment.html>


More information about the macruby-changes mailing list