diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-15 02:09:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-15 02:09:27 +0000 |
commit | 0472578b26793e45434769200a806cb6190e5700 (patch) | |
tree | 46dbee7a4fdfe609699e9b24f733b3041c8330c4 | |
parent | 6f1fbfd6187db01e3c3967468cc8b182fc8ca847 (diff) |
ruby.h: check argc to rb_funcall
* include/ruby/ruby.h (rb_funcall): check if argc matches the
number of variadic arguments, and replace with rb_funcallv.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | error.c | 2 | ||||
-rw-r--r-- | include/ruby/ruby.h | 11 | ||||
-rw-r--r-- | numeric.c | 2 | ||||
-rw-r--r-- | parse.y | 8 | ||||
-rw-r--r-- | vm_eval.c | 1 |
5 files changed, 22 insertions, 2 deletions
@@ -963,7 +963,7 @@ rb_get_backtrace(VALUE exc) return Qnil; return rb_check_backtrace(info); } - return rb_funcall(exc, mid, 0, 0); + return rb_funcallv(exc, mid, 0, 0); } /* diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 9cf0b4c6b0..0b277dce19 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2450,6 +2450,17 @@ __extension__({ \ rb_varargs_argc_check(rb_yield_values_argc, rb_yield_values_nargs), \ rb_yield_values_args); \ }) + +# define rb_funcall(recv, mid, argc, ...) \ +__extension__({ \ + const int rb_funcall_argc = (argc); \ + const VALUE rb_funcall_args[] = {__VA_ARGS__}; \ + const int rb_funcall_nargs = \ + (int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \ + rb_funcallv(recv, mid, \ + rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \ + rb_funcall_args); \ + }) #endif #ifndef RUBY_DONT_SUBST @@ -362,7 +362,7 @@ num_funcall_op_0(VALUE x, VALUE arg, int recursive) ID2SYM(func), x); } } - return rb_funcall(x, func, 0, 0); + return rb_funcallv(x, func, 0, 0); } static VALUE @@ -831,10 +831,18 @@ static ID id_warn, id_warning, id_gets; # define PRIsWARN "s" # define WARN_ARGS(fmt,n) parser->value, id_warn, n, rb_usascii_str_new_lit(fmt) # define WARN_ARGS_L(l,fmt,n) WARN_ARGS(fmt,n) +# ifdef HAVE_VA_ARGS_MACRO +# define WARN_CALL(args,...) rb_funcall(args,__VA_ARGS__) +# else # define WARN_CALL rb_funcall +# endif # define WARNING_ARGS(fmt,n) parser->value, id_warning, n, rb_usascii_str_new_lit(fmt) # define WARNING_ARGS_L(l, fmt,n) WARNING_ARGS(fmt,n) +# ifdef HAVE_VA_ARGS_MACRO +# define WARNING_CALL(args,...) rb_funcall(args,__VA_ARGS__) +# else # define WARNING_CALL rb_funcall +# endif static void ripper_compile_error(struct parser_params*, const char *fmt, ...); # define compile_error ripper_compile_error # define PARSER_ARG parser, @@ -804,6 +804,7 @@ rb_apply(VALUE recv, ID mid, VALUE args) return rb_call(recv, mid, argc, argv, CALL_FCALL); } +#undef rb_funcall /*! * Calls a method * \param recv receiver of the method |