Project

General

Profile

Bug #1885 ยป struct_comparison.diff

marcandre (Marc-Andre Lafortune), 08/31/2009 04:17 AM

View differences:

struct.c (working copy)
return result;
}
static VALUE
recursive_equal(VALUE s, VALUE s2, int recur)
{
long i;
if (recur) return Qtrue; /* Subtle! */
for (i=0; i<RSTRUCT_LEN(s); i++) {
if (!rb_eql(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
}
return Qtrue;
}
/*
* call-seq:
* struct == other_struct => true or false
......
static VALUE
rb_struct_equal(VALUE s, 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;
......
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_paired(recursive_equal, s, s2, s2);
}
static VALUE
......
return rb_exec_recursive(recursive_hash, s, 0);
}
static VALUE
recursive_eql(VALUE s, VALUE s2, int recur)
{
long i;
if (recur) return Qtrue; /* Subtle! */
for (i=0; i<RSTRUCT_LEN(s); i++) {
if (!rb_eql(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
}
return Qtrue;
}
/*
* code-seq:
* struct.eql?(other) => true or false
......
static VALUE
rb_struct_eql(VALUE s, 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;
......
rb_bug("inconsistent struct"); /* should never happen */
}
for (i=0; i<RSTRUCT_LEN(s); i++) {
if (!rb_eql(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
}
return Qtrue;
return rb_exec_recursive_paired(recursive_eql, s, s2, s2);
}
/*
    (1-1/1)