Skip to content

Commit

Permalink
Fix an off by one error in my Range#relative_to workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrous26 committed Mar 31, 2012
1 parent 4defae5 commit 7a4effc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion range.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ range_relative_to(VALUE range, SEL sel, VALUE max)
{
long beg, len, m = NUM2LONG(max);
rb_range_beg_len(range, &beg, &len, m, 0);
if (beg + len - 1 > m)
if (beg + len > m)
len -= 1;
return rb_range_new(LONG2NUM(beg), LONG2NUM(beg + len - 1), 0);
}
Expand Down

0 comments on commit 7a4effc

Please sign in to comment.