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

ruby-changes:23756

From: ko1 <ko1@a...>
Date: Sat, 26 May 2012 17:09:09 +0900 (JST)
Subject: [ruby-changes:23756] ko1:r35807 (trunk): * vm.c (backtrace_*): change type of lev and n from size_t to int.

ko1	2012-05-26 17:08:16 +0900 (Sat, 26 May 2012)

  New Revision: 35807

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

  Log:
    * vm.c (backtrace_*): change type of lev and n from size_t to int.
      Also set type of rb_backtrace_t#backtrace_size to int.
      A patch from nobu.
    * vm_eval.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/vm.c
    trunk/vm_eval.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35806)
+++ ChangeLog	(revision 35807)
@@ -1,3 +1,11 @@
+Sat May 26 17:05:45 2012  Koichi Sasada  <ko1@a...>
+
+	* vm.c (backtrace_*): change type of lev and n from size_t to int.
+	  Also set type of rb_backtrace_t#backtrace_size to int.
+	  A patch from nobu.
+
+	* vm_eval.c: ditto.
+
 Sat May 26 16:26:30 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* file.c (realpath_rec): UNC prefix does not end with path separator,
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 35806)
+++ vm_eval.c	(revision 35807)
@@ -20,8 +20,8 @@
 static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref);
 static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
 
-static VALUE vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n);
-static VALUE vm_backtrace_frame_ary(rb_thread_t *th, size_t lev, size_t n);
+static VALUE vm_backtrace_str_ary(rb_thread_t *th, int lev, int n);
+static VALUE vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n);
 static void vm_backtrace_print(FILE *fp);
 
 typedef enum call_type {
Index: vm.c
===================================================================
--- vm.c	(revision 35806)
+++ vm.c	(revision 35807)
@@ -1026,7 +1026,7 @@
 typedef struct rb_backtrace_struct {
     rb_frame_info_t *backtrace;
     rb_frame_info_t *backtrace_base;
-    size_t backtrace_size;
+    int backtrace_size;
     VALUE strary;
 } rb_backtrace_t;
 
@@ -1198,9 +1198,13 @@
     VALUE btary;
     int i;
 
+    if (UNLIKELY(lev < 0 || n < 0)) {
+	rb_bug("backtreace_collect: unreachable");
+    }
+
     btary = rb_ary_new();
 
-    for (i=0; i+lev<(int)bt->backtrace_size && i<n; i++) {
+    for (i=0; i+lev<bt->backtrace_size && i<n; i++) {
 	rb_frame_info_t *fi = &bt->backtrace[bt->backtrace_size - 1 - (lev+i)];
 	rb_ary_push(btary, func(fi, arg));
     }
@@ -1230,10 +1234,10 @@
 }
 
 static VALUE
-backtrace_to_str_ary2(VALUE self, size_t lev, size_t n)
+backtrace_to_str_ary2(VALUE self, int lev, int n)
 {
     rb_backtrace_t *bt;
-    size_t size;
+    int size;
     GetCoreDataFromValue(self, rb_backtrace_t, bt);
     size = bt->backtrace_size;
 
@@ -1261,10 +1265,10 @@
 }
 
 static VALUE
-backtrace_to_frame_ary(VALUE self, size_t lev, size_t n)
+backtrace_to_frame_ary(VALUE self, int lev, int n)
 {
     rb_backtrace_t *bt;
-    size_t size;
+    int size;
     GetCoreDataFromValue(self, rb_backtrace_t, bt);
     size = bt->backtrace_size;
 
@@ -1295,13 +1299,13 @@
 }
 
 static VALUE
-vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n)
+vm_backtrace_str_ary(rb_thread_t *th, int lev, int n)
 {
     return backtrace_to_str_ary2(backtrace_object(th), lev, n);
 }
 
 static VALUE
-vm_backtrace_frame_ary(rb_thread_t *th, size_t lev, size_t n)
+vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n)
 {
     return backtrace_to_frame_ary(backtrace_object(th), lev, n);
 }

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

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