0
0
mirror of https://github.com/vim/vim.git synced 2025-09-04 21:33:48 -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); semsg(_(e_invalid_argument_str), use_string ? tv_get_string(&argvars[0]) : s);
// Don't check an autoload name for existence here. // Don't check an autoload name for existence here.
else if (trans_name != NULL && (is_funcref 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))) : !translated_function_exists(trans_name, is_global)))
semsg(_(e_unknown_function_str_2), s); semsg(_(e_unknown_function_str_2), s);
else else
@ -4245,7 +4245,7 @@ common_function(typval_T *argvars, typval_T *rettv, int is_funcref)
} }
else if (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); func_ptr_ref(pt->pt_func);
vim_free(name); vim_free(name);
} }

View File

@ -2727,7 +2727,7 @@ eval_variable(
} }
else if (in_vim9script() && (flags & EVAL_VAR_NO_FUNC) == 0) 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 // In Vim9 script we can get a function reference by using the
// function name. // function name.
@ -3063,7 +3063,7 @@ lookup_scriptitem(
is_global = TRUE; is_global = TRUE;
fname = name + 2; fname = name + 2;
} }
if (find_func(fname, is_global, NULL) != NULL) if (find_func(fname, is_global) != NULL)
res = OK; 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); 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); 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); 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_even_dead(char_u *name, int is_global);
ufunc_T *find_func(char_u *name, int is_global, cctx_T *cctx); ufunc_T *find_func(char_u *name, int is_global);
int func_is_global(ufunc_T *ufunc); int func_is_global(ufunc_T *ufunc);
int func_name_refcount(char_u *name); int func_name_refcount(char_u *name);
void func_clear_free(ufunc_T *fp, int force); 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; 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) if (fp != NULL)
retval = fp->uf_refcount; retval = fp->uf_refcount;
} }

View File

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

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4086,
/**/ /**/
4085, 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()". // valid command, such as ":split" versus "split()".
// Skip "g:" before a function name. // Skip "g:" before a function name.
is_global = (name[0] == 'g' && name[1] == ':'); 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; 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 && (lookup_local(p, len, NULL, cctx) == OK
|| arg_exists(p, len, NULL, NULL, NULL, cctx) == OK)) || arg_exists(p, len, NULL, NULL, NULL, cctx) == OK))
|| find_imported(p, len, FALSE, cctx) != NULL || 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. // A local or script-local function can shadow a global function.
if (ufunc == NULL || ((ufunc->uf_flags & FC_DEAD) == 0 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); return call_bfunc(func_idx, argcount, ectx);
} }
ufunc = find_func(name, FALSE, NULL); ufunc = find_func(name, FALSE);
if (ufunc == NULL) if (ufunc == NULL)
{ {
@ -1015,7 +1015,7 @@ call_by_name(
if (script_autoload(name, TRUE)) if (script_autoload(name, TRUE))
// loaded a package, search for the function again // 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)) if (vim9_aborting(prev_uncaught_emsg))
return FAIL; // bail out if loading the script caused an error return FAIL; // bail out if loading the script caused an error
@ -3319,7 +3319,7 @@ exec_instructions(ectx_T *ectx)
} }
else else
{ {
ufunc = find_func(funcref->fr_func_name, FALSE, NULL); ufunc = find_func(funcref->fr_func_name, FALSE);
} }
if (ufunc == NULL) if (ufunc == NULL)
{ {
@ -6039,14 +6039,14 @@ ex_disassemble(exarg_T *eap)
return; return;
} }
ufunc = find_func(fname, is_global, NULL); ufunc = find_func(fname, is_global);
if (ufunc == NULL) if (ufunc == NULL)
{ {
char_u *p = untrans_function_name(fname); char_u *p = untrans_function_name(fname);
if (p != NULL) if (p != NULL)
// Try again without making it script-local. // Try again without making it script-local.
ufunc = find_func(p, FALSE, NULL); ufunc = find_func(p, FALSE);
} }
vim_free(fname); vim_free(fname);
if (ufunc == NULL) if (ufunc == NULL)

View File

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

View File

@ -2030,7 +2030,7 @@ delete_instr(isn_T *isn)
case ISN_NEWFUNC: case ISN_NEWFUNC:
{ {
char_u *lambda = isn->isn_arg.newfunc.nf_lambda; 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) if (ufunc != NULL)
{ {

View File

@ -132,7 +132,7 @@ ex_vim9script(exarg_T *eap UNUSED)
} }
si->sn_state = SN_STATE_HAD_COMMAND; 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) if (si->sn_autoload_prefix == NULL)
si->sn_autoload_prefix = get_autoload_prefix(si); si->sn_autoload_prefix = get_autoload_prefix(si);
@ -712,7 +712,7 @@ find_exported(
funcname[2] = (int)KE_SNR; funcname[2] = (int)KE_SNR;
sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name); sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
} }
*ufunc = find_func(funcname, FALSE, NULL); *ufunc = find_func(funcname, FALSE);
if (funcname != buffer) if (funcname != buffer)
vim_free(funcname); 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); member_type = internal_func_ret_type(idx, 0, NULL);
} }
else else
ufunc = find_func(name, FALSE, NULL); ufunc = find_func(name, FALSE);
} }
if (ufunc != NULL) if (ufunc != NULL)
{ {