ruby-changes:58811
From: Jeremy <ko1@a...>
Date: Mon, 18 Nov 2019 08:39:33 +0900 (JST)
Subject: [ruby-changes:58811] c257303ae7 (master): Deprecate rb_eval_cmd, add rb_eval_cmd_kw
https://git.ruby-lang.org/ruby.git/commit/?id=c257303ae7 From c257303ae78d0e307a80dbe5ccd405abc6e8d44d Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Wed, 25 Sep 2019 15:49:21 -0700 Subject: Deprecate rb_eval_cmd, add rb_eval_cmd_kw rb_eval_cmd takes a safe level, and now that $SAFE is deprecated, it should be deprecated as well. Replace with rb_eval_cmd_kw, which takes a keyword flag. Switch the two callers to this function. diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 8ce3ed7..90d1254 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -435,6 +435,7 @@ void rb_attr(VALUE,ID,int,int,int); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L435 int rb_method_boundp(VALUE, ID, int); int rb_method_basic_definition_p(VALUE, ID); VALUE rb_eval_cmd(VALUE, VALUE, int); +VALUE rb_eval_cmd_kw(VALUE, VALUE, int); int rb_obj_respond_to(VALUE, ID, int); int rb_respond_to(VALUE, ID); NORETURN(VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker)); diff --git a/signal.c b/signal.c index 17aca47..68d68c5 100644 --- a/signal.c +++ b/signal.c @@ -1043,7 +1043,7 @@ signal_exec(VALUE cmd, int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1043 EC_PUSH_TAG(ec); if ((state = EC_EXEC_TAG()) == TAG_NONE) { VALUE signum = INT2NUM(sig); - rb_eval_cmd(cmd, rb_ary_new3(1, signum), 0); + rb_eval_cmd_kw(cmd, rb_ary_new3(1, signum), RB_NO_KEYWORDS); } EC_POP_TAG(); ec = GET_EC(); diff --git a/variable.c b/variable.c index 4b3b172..4fdffcb 100644 --- a/variable.c +++ b/variable.c @@ -526,7 +526,7 @@ rb_define_virtual_variable( https://github.com/ruby/ruby/blob/trunk/variable.c#L526 static void rb_trace_eval(VALUE cmd, VALUE val) { - rb_eval_cmd(cmd, rb_ary_new3(1, val), 0); + rb_eval_cmd_kw(cmd, rb_ary_new3(1, val), RB_NO_KEYWORDS); } VALUE diff --git a/vm_eval.c b/vm_eval.c index 8b557fa..c3f12d7 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1777,7 +1777,7 @@ rb_eval_string_wrap(const char *str, int *pstate) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1777 } VALUE -rb_eval_cmd(VALUE cmd, VALUE arg, int _level) +rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat) { enum ruby_tag_type state; volatile VALUE val = Qnil; /* OK */ @@ -1786,8 +1786,8 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int _level) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1786 EC_PUSH_TAG(ec); if ((state = EC_EXEC_TAG()) == TAG_NONE) { if (!RB_TYPE_P(cmd, T_STRING)) { - val = rb_funcallv(cmd, idCall, RARRAY_LENINT(arg), - RARRAY_CONST_PTR(arg)); + val = rb_funcallv_kw(cmd, idCall, RARRAY_LENINT(arg), + RARRAY_CONST_PTR(arg), kw_splat); } else { val = eval_string_with_cref(rb_vm_top_self(), cmd, NULL, 0, 0); @@ -1799,6 +1799,13 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int _level) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1799 return val; } +VALUE +rb_eval_cmd(VALUE cmd, VALUE arg, int _level) +{ + rb_warn("rb_eval_cmd will be removed in Ruby 3.0"); + return rb_eval_cmd_kw(cmd, arg, RB_NO_KEYWORDS); +} + /* block eval under the class/module context */ static VALUE -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/