Modified: MacRuby/trunk/struct.c (4336 => 4337)
--- MacRuby/trunk/struct.c 2010-07-08 23:55:33 UTC (rev 4336)
+++ MacRuby/trunk/struct.c 2010-07-09 00:03:00 UTC (rev 4337)
@@ -813,21 +813,35 @@
*/
static VALUE
+rb_struct_equal_r(VALUE s, VALUE s2, int recur)
+{
+ if (recur) {
+ return Qtrue;
+ }
+ for (int i = 0; i < RSTRUCT_LEN(s); i++) {
+ if (!rb_equal(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) {
+ return Qfalse;
+ }
+ }
+ return Qtrue;
+}
+
+static VALUE
rb_struct_equal(VALUE s, SEL sel, VALUE s2)
{
- long i;
-
- if (s == s2) return Qtrue;
- if (TYPE(s2) != T_STRUCT) return Qfalse;
- if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
+ if (s == s2) {
+ return Qtrue;
+ }
+ if (TYPE(s2) != T_STRUCT) {
+ return Qfalse;
+ }
+ if (rb_obj_class(s) != rb_obj_class(s2)) {
+ return Qfalse;
+ }
if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
rb_bug("inconsistent struct"); /* should never happen */
}
-
- for (i=0; i<RSTRUCT_LEN(s); i++) {
- if (!rb_equal(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
- }
- return Qtrue;
+ return rb_exec_recursive(rb_struct_equal_r, s, s2);
}
/*