diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | range.c | 9 |
2 files changed, 11 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Mon Jan 5 06:39:56 2009 Yukihiro Matsumoto <matz@ruby-lang.org> + + * range.c (range_max): max value from ... not defined for non + Integer Numeric end values. [ruby-dev:37690] fix: #974 + Sun Jan 4 22:37:19 2009 Tanaka Akira <akr@fsij.org> * ext/socket/socket.c (rb_getaddrinfo): defined for address lookup without GVL. @@ -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) { |