summaryrefslogtreecommitdiffstats
path: root/range.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-02 04:49:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-02 04:49:46 +0000
commit3717865af5630794e31e1f92222072bd15426318 (patch)
treea1a78a9425305557dcff6569806876989c9098c3 /range.c
parent453f1eaf38c4540859df047a4a608ccbeb714c9b (diff)
downloadruby-3717865af5630794e31e1f92222072bd15426318.tar.gz
ruby-3717865af5630794e31e1f92222072bd15426318.tar.xz
ruby-3717865af5630794e31e1f92222072bd15426318.zip
* array.c (push_values_at): Array#values_at should work with
ranges too. * range.c (rb_range_beg_len): length calculation was wrong. * eval.c (rb_call): should set T_ICLASS in the frame->last_class. [ruby-core:01110] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/range.c b/range.c
index 5d398b5e6..b7ef17544 100644
--- a/range.c
+++ b/range.c
@@ -369,27 +369,22 @@ rb_range_beg_len(range, begp, lenp, len, err)
}
if (err == 0 || err == 2) {
if (beg > len) goto out_of_range;
- if (end > len || (!EXCL(range) && end == len))
+ if (end > len)
end = len;
}
if (end < 0) {
end += len;
if (end < 0) {
- if (beg == 0 && end == -1 && !EXCL(range)) {
- len = 0;
- goto length_set;
- }
goto out_of_range;
}
}
+ if (!EXCL(range)) end++; /* include end point */
len = end - beg;
- if (!EXCL(range)) len++; /* include end point */
if (len < 0) goto out_of_range;
length_set:
*begp = beg;
*lenp = len;
-
return Qtrue;
out_of_range: