summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-13 02:33:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-13 02:33:11 +0000
commit113a709cce1baf1623ad8457a08585c5db49a5df (patch)
treef0ddec7c3c14aad37dbd4cbfbcee38483430c3ee /range.c
parent608545ced079d61569951461406eea45c64f6221 (diff)
* range.c (range_max, range_min): return nil for empty set as well as
1.8 and Enumerable. [ruby-dev:31198] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/range.c b/range.c
index a63919d0d9..15615a46bc 100644
--- a/range.c
+++ b/range.c
@@ -468,7 +468,7 @@ range_min(VALUE range)
VALUE e = rb_ivar_get(range, id_end);
int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
- if (c > 0)
+ if (c > 0 || (c == 0 && EXCL(range)))
return Qnil;
return b;
}
@@ -502,6 +502,7 @@ range_max(VALUE range)
if (c > 0)
return Qnil;
if (EXCL(range)) {
+ if (c == 0) return Qnil;
if (FIXNUM_P(e)) {
return LONG2NUM(FIX2LONG(e) - 1);
}