summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-13 11:00:28 (GMT)
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-13 11:00:28 (GMT)
commit606d6b34706c590fe0449b0c160281e729be0484 (patch)
tree7e95a9e7da6913fde1d89a51a31a38c5e5297f4b /range.c
parent4f4ed3e9eaea5c90c23c1bbfb7c1ff08331ad18a (diff)
Revert "range.c: prohibit `(1..nil)`"
This reverts commit a44c010764a16ae09aaed49d76eec055ca0057c8. Refs #14845. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/range.c b/range.c
index c9521dc..dcae2b2 100644
--- a/range.c
+++ b/range.c
@@ -37,7 +37,7 @@ static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
static void
range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end)
{
- if ((!FIXNUM_P(beg) || !FIXNUM_P(end)) && end != Qundef) {
+ if ((!FIXNUM_P(beg) || !FIXNUM_P(end)) && !NIL_P(end)) {
VALUE v;
v = rb_funcall(beg, id_cmp, 1, end);
@@ -47,16 +47,15 @@ range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end)
RANGE_SET_EXCL(range, exclude_end);
RANGE_SET_BEG(range, beg);
- RANGE_SET_END(range, end == Qundef ? Qnil : end);
+ RANGE_SET_END(range, end);
}
VALUE
-rb_range_new(VALUE beg, VALUE end, int flag)
+rb_range_new(VALUE beg, VALUE end, int exclude_end)
{
VALUE range = rb_obj_alloc(rb_cRange);
- if (flag & 2) end = Qundef;
- range_init(range, beg, end, RBOOL(flag & 1));
+ range_init(range, beg, end, RBOOL(exclude_end));
return range;
}
@@ -86,7 +85,6 @@ range_initialize(int argc, VALUE *argv, VALUE range)
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
range_modify(range);
- if (NIL_P(end)) end = Qundef;
range_init(range, beg, end, RBOOL(RTEST(flags)));
return Qnil;
}
@@ -1341,7 +1339,7 @@ range_dumper(VALUE range)
rb_ivar_set(v, id_excl, RANGE_EXCL(range));
rb_ivar_set(v, id_beg, RANGE_BEG(range));
- if (!NIL_P(RANGE_END(range))) rb_ivar_set(v, id_end, RANGE_END(range));
+ rb_ivar_set(v, id_end, RANGE_END(range));
return v;
}
@@ -1356,7 +1354,7 @@ range_loader(VALUE range, VALUE obj)
range_modify(range);
beg = rb_ivar_get(obj, id_beg);
- end = rb_ivar_lookup(obj, id_end, Qundef);
+ end = rb_ivar_get(obj, id_end);
excl = rb_ivar_get(obj, id_excl);
if (!NIL_P(excl)) {
range_init(range, beg, end, RBOOL(RTEST(excl)));