1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

range.c: revert r42400

* range.c (range_last): revert r42400.  [Bug #8739]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-08-08 01:27:19 +00:00
parent 354028abe1
commit 0be97c7015
3 changed files with 7 additions and 17 deletions

View file

@ -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> 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. * file.c (rb_str_normalize_ospath): extract and move from dir.c.

View file

@ -237,7 +237,8 @@ module Net::HTTPHeader
rangestr = (n > 0 ? "0-#{n-1}" : "-#{-n}") rangestr = (n > 0 ? "0-#{n-1}" : "-#{-n}")
when Range when Range
first = r.first first = r.first
last = r.last last = r.end
last -= 1 if r.exclude_end?
if last == -1 if last == -1
rangestr = (first > 0 ? "#{first}-" : "-#{-first}") rangestr = (first > 0 ? "#{first}-" : "-#{-first}")
else else

17
range.c
View file

@ -887,22 +887,7 @@ range_first(int argc, VALUE *argv, VALUE range)
static VALUE static VALUE
range_last(int argc, VALUE *argv, VALUE range) range_last(int argc, VALUE *argv, VALUE range)
{ {
if (argc == 0) { if (argc == 0) return RANGE_END(range);
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 */
}
return rb_ary_last(argc, argv, rb_Array(range)); return rb_ary_last(argc, argv, rb_Array(range));
} }