# HG changeset patch # User Bram Moolenaar # Date 1642109405 -3600 # Node ID 98a01021e465aa72fc699d5ecd25df6b66244f8c # Parent 93194ce58678b4e0b857e650cc1e4e2168d4da74 patch 8.2.4086: "cctx" argument of find_func_even_dead() is unused Commit: https://github.com/vim/vim/commit/d9d2fd0aa33dd9f7460d6f1e403505a60f7ce2fc Author: Bram Moolenaar Date: Thu Jan 13 21:15:21 2022 +0000 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. diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4117,7 +4117,7 @@ common_function(typval_T *argvars, typva 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, typva } 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); } diff --git a/src/evalvars.c b/src/evalvars.c --- a/src/evalvars.c +++ b/src/evalvars.c @@ -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; } } diff --git a/src/proto/userfunc.pro b/src/proto/userfunc.pro --- a/src/proto/userfunc.pro +++ b/src/proto/userfunc.pro @@ -8,8 +8,8 @@ char_u *deref_func_name(char_u *name, in 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); diff --git a/src/testing.c b/src/testing.c --- a/src/testing.c +++ b/src/testing.c @@ -1113,7 +1113,7 @@ f_test_refcount(typval_T *argvars, typva { 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; } diff --git a/src/userfunc.c b/src/userfunc.c --- a/src/userfunc.c +++ b/src/userfunc.c @@ -1934,7 +1934,7 @@ find_func_with_prefix(char_u *name, int * 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 * 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 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 *na *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 *na // 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 *na { 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 *na 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, { 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 : 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 *f 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) { diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4086, +/**/ 4085, /**/ 4084, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -296,7 +296,7 @@ item_exists(char_u *name, size_t len, in // 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, cct && (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 diff --git a/src/vim9execute.c b/src/vim9execute.c --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -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) diff --git a/src/vim9expr.c b/src/vim9expr.c --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -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); diff --git a/src/vim9instr.c b/src/vim9instr.c --- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -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) { diff --git a/src/vim9script.c b/src/vim9script.c --- a/src/vim9script.c +++ b/src/vim9script.c @@ -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); diff --git a/src/vim9type.c b/src/vim9type.c --- a/src/vim9type.c +++ b/src/vim9type.c @@ -361,7 +361,7 @@ typval2type_int(typval_T *tv, int copyID member_type = internal_func_ret_type(idx, 0, NULL); } else - ufunc = find_func(name, FALSE, NULL); + ufunc = find_func(name, FALSE); } if (ufunc != NULL) {