Skip to content

Commit

Permalink
* range.c (range_max): max value from ... not defined for non
Browse files Browse the repository at this point in the history
  Integer Numeric end values. [ruby-dev:37690] fix: ruby#974

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jan 4, 2009
1 parent d4a0895 commit 61394a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Jan 5 06:39:56 2009 Yukihiro Matsumoto <[email protected]>

* 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 <[email protected]>

* ext/socket/socket.c (rb_getaddrinfo): defined for address lookup without GVL.
Expand Down
9 changes: 6 additions & 3 deletions range.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -594,6 +596,7 @@ range_max(VALUE range)
}
}


VALUE
rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
{
Expand Down

0 comments on commit 61394a1

Please sign in to comment.