summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-30 16:33:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-30 16:33:32 +0000
commit394738639ed4b4d2bacb40a1ac170950b09cbd95 (patch)
tree79f6160bf89ffba6449eb884f76af8c5f3224651 /compar.c
parent2c2b30dde4f7b26fbe63b6ba74f2bc7ac98d35ba (diff)
031031
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/compar.c b/compar.c
index d6cca36137..5376ce4452 100644
--- a/compar.c
+++ b/compar.c
@@ -53,18 +53,32 @@ rb_cmperr(x, y)
#define cmperr() (rb_cmperr(x, y), Qnil)
static VALUE
+cmp_eq(a)
+ VALUE *a;
+{
+ VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
+
+ if (NIL_P(c)) return Qnil;
+ if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
+ return Qfalse;
+}
+
+static VALUE
+cmp_failed()
+{
+ return Qnil;
+}
+
+static VALUE
cmp_equal(x, y)
VALUE x, y;
{
- int c;
+ VALUE a[2];
if (x == y) return Qtrue;
- c = rb_funcall(x, cmp, 1, y);
- if (NIL_P(c)) return Qnil;
- if (c == INT2FIX(0)) return Qtrue;
- if (rb_cmpint(c, x, y) == 0) return Qtrue;
- return Qfalse;
+ a[0] = x; a[1] = y;
+ return rb_rescue(cmp_eq, (VALUE)a, cmp_failed, 0);
}
static VALUE