summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-03 05:20:14 (GMT)
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-03 05:20:14 (GMT)
commit6f484e4930be69c58462dd11c97663e6c8488b8e (patch)
tree324b1dbdf4149be943eb3cbff26ad7f377e53dc0 /compar.c
parent20254d4e133331e69e6aa7514e1e72ad7d14d496 (diff)
* variable.c (rb_copy_generic_ivar): remove old generic instance
variable table if it existes. * class.c (rb_make_metaclass): metaclass of a metaclass is a metaclass itself. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/compar.c b/compar.c
index ebdd47a..3647f9b 100644
--- a/compar.c
+++ b/compar.c
@@ -23,7 +23,10 @@ cmp_equal(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) == 0) return Qtrue;
+ if (c == INT2FIX(0)) return Qtrue;
+ if (TYPE(c) == T_BIGNUM) {
+ if (rb_big_norm(c) == INT2FIX(0)) return Qtrue;
+ }
return Qfalse;
}
@@ -34,7 +37,11 @@ cmp_gt(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) > 0) return Qtrue;
+ if (FIXNUM_P(c) && FIX2INT(c) > 0) return Qtrue;
+ if (TYPE(c) == T_BIGNUM) {
+ if (rb_big_norm(x) == INT2FIX(0)) return Qfalse;
+ if (RBIGNUM(c)->sign) return Qtrue;
+ }
return Qfalse;
}
@@ -45,7 +52,11 @@ cmp_ge(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) >= 0) return Qtrue;
+ if (FIXNUM_P(c) && FIX2INT(c) >= 0) return Qtrue;
+ if (TYPE(c) == T_BIGNUM) {
+ if (rb_big_norm(x) == INT2FIX(0)) return Qtrue;
+ if (RBIGNUM(c)->sign) return Qtrue;
+ }
return Qfalse;
}
@@ -55,8 +66,11 @@ cmp_lt(x, y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
- if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) < 0) return Qtrue;
+ if (FIXNUM_P(c) && FIX2INT(c) < 0) return Qtrue;
+ if (TYPE(c) == T_BIGNUM) {
+ if (rb_big_norm(x) == INT2FIX(0)) return Qfalse;
+ if (!RBIGNUM(c)->sign) return Qtrue;
+ }
return Qfalse;
}
@@ -67,7 +81,11 @@ cmp_le(x, y)
VALUE c = rb_funcall(x, cmp, 1, y);
if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) <= 0) return Qtrue;
+ if (FIXNUM_P(c) && FIX2INT(c) <= 0) return Qtrue;
+ if (TYPE(c) == T_BIGNUM) {
+ if (rb_big_norm(x) == INT2FIX(0)) return Qtrue;
+ if (!RBIGNUM(c)->sign) return Qtrue;
+ }
return Qfalse;
}
@@ -75,14 +93,8 @@ static VALUE
cmp_between(x, min, max)
VALUE x, min, max;
{
- VALUE c = rb_funcall(x, cmp, 1, min);
-
- if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) < 0) return Qfalse;
-
- c = rb_funcall(x, cmp, 1, max);
- if (NIL_P(c)) return Qfalse;
- if (NUM2LONG(c) > 0) return Qfalse;
+ if (cmp_lt(x, min)) return Qfalse;
+ if (cmp_gt(x, max)) return Qfalse;
return Qtrue;
}