[macruby-changes] [5066] MacRuby/trunk/struct.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Dec 21 20:00:05 PST 2010
Revision: 5066
http://trac.macosforge.org/projects/ruby/changeset/5066
Author: lsansonetti at apple.com
Date: 2010-12-21 20:00:02 -0800 (Tue, 21 Dec 2010)
Log Message:
-----------
fix a bug in Struct#hash when called on recursive structs
Modified Paths:
--------------
MacRuby/trunk/struct.c
Modified: MacRuby/trunk/struct.c
===================================================================
--- MacRuby/trunk/struct.c 2010-12-22 03:34:08 UTC (rev 5065)
+++ MacRuby/trunk/struct.c 2010-12-22 04:00:02 UTC (rev 5066)
@@ -853,20 +853,25 @@
*/
static VALUE
-rb_struct_hash(VALUE s, SEL sel)
+rb_struct_hash_r(VALUE s, VALUE s2, int recur)
{
- long i, h;
- VALUE n;
-
- h = rb_hash(rb_obj_class(s));
- for (i = 0; i < RSTRUCT_LEN(s); i++) {
- h = (h << 1) | (h<0 ? 1 : 0);
- n = rb_hash(RSTRUCT_PTR(s)[i]);
- h ^= NUM2LONG(n);
+ long h = rb_hash(rb_obj_class(s));
+ if (!recur) {
+ for (long i = 0; i < RSTRUCT_LEN(s); i++) {
+ h = (h << 1) | (h < 0 ? 1 : 0);
+ VALUE n = rb_hash(RSTRUCT_PTR(s)[i]);
+ h ^= NUM2LONG(n);
+ }
}
return LONG2FIX(h);
}
+static VALUE
+rb_struct_hash(VALUE s, SEL sel)
+{
+ return rb_exec_recursive(rb_struct_hash_r, s, Qnil);
+}
+
/*
* code-seq:
* struct.eql?(other) => true or false
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101221/f26cf519/attachment.html>
More information about the macruby-changes
mailing list