mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
vim-patch:8.1.0233: "safe" argument of call_vim_function() is always FALSE
Problem: "safe" argument of call_vim_function() is always FALSE.
Solution: Remove the argument.
ded27a1feb
This commit is contained in:
@@ -3722,7 +3722,7 @@ expand_by_function(
|
||||
curbuf_save = curbuf;
|
||||
|
||||
// Call a function, which returns a list or dict.
|
||||
if (call_vim_function(funcname, 2, args, &rettv, false) == OK) {
|
||||
if (call_vim_function(funcname, 2, args, &rettv) == OK) {
|
||||
switch (rettv.v_type) {
|
||||
case VAR_LIST:
|
||||
matchlist = rettv.vval.v_list;
|
||||
@@ -4913,7 +4913,6 @@ static int ins_complete(int c, bool enable_pum)
|
||||
* Call user defined function 'completefunc' with "a:findstart"
|
||||
* set to 1 to obtain the length of text to use for completion.
|
||||
*/
|
||||
int col;
|
||||
char_u *funcname;
|
||||
pos_T pos;
|
||||
win_T *curwin_save;
|
||||
@@ -4942,7 +4941,7 @@ static int ins_complete(int c, bool enable_pum)
|
||||
pos = curwin->w_cursor;
|
||||
curwin_save = curwin;
|
||||
curbuf_save = curbuf;
|
||||
col = call_func_retnr(funcname, 2, args, false);
|
||||
int col = call_func_retnr(funcname, 2, args);
|
||||
|
||||
State = save_State;
|
||||
if (curwin_save != curwin || curbuf_save != curbuf) {
|
||||
|
@@ -1307,27 +1307,17 @@ int call_vim_function(
|
||||
const char_u *func,
|
||||
int argc,
|
||||
typval_T *argv,
|
||||
typval_T *rettv,
|
||||
bool safe // use the sandbox
|
||||
typval_T *rettv
|
||||
)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int doesrange;
|
||||
void *save_funccalp = NULL;
|
||||
int ret;
|
||||
|
||||
if (safe) {
|
||||
save_funccalp = save_funccal();
|
||||
++sandbox;
|
||||
}
|
||||
|
||||
rettv->v_type = VAR_UNKNOWN; // tv_clear() uses this.
|
||||
ret = call_func(func, (int)STRLEN(func), rettv, argc, argv, NULL,
|
||||
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
||||
&doesrange, true, NULL, NULL);
|
||||
if (safe) {
|
||||
--sandbox;
|
||||
restore_funccal(save_funccalp);
|
||||
}
|
||||
|
||||
if (ret == FAIL) {
|
||||
tv_clear(rettv);
|
||||
@@ -1340,16 +1330,16 @@ int call_vim_function(
|
||||
/// @param[in] func Function name.
|
||||
/// @param[in] argc Number of arguments.
|
||||
/// @param[in] argv Array with typval_T arguments.
|
||||
/// @param[in] safe Use with sandbox.
|
||||
///
|
||||
/// @return -1 when calling function fails, result of function otherwise.
|
||||
varnumber_T call_func_retnr(char_u *func, int argc,
|
||||
typval_T *argv, int safe)
|
||||
varnumber_T call_func_retnr(const char_u *func, int argc,
|
||||
typval_T *argv)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
typval_T rettv;
|
||||
varnumber_T retval;
|
||||
|
||||
if (call_vim_function(func, argc, argv, &rettv, safe) == FAIL) {
|
||||
if (call_vim_function(func, argc, argv, &rettv) == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
retval = tv_get_number_chk(&rettv, NULL);
|
||||
@@ -1361,18 +1351,16 @@ varnumber_T call_func_retnr(char_u *func, int argc,
|
||||
/// @param[in] func Function name.
|
||||
/// @param[in] argc Number of arguments.
|
||||
/// @param[in] argv Array with typval_T arguments.
|
||||
/// @param[in] safe Use the sandbox.
|
||||
///
|
||||
/// @return [allocated] NULL when calling function fails, allocated string
|
||||
/// otherwise.
|
||||
char *call_func_retstr(const char *const func, int argc,
|
||||
typval_T *argv,
|
||||
bool safe)
|
||||
FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
|
||||
typval_T *argv)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
|
||||
{
|
||||
typval_T rettv;
|
||||
// All arguments are passed as strings, no conversion to number.
|
||||
if (call_vim_function((const char_u *)func, argc, argv, &rettv, safe)
|
||||
if (call_vim_function((const char_u *)func, argc, argv, &rettv)
|
||||
== FAIL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -1386,17 +1374,16 @@ char *call_func_retstr(const char *const func, int argc,
|
||||
/// @param[in] func Function name.
|
||||
/// @param[in] argc Number of arguments.
|
||||
/// @param[in] argv Array with typval_T arguments.
|
||||
/// @param[in] safe Use the sandbox.
|
||||
///
|
||||
/// @return [allocated] NULL when calling function fails or return tv is not a
|
||||
/// List, allocated List otherwise.
|
||||
void *call_func_retlist(char_u *func, int argc, typval_T *argv,
|
||||
bool safe)
|
||||
void *call_func_retlist(const char_u *func, int argc, typval_T *argv)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
typval_T rettv;
|
||||
|
||||
// All arguments are passed as strings, no conversion to number.
|
||||
if (call_vim_function(func, argc, argv, &rettv, safe) == FAIL) {
|
||||
if (call_vim_function(func, argc, argv, &rettv) == FAIL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -198,10 +198,7 @@ static Array cmdline_block = ARRAY_DICT_INIT;
|
||||
/*
|
||||
* Type used by call_user_expand_func
|
||||
*/
|
||||
typedef void *(*user_expand_func_T)(const char_u *,
|
||||
int,
|
||||
typval_T *,
|
||||
bool);
|
||||
typedef void *(*user_expand_func_T)(const char_u *, int, typval_T *);
|
||||
|
||||
static histentry_T *(history[HIST_COUNT]) = {NULL, NULL, NULL, NULL, NULL};
|
||||
static int hisidx[HIST_COUNT] = {-1, -1, -1, -1, -1}; /* lastused entry */
|
||||
@@ -5059,12 +5056,12 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
|
||||
/// return the result (either a string or a List).
|
||||
static void * call_user_expand_func(user_expand_func_T user_expand_func,
|
||||
expand_T *xp, int *num_file, char_u ***file)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char_u keep = 0;
|
||||
typval_T args[4];
|
||||
char_u *pat = NULL;
|
||||
int save_current_SID = current_SID;
|
||||
void *ret;
|
||||
struct cmdline_info save_ccline;
|
||||
|
||||
if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0' || xp->xp_line == NULL)
|
||||
@@ -5092,10 +5089,7 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func,
|
||||
ccline.cmdprompt = NULL;
|
||||
current_SID = xp->xp_scriptID;
|
||||
|
||||
ret = user_expand_func(xp->xp_arg,
|
||||
3,
|
||||
args,
|
||||
false);
|
||||
void *const ret = user_expand_func(xp->xp_arg, 3, args);
|
||||
|
||||
ccline = save_ccline;
|
||||
current_SID = save_current_SID;
|
||||
|
@@ -2082,7 +2082,8 @@ static void op_colon(oparg_T *oap)
|
||||
/*
|
||||
* Handle the "g@" operator: call 'operatorfunc'.
|
||||
*/
|
||||
static void op_function(oparg_T *oap)
|
||||
static void op_function(const oparg_T *oap)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
const TriState save_virtual_op = virtual_op;
|
||||
|
||||
@@ -2111,7 +2112,7 @@ static void op_function(oparg_T *oap)
|
||||
// function.
|
||||
virtual_op = kNone;
|
||||
|
||||
(void)call_func_retnr(p_opfunc, 1, argv, false);
|
||||
(void)call_func_retnr(p_opfunc, 1, argv);
|
||||
|
||||
virtual_op = save_virtual_op;
|
||||
}
|
||||
|
Reference in New Issue
Block a user