diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-04 22:32:40 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-04 22:32:40 +0000 |
commit | 61394a1b5544d525c55241b2ec99187f9da14b24 (patch) | |
tree | 45aa8c0d3c2800fd9e5157979d813ad9332c2194 /range.c | |
parent | d4a0895181eae1867db36b2083fe98c1dabc7e1c (diff) |
* range.c (range_max): max value from ... not defined for non
Integer Numeric end values. [ruby-dev:37690] fix: #974
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -567,14 +567,13 @@ range_min(VALUE range) * */ - static VALUE range_max(VALUE range) { VALUE e = RANGE_END(range); - int ip = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cInteger); + int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric); - if (rb_block_given_p() || (EXCL(range) && !ip)) { + if (rb_block_given_p() || (EXCL(range) && !nm)) { return rb_call_super(0, 0); } else { @@ -584,6 +583,9 @@ range_max(VALUE range) if (c > 0) return Qnil; if (EXCL(range)) { + if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) { + rb_raise(rb_eTypeError, "cannot exclude non Integer end value"); + } if (c == 0) return Qnil; if (FIXNUM_P(e)) { return LONG2NUM(FIX2LONG(e) - 1); @@ -594,6 +596,7 @@ range_max(VALUE range) } } + VALUE rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err) { |