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

ruby-changes:4422

From: ko1@a...
Date: Mon, 7 Apr 2008 12:15:39 +0900 (JST)
Subject: [ruby-changes:4422] nobu - Ruby:r15913 (trunk): * range.c (range_each_func): should not leave a variable

nobu	2008-04-07 12:15:26 +0900 (Mon, 07 Apr 2008)

  New Revision: 15913

  Modified files:
    trunk/ChangeLog
    trunk/range.c

  Log:
    * range.c (range_each_func): should not leave a variable
      uninitialized, which could cause SEGV.
    
    * range.c (range_step): removed duplicated and unreachable code.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15913&r2=15912&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/range.c?r1=15913&r2=15912&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15912)
+++ ChangeLog	(revision 15913)
@@ -1,3 +1,10 @@
+Mon Apr  7 12:15:24 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* range.c (range_each_func): should not leave a variable
+	  uninitialized, which could cause SEGV.
+
+	* range.c (range_step): removed duplicated and unreachable code.
+
 Mon Apr  7 02:12:27 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* string.c (rb_str_intern): need not to check if tainted.
Index: range.c
===================================================================
--- range.c	(revision 15912)
+++ range.c	(revision 15913)
@@ -228,7 +228,7 @@
     int c;
     VALUE b = RANGE_BEG(range);
     VALUE e = RANGE_END(range);
-    VALUE v;
+    VALUE v = b;
 
     if (EXCL(range)) {
 	while (r_lt(v, e)) {
@@ -295,9 +295,8 @@
 static VALUE
 range_step(int argc, VALUE *argv, VALUE range)
 {
-    VALUE b, e, step, tmp, c;
+    VALUE b, e, step, tmp;
     long unit;
-    int nv;
 
     RETURN_ENUMERATOR(range, argc, argv);
 
@@ -361,16 +360,6 @@
 	    iter[1] = step;
 	    rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter);
 	}
-	else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
-	    ID c = rb_intern(EXCL(range) ? "<" : "<=");
-
-	    if (rb_equal(step, INT2FIX(0)))
-		rb_raise(rb_eArgError, "step can't be 0");
-	    while (RTEST(rb_funcall(b, c, 1, e))) {
-		rb_yield(b);
-		b = rb_funcall(b, '+', 1, step);
-	    }
-	}
 	else {
 	    VALUE args[2];
 

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

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