* 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
This commit is contained in:
parent
d4a0895181
commit
61394a1b55
@ -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.
|
||||
|
9
range.c
9
range.c
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user