summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-25 06:57:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-25 06:57:20 +0000
commita2231670d6b0f696d59e0425aa28cfb0ab5a6547 (patch)
treee9687e123f1c62c6646f749d2ef6fbfb61339da8
parenta6d095bd229f84be90fa9138e63fb17c01434d7d (diff)
range.c: fix int and VALUE
* range.c (SET_EXCL): set boolean always. * range.c (range_init): fix int flag and boolean VALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--range.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/range.c b/range.c
index a325c31..99fdf9c 100644
--- a/range.c
+++ b/range.c
@@ -28,13 +28,15 @@ static ID id_cmp, id_succ, id_beg, id_end, id_excl, id_integer_p, id_div;
#define RANGE_SET_BEG(r, v) (RSTRUCT_SET(r, 0, v))
#define RANGE_SET_END(r, v) (RSTRUCT_SET(r, 1, v))
#define RANGE_SET_EXCL(r, v) (RSTRUCT_SET(r, 2, v))
+#define RBOOL(v) ((v) ? Qtrue : Qfalse)
#define EXCL(r) RTEST(RANGE_EXCL(r))
static inline VALUE
SET_EXCL(VALUE r, VALUE v)
{
+ v = RBOOL(RTEST(v));
RANGE_SET_EXCL(r, v);
- return v ? Qtrue : Qfalse;
+ return v;
}
static VALUE
@@ -51,7 +53,7 @@ range_check(VALUE *args)
}
static void
-range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
+range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end)
{
VALUE args[2];
@@ -66,7 +68,7 @@ range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
range_failed();
}
- SET_EXCL(range, exclude_end);
+ RANGE_SET_EXCL(range, exclude_end);
RANGE_SET_BEG(range, beg);
RANGE_SET_END(range, end);
}
@@ -76,7 +78,7 @@ rb_range_new(VALUE beg, VALUE end, int exclude_end)
{
VALUE range = rb_obj_alloc(rb_cRange);
- range_init(range, beg, end, exclude_end);
+ range_init(range, beg, end, RBOOL(exclude_end));
return range;
}
@@ -99,7 +101,7 @@ range_initialize(int argc, VALUE *argv, VALUE range)
if (RANGE_EXCL(range) != Qnil) {
rb_name_error(idInitialize, "`initialize' called twice");
}
- range_init(range, beg, end, RTEST(flags));
+ range_init(range, beg, end, RBOOL(RTEST(flags)));
return Qnil;
}