summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-19 16:40:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-19 16:40:23 +0000
commitef7fdbd71ea0d9b98ac0f70a55077f71c080d6c6 (patch)
tree352bf068e2f1d0621ef464299bcc8308d4577019 /array.c
parentf5dd2cf3bab25e2d83502d21a4bf227efd5494bb (diff)
* array.c (rb_ary_equal, rb_ary_eql, rb_ary_hash, rb_ary_cmp):
Make Array#eql?, #hash, #== and #<=> use rb_protect_inspect() and handle recursive data properly. [ruby-dev:35181] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/array.c b/array.c
index 101779c053..e99a5816d3 100644
--- a/array.c
+++ b/array.c
@@ -2468,7 +2468,6 @@ recursive_equal(ary1, ary2)
{
long i;
- if (rb_inspecting_p(ary1)) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
@@ -2502,6 +2501,7 @@ rb_ary_equal(ary1, ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
+ if (rb_inspecting_p(ary1)) return Qfalse;
return rb_protect_inspect(recursive_equal, ary1, ary2);
}
@@ -2511,7 +2511,6 @@ recursive_eql(ary1, ary2)
{
long i;
- if (rb_inspecting_p(ary1)) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
@@ -2534,6 +2533,7 @@ rb_ary_eql(ary1, ary2)
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
+ if (rb_inspecting_p(ary1)) return Qfalse;
return rb_protect_inspect(recursive_eql, ary1, ary2);
}
@@ -2546,9 +2546,6 @@ recursive_hash(ary)
long i, h;
VALUE n;
- if (rb_inspecting_p(ary)) {
- return LONG2FIX(0);
- }
h = RARRAY(ary)->len;
for (i=0; i<RARRAY(ary)->len; i++) {
h = (h << 1) | (h<0 ? 1 : 0);
@@ -2570,6 +2567,9 @@ static VALUE
rb_ary_hash(ary)
VALUE ary;
{
+ if (rb_inspecting_p(ary)) {
+ return LONG2FIX(0);
+ }
return rb_protect_inspect(recursive_hash, ary, 0);
}
@@ -2607,7 +2607,6 @@ recursive_cmp(ary1, ary2)
{
long i, len;
- if (rb_inspecting_p(ary1)) return Qfalse;
len = RARRAY(ary1)->len;
if (len > RARRAY(ary2)->len) {
len = RARRAY(ary2)->len;
@@ -2650,6 +2649,7 @@ rb_ary_cmp(ary1, ary2)
ary2 = to_ary(ary2);
if (ary1 == ary2) return INT2FIX(0);
+ if (rb_inspecting_p(ary1)) return INT2FIX(0);
v = rb_protect_inspect(recursive_cmp, ary1, ary2);
if (v != Qundef) return v;
len = RARRAY(ary1)->len - RARRAY(ary2)->len;