summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--lib/net/http/header.rb3
-rw-r--r--range.c17
3 files changed, 7 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c2ca95280..574027ecf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Aug 8 10:27:18 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * range.c (range_last): revert r42400. [Bug #8739]
+
Thu Aug 8 10:26:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_str_normalize_ospath): extract and move from dir.c.
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 04981406d3..029b647b5e 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -237,7 +237,8 @@ module Net::HTTPHeader
rangestr = (n > 0 ? "0-#{n-1}" : "-#{-n}")
when Range
first = r.first
- last = r.last
+ last = r.end
+ last -= 1 if r.exclude_end?
if last == -1
rangestr = (first > 0 ? "#{first}-" : "-#{-first}")
else
diff --git a/range.c b/range.c
index 007625469e..8fa7dcb3ba 100644
--- a/range.c
+++ b/range.c
@@ -887,22 +887,7 @@ range_first(int argc, VALUE *argv, VALUE range)
static VALUE
range_last(int argc, VALUE *argv, VALUE range)
{
- if (argc == 0) {
- VALUE e = RANGE_END(range);
- if (!EXCL(range)) return e; /* inclusive, the end is the last */
- /* exclusive, the last is previous to the end */
- if (FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric)) {
- VALUE pred = rb_int_pred(e);
- if (!r_lt(RANGE_BEG(range), pred)) {
- /* TODO: what should be returned, or should raise an
- * exception? */
- pred = Qnil;
- }
- return pred;
- }
-
- /* fallback to Array */
- }
+ if (argc == 0) return RANGE_END(range);
return rb_ary_last(argc, argv, rb_Array(range));
}