[前][次][番号順一覧][スレッド一覧]

ruby-changes:31341

From: nobu <ko1@a...>
Date: Fri, 25 Oct 2013 15:57:25 +0900 (JST)
Subject: [ruby-changes:31341] nobu:r43420 (trunk): range.c: fix int and VALUE

nobu	2013-10-25 15:57:20 +0900 (Fri, 25 Oct 2013)

  New Revision: 43420

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43420

  Log:
    range.c: fix int and VALUE
    
    * range.c (SET_EXCL): set boolean always.
    
    * range.c (range_init): fix int flag and boolean VALUE.

  Modified files:
    trunk/range.c
Index: range.c
===================================================================
--- range.c	(revision 43419)
+++ range.c	(revision 43420)
@@ -28,13 +28,15 @@ static ID id_cmp, id_succ, id_beg, id_en https://github.com/ruby/ruby/blob/trunk/range.c#L28
 #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) https://github.com/ruby/ruby/blob/trunk/range.c#L53
 }
 
 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 https://github.com/ruby/ruby/blob/trunk/range.c#L68
 	    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 e https://github.com/ruby/ruby/blob/trunk/range.c#L78
 {
     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, https://github.com/ruby/ruby/blob/trunk/range.c#L101
     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;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]