1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2017-04-15 02:09:27 +00:00
parent 6f1fbfd618
commit 0472578b26
5 changed files with 22 additions and 2 deletions

View file

@ -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);
}
/*

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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