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

ruby-changes:57340

From: TO <ko1@a...>
Date: Wed, 28 Aug 2019 00:24:19 +0900 (JST)
Subject: [ruby-changes:57340] Re: ruby-cvs Digest, Vol 73, Issue 50

https://git.ruby-lang.org/ruby.git/commit/?id=5c7c2d9951

From 5c7c2d9951f2512ca10ea38fecc48d8ac67502e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 26 Aug 2019 14:51:00 +0900
Subject: rb_rescue / rb_rescue2 now free from ANYARGS

After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_rescue / rb_rescue2, which revealed many arity / type mismatches.

diff --git a/enum.c b/enum.c
index 665c97f..829d67a 100644
--- a/enum.c
+++ b/enum.c
@@ -2723,14 +2723,16 @@ zip_ary(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval)) https://github.com/ruby/ruby/blob/trunk/enum.c#L2723
 }
 
 static VALUE
-call_next(VALUE *v)
+call_next(VALUE w)
 {
+    VALUE *v = (VALUE *)w;
     return v[0] = rb_funcallv(v[1], id_next, 0, 0);
 }
 
 static VALUE
-call_stop(VALUE *v)
+call_stop(VALUE w, VALUE _)
 {
+    VALUE *v = (VALUE *)w;
     return v[0] = Qundef;
 }
 
diff --git a/enumerator.c b/enumerator.c
index beea1c7..afc9ed9 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -2231,7 +2231,7 @@ call_next(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2231
 }
 
 static VALUE
-next_stopped(VALUE obj)
+next_stopped(VALUE obj, VALUE _)
 {
     return Qnil;
 }
diff --git a/eval.c b/eval.c
index 01e4fa6..b06e87f 100644
--- a/eval.c
+++ b/eval.c
@@ -931,8 +931,8 @@ rb_need_block(void) https://github.com/ruby/ruby/blob/trunk/eval.c#L931
  * \ingroup exception
  */
 VALUE
-rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
-	   VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
+rb_rescue2(VALUE (* b_proc) (VALUE), VALUE data1,
+           VALUE (* r_proc) (VALUE, VALUE), VALUE data2, ...)
 {
     enum ruby_tag_type state;
     rb_execution_context_t * volatile ec = GET_EC();
@@ -1003,8 +1003,8 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1, https://github.com/ruby/ruby/blob/trunk/eval.c#L1003
  * \ingroup exception
  */
 VALUE
-rb_rescue(VALUE (* b_proc)(ANYARGS), VALUE data1,
-	  VALUE (* r_proc)(ANYARGS), VALUE data2)
+rb_rescue(VALUE (* b_proc)(VALUE), VALUE data1,
+          VALUE (* r_proc)(VALUE, VALUE), VALUE data2)
 {
     return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError,
 		      (VALUE)0);
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index f1fd2b5..e84e565 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -140,7 +140,7 @@ static void gzfile_reset(struct gzfile*); https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L140
 static void gzfile_close(struct gzfile*, int);
 static void gzfile_write_raw(struct gzfile*);
 static VALUE gzfile_read_raw_partial(VALUE);
-static VALUE gzfile_read_raw_rescue(VALUE);
+static VALUE gzfile_read_raw_rescue(VALUE,VALUE);
 static VALUE gzfile_read_raw(struct gzfile*, VALUE outbuf);
 static int gzfile_read_raw_ensure(struct gzfile*, long, VALUE outbuf);
 static char *gzfile_read_raw_until_zero(struct gzfile*, long);
@@ -2385,7 +2385,7 @@ gzfile_read_raw_partial(VALUE arg) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L2385
 }
 
 static VALUE
-gzfile_read_raw_rescue(VALUE arg)
+gzfile_read_raw_rescue(VALUE arg, VALUE _)
 {
     struct read_raw_arg *ra = (struct read_raw_arg *)arg;
     VALUE str = Qnil;
@@ -4888,5 +4888,3 @@ Init_zlib(void) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L4888
  * Raised when the data length recorded in the gzip file footer is not equivalent
  * to the length of the actual uncompressed data.
  */
-
-
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 1f05dd4..b1e5b0d 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1966,8 +1966,8 @@ int rb_block_given_p(void); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1966
 void rb_need_block(void);
 VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
 VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE);
-VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...);
+VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
+VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
 VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
 VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
 VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);
diff --git a/io.c b/io.c
index e918f1c..8f48ba1 100644
--- a/io.c
+++ b/io.c
@@ -11457,7 +11457,7 @@ copy_stream_fallback(struct copy_stream_struct *stp) https://github.com/ruby/ruby/blob/trunk/io.c#L11457
 	rb_raise(rb_eArgError, "cannot specify src_offset for non-IO");
     }
     rb_rescue2(copy_stream_fallback_body, (VALUE)stp,
-               (VALUE (*) (ANYARGS))0, (VALUE)0,
+               (VALUE (*) (VALUE, VALUE))0, (VALUE)0,
                rb_eEOFError, (VALUE)0);
     return Qnil;
 }
diff --git a/time.c b/time.c
index 40b2f06..1e760f6 100644
--- a/time.c
+++ b/time.c
@@ -5204,7 +5204,7 @@ mload_zone(VALUE time, VALUE zone) https://github.com/ruby/ruby/blob/trunk/time.c#L5204
     VALUE z, args[2];
     args[0] = time;
     args[1] = zone;
-    z = rb_rescue(mload_findzone, (VALUE)args, (VALUE (*)(ANYARGS))NULL, Qnil);
+    z = rb_rescue(mload_findzone, (VALUE)args, 0, Qnil);
     if (NIL_P(z)) return rb_fstring(zone);
     if (RB_TYPE_P(z, T_STRING)) return rb_fstring(z);
     return z;
diff --git a/vm_eval.c b/vm_eval.c
index 2670c2c..e9045bb 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -322,16 +322,18 @@ struct rescue_funcall_args { https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L322
 };
 
 static VALUE
-check_funcall_exec(struct rescue_funcall_args *args)
+check_funcall_exec(VALUE v)
 {
+    struct rescue_funcall_args *args = (void *)v;
     return call_method_entry(args->ec, args->defined_class,
 			     args->recv, idMethodMissing,
 			     args->me, args->argc, args->argv);
 }
 
 static VALUE
-check_funcall_failed(struct rescue_funcall_args *args, VALUE e)
+check_funcall_failed(VALUE v, VALUE e)
 {
+    struct rescue_funcall_args *args = (void *)v;
     int ret = args->respond;
     if (!ret) {
 	switch (rb_method_boundp(args->defined_class, args->mid,
@@ -1075,7 +1077,7 @@ rb_yield_block(VALUE val, VALUE arg, int argc, const VALUE *argv, VALUE blockarg https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1077
 }
 
 static VALUE
-loop_i(void)
+loop_i(VALUE _)
 {
     for (;;) {
 	rb_yield_0(0, 0);
-- 
cgit v0.10.2


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

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