summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-02 18:19:04 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-02 18:19:04 +0000
commit76915e433bd4342a6fb507eaafd77cd5dd77bea8 (patch)
tree00265034b9a87396f2690dbbf993f4556202ac73 /compar.c
parent5b1722709e91fd3a2b110a04abe551c0f40a5414 (diff)
* eval.c (backtrace): should ignore line 0 frame.
* sprintf.c (rb_f_sprintf): preceding ".." for negative hexadecimal numbers should not appear if prec (e.g. %.4) is specified. * compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): "<=>" might return nil. check using rb_cmpint(). * error.c (init_syserr): remove sys_nerr dependency. * regex.c (re_match): avoid dereferencing if size == 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@3112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/compar.c b/compar.c
index 3cebc30a80..4cd169ca73 100644
--- a/compar.c
+++ b/compar.c
@@ -21,9 +21,9 @@ cmp_eq(a)
VALUE *a;
{
VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
- int t = NUM2INT(c);
- if (t == 0) return Qtrue;
+ if (NIL_P(c)) return Qfalse;
+ if (rb_cmpint(c) == 0) return Qtrue;
return Qfalse;
}
@@ -51,9 +51,9 @@ cmp_gt(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t > 0) return Qtrue;
+ if (NIL_P(c)) return Qfalse;
+ if (rb_cmpint(c) > 0) return Qtrue;
return Qfalse;
}
@@ -62,9 +62,9 @@ cmp_ge(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t >= 0) return Qtrue;
+ if (NIL_P(c)) return Qfalse;
+ if (rb_cmpint(c) >= 0) return Qtrue;
return Qfalse;
}
@@ -73,9 +73,9 @@ cmp_lt(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t < 0) return Qtrue;
+ if (NIL_P(c)) return Qfalse;
+ if (rb_cmpint(c) < 0) return Qtrue;
return Qfalse;
}
@@ -84,9 +84,9 @@ cmp_le(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t <= 0) return Qtrue;
+ if (NIL_P(c)) return Qfalse;
+ if (rb_cmpint(c) <= 0) return Qtrue;
return Qfalse;
}
@@ -94,13 +94,8 @@ static VALUE
cmp_between(x, min, max)
VALUE x, min, max;
{
- VALUE c = rb_funcall(x, cmp, 1, min);
- long t = NUM2LONG(c);
- if (t < 0) return Qfalse;
-
- c = rb_funcall(x, cmp, 1, max);
- t = NUM2LONG(c);
- if (t > 0) return Qfalse;
+ if (cmp_lt(x, min)) return Qfalse;
+ if (cmp_gt(x, max)) return Qfalse;
return Qtrue;
}