summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-20 20:40:20 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-20 20:40:20 +0000
commit64db238388ecf74d3d2e26524bb5d0f6eb70f152 (patch)
tree79088735efd0839894fa930ce65f275cd98d6b55 /compar.c
parent697462490a8099a765e34523e30867e4ca65a202 (diff)
downloadruby-64db238388ecf74d3d2e26524bb5d0f6eb70f152.tar.gz
* string.c (rb_str_cmp_m): return nil if str2 does not respond to
both "to_str" and "<=>". * compar.c (cmp_gt): return nil if "<=>" returns nil (means incomparable). * compar.c (cmp_ge): ditto. * compar.c (cmp_lt): ditto. * compar.c (cmp_between): use RTEST(), since cmp_lt and cmp_gt may return nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/compar.c b/compar.c
index 3b6622cce1..42258d59cb 100644
--- a/compar.c
+++ b/compar.c
@@ -50,7 +50,7 @@ cmp_gt(x, y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
- if (NIL_P(c)) return Qfalse;
+ if (NIL_P(c)) return Qnil;
if (rb_cmpint(c) > 0) return Qtrue;
return Qfalse;
}
@@ -61,7 +61,7 @@ cmp_ge(x, y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
- if (NIL_P(c)) return Qfalse;
+ if (NIL_P(c)) return Qnil;
if (rb_cmpint(c) >= 0) return Qtrue;
return Qfalse;
}
@@ -72,7 +72,7 @@ cmp_lt(x, y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
- if (NIL_P(c)) return Qfalse;
+ if (NIL_P(c)) return Qnil;
if (rb_cmpint(c) < 0) return Qtrue;
return Qfalse;
}
@@ -83,7 +83,7 @@ cmp_le(x, y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
- if (NIL_P(c)) return Qfalse;
+ if (NIL_P(c)) return Qnil;
if (rb_cmpint(c) <= 0) return Qtrue;
return Qfalse;
}
@@ -92,8 +92,8 @@ static VALUE
cmp_between(x, min, max)
VALUE x, min, max;
{
- if (cmp_lt(x, min)) return Qfalse;
- if (cmp_gt(x, max)) return Qfalse;
+ if (RTEST(cmp_lt(x, min))) return Qfalse;
+ if (RTEST(cmp_gt(x, max))) return Qfalse;
return Qtrue;
}