From 394738639ed4b4d2bacb40a1ac170950b09cbd95 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 30 Oct 2003 16:33:32 +0000 Subject: 031031 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compar.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'compar.c') diff --git a/compar.c b/compar.c index d6cca36137..5376ce4452 100644 --- a/compar.c +++ b/compar.c @@ -52,19 +52,33 @@ 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 -- cgit v1.2.3