0
0
mirror of https://github.com/vim/vim.git synced 2025-08-31 20:53:42 -04:00

patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused

Problem:    "cctx" argument of find_func_even_dead() is unused.
Solution:   Remove the argument.
This commit is contained in:
Bram Moolenaar 2022-01-13 21:15:21 +00:00
parent c43e6235c7
commit d9d2fd0aa3
12 changed files with 43 additions and 41 deletions

View File

@ -4117,7 +4117,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
semsg(_(e_invalid_argument_str), use_string ? tv_get_string(&argvars[0]) : s);
// Don't check an autoload name for existence here.
else if (trans_name != NULL && (is_funcref
? find_func(trans_name, is_global, NULL) == NULL
? find_func(trans_name, is_global) == NULL
: !translated_function_exists(trans_name, is_global)))
semsg(_(e_unknown_function_str_2), s);
else
@ -4245,7 +4245,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
}
else if (is_funcref)
{
pt->pt_func = find_func(trans_name, is_global, NULL);
pt->pt_func = find_func(trans_name, is_global);
func_ptr_ref(pt->pt_func);
vim_free(name);
}

View File

@ -2727,7 +2727,7 @@ eval_variable(
}
else if (in_vim9script() && (flags & EVAL_VAR_NO_FUNC) == 0)
{
ufunc_T *ufunc = find_func(name, FALSE, NULL);
ufunc_T *ufunc = find_func(name, FALSE);
// In Vim9 script we can get a function reference by using the
// function name.
@ -3063,7 +3063,7 @@ lookup_scriptitem(
is_global = TRUE;
fname = name + 2;
}
if (find_func(fname, is_global, NULL) != NULL)
if (find_func(fname, is_global) != NULL)
res = OK;
}
}

View File

@ -8,8 +8,8 @@ char_u *deref_func_name(char_u *name, int *lenp, partial_T **partialp, type_T **
void emsg_funcname(char *ermsg, char_u *name);
int get_func_tv(char_u *name, int len, typval_T *rettv, char_u **arg, evalarg_T *evalarg, funcexe_T *funcexe);
char_u *fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error);
ufunc_T *find_func_even_dead(char_u *name, int is_global, cctx_T *cctx);
ufunc_T *find_func(char_u *name, int is_global, cctx_T *cctx);
ufunc_T *find_func_even_dead(char_u *name, int is_global);
ufunc_T *find_func(char_u *name, int is_global);
int func_is_global(ufunc_T *ufunc);
int func_name_refcount(char_u *name);
void func_clear_free(ufunc_T *fp, int force);

View File

@ -1113,7 +1113,7 @@ f_test_refcount(typval_T *argvars, typval_T *rettv)
{
ufunc_T *fp;
fp = find_func(argvars[0].vval.v_string, FALSE, NULL);
fp = find_func(argvars[0].vval.v_string, FALSE);
if (fp != NULL)
retval = fp->uf_refcount;
}

View File

