summaryrefslogtreecommitdiffstats
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
commitc6da742a3bd1c9fcad592a871b3387f0a63cf76b (patch)
tree79f6160bf89ffba6449eb884f76af8c5f3224651 /compar.c
parentce8a0a4d0b37e145323fe5d139b0ce1a433fd7a4 (diff)
downloadruby-c6da742a3bd1c9fcad592a871b3387f0a63cf76b.tar.gz
ruby-c6da742a3bd1c9fcad592a871b3387f0a63cf76b.tar.xz
ruby-c6da742a3bd1c9fcad592a871b3387f0a63cf76b.zip
031031
git-svn-id: http://svn.ruby-lang.org/repos/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 d6cca3613..5376ce445 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