@ -1934,7 +1934,7 @@ find_func_with_prefix(char_u *name, int sid)
* Return NULL for unknown function.
*/
ufunc_T *
find_func_even_dead(char_u *name, int is_global, cctx_T *cctx UNUSED)
find_func_even_dead(char_u *name, int is_global)
{
hashitem_T *hi;
ufunc_T *func;
@ -1970,9 +1970,9 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx UNUSED)
* Return NULL for unknown or dead function.
*/
ufunc_T *
find_func(char_u *name, int is_global, cctx_T *cctx)
find_func(char_u *name, int is_global)
{
ufunc_T *fp = find_func_even_dead(name, is_global, cctx);
ufunc_T *fp = find_func_even_dead(name, is_global);
if (fp != NULL && (fp->uf_flags & FC_DEAD) == 0)
return fp;
@ -2343,7 +2343,7 @@ func_clear_free(ufunc_T *fp, int force)
int
copy_func(char_u *lambda, char_u *global, ectx_T *ectx)
{
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL);
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE);
ufunc_T *fp = NULL;
if (ufunc == NULL)
@ -2352,7 +2352,7 @@ copy_func(char_u *lambda, char_u *global, ectx_T *ectx)
return FAIL;
}
fp = find_func(global, TRUE, NULL);
fp = find_func(global, TRUE);
if (fp != NULL)
{
// TODO: handle ! to overwrite
@ -3413,7 +3413,7 @@ call_func(
* User defined function.
*/
if (fp == NULL)
fp = find_func(rfname, is_global, NULL);
fp = find_func(rfname, is_global);
// Trigger FuncUndefined event, may load the function.
if (fp == NULL
@ -3422,13 +3422,13 @@ call_func(
&& !aborting())
{
// executed an autocommand, search for the function again
fp = find_func(rfname, is_global, NULL);
fp = find_func(rfname, is_global);
}
// Try loading a package.
if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
{
// loaded a package, search for the function again
fp = find_func(rfname, is_global, NULL);
fp = find_func(rfname, is_global);
}
if (fp == NULL)
{
@ -3437,7 +3437,7 @@ call_func(
// If using Vim9 script try not local to the script.
// Don't do this if the name starts with "s:".
if (p != NULL && (funcname[0] != 's' || funcname[1] != ':'))
fp = find_func(p, is_global, NULL);
fp = find_func(p, is_global);
}
if (fp != NULL && (fp->uf_flags & FC_DELETED))
@ -4180,7 +4180,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
*p = NUL;
if (!eap->skip && !got_int)
{
fp = find_func(name, is_global, NULL);
fp = find_func(name, is_global);
if (fp == NULL && ASCII_ISUPPER(*eap->arg))
{
char_u *up = untrans_function_name(name);
@ -4188,7 +4188,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
// With Vim9 script the name was made script-local, if not
// found try again with the original name.
if (up != NULL)
fp = find_func(up, FALSE, NULL);
fp = find_func(up, FALSE);
}
if (fp != NULL)
@ -4403,7 +4403,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
{
if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL)
emsg(_(e_dictionary_entry_already_exists));
else if (name != NULL && find_func(name, is_global, NULL) != NULL)
else if (name != NULL && find_func(name, is_global) != NULL)
emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name);
}
@ -4437,7 +4437,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
goto erret;
}
fp = find_func_even_dead(name, is_global, NULL);
fp = find_func_even_dead(name, is_global);
if (vim9script)
{
char_u *uname = untrans_function_name(name);
@ -4792,7 +4792,7 @@ translated_function_exists(char_u *name, int is_global)
{
if (builtin_function(name, -1))
return has_internal_func(name);
return find_func(name, is_global, NULL) != NULL;
return find_func(name, is_global) != NULL;
}
/*
@ -4939,7 +4939,7 @@ ex_delfunction(exarg_T *eap)
return;
}
if (!eap->skip)
fp = find_func(name, is_global, NULL);
fp = find_func(name, is_global);
vim_free(name);
if (!eap->skip)
@ -4998,7 +4998,7 @@ func_unref(char_u *name)
if (name == NULL || !func_name_refcount(name))
return;
fp = find_func(name, FALSE, NULL);
fp = find_func(name, FALSE);
if (fp == NULL && numbered_function(name))
{
#ifdef EXITFREE
@ -5039,7 +5039,7 @@ func_ref(char_u *name)
if (name == NULL || !func_name_refcount(name))
return;
fp = find_func(name, FALSE, NULL);
fp = find_func(name, FALSE);
if (fp != NULL)
++fp->uf_refcount;
else if (numbered_function(name))
@ -5534,7 +5534,7 @@ make_partial(dict_T *selfdict_in, typval_T *rettv)
: rettv->vval.v_partial->pt_name;
// Translate "s:func" to the stored function name.
fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
fp = find_func(fname, FALSE, NULL);
fp = find_func(fname, FALSE);
vim_free(tofree);
}
@ -5953,7 +5953,7 @@ set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID)
if (fp_in == NULL)
{
fname = fname_trans_sid(name, fname_buf, &tofree, &error);
fp = find_func(fname, FALSE, NULL);
fp = find_func(fname, FALSE);
}
if (fp != NULL)
{

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4086,
/**/
4085,
/**/

View File

@ -296,7 +296,7 @@ item_exists(char_u *name, size_t len, int cmd UNUSED, cctx_T *cctx)
// valid command, such as ":split" versus "split()".
// Skip "g:" before a function name.
is_global = (name[0] == 'g' && name[1] == ':');
return find_func(is_global ? name + 2 : name, is_global, cctx) != NULL;
return find_func(is_global ? name + 2 : name, is_global) != NULL;
}
return FALSE;
}
@ -332,7 +332,7 @@ check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg)
&& (lookup_local(p, len, NULL, cctx) == OK
|| arg_exists(p, len, NULL, NULL, NULL, cctx) == OK))
|| find_imported(p, len, FALSE, cctx) != NULL
|| (ufunc = find_func_even_dead(p, FALSE, cctx)) != NULL)
|| (ufunc = find_func_even_dead(p, FALSE)) != NULL)
{
// A local or script-local function can shadow a global function.
if (ufunc == NULL || ((ufunc->uf_flags & FC_DEAD) == 0

View File

@ -1007,7 +1007,7 @@ call_by_name(
return call_bfunc(func_idx, argcount, ectx);
}
ufunc = find_func(name, FALSE, NULL);
ufunc = find_func(name, FALSE);
if (ufunc == NULL)
{
@ -1015,7 +1015,7 @@ call_by_name(
if (script_autoload(name, TRUE))
// loaded a package, search for the function again
ufunc = find_func(name, FALSE, NULL);
ufunc = find_func(name, FALSE);
if (vim9_aborting(prev_uncaught_emsg))
return FAIL; // bail out if loading the script caused an error
@ -3319,7 +3319,7 @@ exec_instructions(ectx_T *ectx)
}
else
{
ufunc = find_func(funcref->fr_func_name, FALSE, NULL);
ufunc = find_func(funcref->fr_func_name, FALSE);
}
if (ufunc == NULL)
{
@ -6039,14 +6039,14 @@ ex_disassemble(exarg_T *eap)
return;
}
ufunc = find_func(fname, is_global, NULL);
ufunc = find_func(fname, is_global);
if (ufunc == NULL)
{
char_u *p = untrans_function_name(fname);
if (p != NULL)
// Try again without making it script-local.
ufunc = find_func(p, FALSE, NULL);
ufunc = find_func(p, FALSE);
}
vim_free(fname);
if (ufunc == NULL)

View File

@ -350,7 +350,7 @@ compile_load_scriptvar(
static int
generate_funcref(cctx_T *cctx, char_u *name)
{
ufunc_T *ufunc = find_func(name, FALSE, cctx);
ufunc_T *ufunc = find_func(name, FALSE);
if (ufunc == NULL)
return FAIL;
@ -418,7 +418,7 @@ compile_load(
case 'v': res = generate_LOADV(cctx, name, error);
break;
case 's': if (is_expr && ASCII_ISUPPER(*name)
&& find_func(name, FALSE, cctx) != NULL)
&& find_func(name, FALSE) != NULL)
res = generate_funcref(cctx, name);
else
res = compile_load_scriptvar(cctx, name,
@ -427,7 +427,7 @@ compile_load(
case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
{
if (is_expr && ASCII_ISUPPER(*name)
&& find_func(name, FALSE, cctx) != NULL)
&& find_func(name, FALSE) != NULL)
res = generate_funcref(cctx, name);
else
isn_type = ISN_LOADG;
@ -779,7 +779,7 @@ compile_call(
{
// If we can find the function by name generate the right call.
// Skip global functions here, a local funcref takes precedence.
ufunc = find_func(name, FALSE, cctx);
ufunc = find_func(name, FALSE);
if (ufunc != NULL && !func_is_global(ufunc))
{
res = generate_CALL(cctx, ufunc, argcount);

View File

@ -2030,7 +2030,7 @@ delete_instr(isn_T *isn)
case ISN_NEWFUNC:
{
char_u *lambda = isn->isn_arg.newfunc.nf_lambda;
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL);
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE);
if (ufunc != NULL)
{

View File

@ -132,7 +132,7 @@ ex_vim9script(exarg_T *eap UNUSED)
}
si->sn_state = SN_STATE_HAD_COMMAND;
// Store the prefix with the script. It isused to find exported functions.
// Store the prefix with the script, it is used to find exported functions.
if (si->sn_autoload_prefix == NULL)
si->sn_autoload_prefix = get_autoload_prefix(si);
@ -712,7 +712,7 @@ find_exported(
funcname[2] = (int)KE_SNR;
sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
}
*ufunc = find_func(funcname, FALSE, NULL);
*ufunc = find_func(funcname, FALSE);
if (funcname != buffer)
vim_free(funcname);

View File

@ -361,7 +361,7 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int flags)
member_type = internal_func_ret_type(idx, 0, NULL);
}
else
ufunc = find_func(name, FALSE, NULL);
ufunc = find_func(name, FALSE);
}
if (ufunc != NULL)
{