To: vim_dev@googlegroups.com Subject: Patch 8.2.4086 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4086 Problem: "cctx" argument of find_func_even_dead() is unused. Solution: Remove the argument. Files: src/userfunc.c, src/proto/userfunc.pro, src/vim9compile.c, src/vim9instr.c, src/evalfunc.c, src/evalvars.c, src/testing.c, src/vim9execute.c, src/vim9expr.c, src/vim9script.c, src/vim9type.c *** ../vim-8.2.4085/src/userfunc.c 2022-01-13 13:24:28.207818222 +0000 --- src/userfunc.c 2022-01-13 21:05:04.566567030 +0000 *************** *** 1934,1940 **** * Return NULL for unknown function. */ ufunc_T * ! find_func_even_dead(char_u *name, int is_global, cctx_T *cctx UNUSED) { hashitem_T *hi; ufunc_T *func; --- 1934,1940 ---- * Return NULL for unknown function. */ ufunc_T * ! find_func_even_dead(char_u *name, int is_global) { hashitem_T *hi; ufunc_T *func; *************** *** 1970,1978 **** * Return NULL for unknown or dead function. */ ufunc_T * ! find_func(char_u *name, int is_global, cctx_T *cctx) { ! ufunc_T *fp = find_func_even_dead(name, is_global, cctx); if (fp != NULL && (fp->uf_flags & FC_DEAD) == 0) return fp; --- 1970,1978 ---- * Return NULL for unknown or dead function. */ ufunc_T * ! find_func(char_u *name, int is_global) { ! ufunc_T *fp = find_func_even_dead(name, is_global); if (fp != NULL && (fp->uf_flags & FC_DEAD) == 0) return fp; *************** *** 2343,2349 **** int copy_func(char_u *lambda, char_u *global, ectx_T *ectx) { ! ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL); ufunc_T *fp = NULL; if (ufunc == NULL) --- 2343,2349 ---- int copy_func(char_u *lambda, char_u *global, ectx_T *ectx) { ! ufunc_T *ufunc = find_func_even_dead(lambda, TRUE); ufunc_T *fp = NULL; if (ufunc == NULL) *************** *** 2352,2358 **** return FAIL; } ! fp = find_func(global, TRUE, NULL); if (fp != NULL) { // TODO: handle ! to overwrite --- 2352,2358 ---- return FAIL; } ! fp = find_func(global, TRUE); if (fp != NULL) { // TODO: handle ! to overwrite *************** *** 3413,3419 **** * User defined function. */ if (fp == NULL) ! fp = find_func(rfname, is_global, NULL); // Trigger FuncUndefined event, may load the function. if (fp == NULL --- 3413,3419 ---- * User defined function. */ if (fp == NULL) ! fp = find_func(rfname, is_global); // Trigger FuncUndefined event, may load the function. if (fp == NULL *************** *** 3422,3434 **** && !aborting()) { // executed an autocommand, search for the function again ! fp = find_func(rfname, is_global, NULL); } // 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); } if (fp == NULL) { --- 3422,3434 ---- && !aborting()) { // executed an autocommand, search for the function again ! 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); } if (fp == NULL) { *************** *** 3437,3443 **** // 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); } if (fp != NULL && (fp->uf_flags & FC_DELETED)) --- 3437,3443 ---- // 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); } if (fp != NULL && (fp->uf_flags & FC_DELETED)) *************** *** 4180,4186 **** *p = NUL; if (!eap->skip && !got_int) { ! fp = find_func(name, is_global, NULL); if (fp == NULL && ASCII_ISUPPER(*eap->arg)) { char_u *up = untrans_function_name(name); --- 4180,4186 ---- *p = NUL; if (!eap->skip && !got_int) { ! fp = find_func(name, is_global); if (fp == NULL && ASCII_ISUPPER(*eap->arg)) { char_u *up = untrans_function_name(name); *************** *** 4188,4194 **** // 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); } if (fp != NULL) --- 4188,4194 ---- // 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); } if (fp != NULL) *************** *** 4403,4409 **** { 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) emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name); } --- 4403,4409 ---- { 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) emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name); } *************** *** 4437,4443 **** goto erret; } ! fp = find_func_even_dead(name, is_global, NULL); if (vim9script) { char_u *uname = untrans_function_name(name); --- 4437,4443 ---- goto erret; } ! fp = find_func_even_dead(name, is_global); if (vim9script) { char_u *uname = untrans_function_name(name); *************** *** 4792,4798 **** { if (builtin_function(name, -1)) return has_internal_func(name); ! return find_func(name, is_global, NULL) != NULL; } /* --- 4792,4798 ---- { if (builtin_function(name, -1)) return has_internal_func(name); ! return find_func(name, is_global) != NULL; } /* *************** *** 4939,4945 **** return; } if (!eap->skip) ! fp = find_func(name, is_global, NULL); vim_free(name); if (!eap->skip) --- 4939,4945 ---- return; } if (!eap->skip) ! fp = find_func(name, is_global); vim_free(name); if (!eap->skip) *************** *** 4998,5004 **** if (name == NULL || !func_name_refcount(name)) return; ! fp = find_func(name, FALSE, NULL); if (fp == NULL && numbered_function(name)) { #ifdef EXITFREE --- 4998,5004 ---- if (name == NULL || !func_name_refcount(name)) return; ! fp = find_func(name, FALSE); if (fp == NULL && numbered_function(name)) { #ifdef EXITFREE *************** *** 5039,5045 **** if (name == NULL || !func_name_refcount(name)) return; ! fp = find_func(name, FALSE, NULL); if (fp != NULL) ++fp->uf_refcount; else if (numbered_function(name)) --- 5039,5045 ---- if (name == NULL || !func_name_refcount(name)) return; ! fp = find_func(name, FALSE); if (fp != NULL) ++fp->uf_refcount; else if (numbered_function(name)) *************** *** 5534,5540 **** : 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); vim_free(tofree); } --- 5534,5540 ---- : 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); vim_free(tofree); } *************** *** 5953,5959 **** if (fp_in == NULL) { fname = fname_trans_sid(name, fname_buf, &tofree, &error); ! fp = find_func(fname, FALSE, NULL); } if (fp != NULL) { --- 5953,5959 ---- if (fp_in == NULL) { fname = fname_trans_sid(name, fname_buf, &tofree, &error); ! fp = find_func(fname, FALSE); } if (fp != NULL) { *** ../vim-8.2.4085/src/proto/userfunc.pro 2022-01-08 15:39:35.410385289 +0000 --- src/proto/userfunc.pro 2022-01-13 21:07:03.250478300 +0000 *************** *** 8,15 **** 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); int func_is_global(ufunc_T *ufunc); int func_name_refcount(char_u *name); void func_clear_free(ufunc_T *fp, int force); --- 8,15 ---- 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); ! 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); *** ../vim-8.2.4085/src/vim9compile.c 2022-01-12 16:18:13.801613093 +0000 --- src/vim9compile.c 2022-01-13 21:05:14.394559884 +0000 *************** *** 296,302 **** // 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 FALSE; } --- 296,302 ---- // 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) != NULL; } return FALSE; } *************** *** 332,338 **** && (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) { // A local or script-local function can shadow a global function. if (ufunc == NULL || ((ufunc->uf_flags & FC_DEAD) == 0 --- 332,338 ---- && (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)) != NULL) { // A local or script-local function can shadow a global function. if (ufunc == NULL || ((ufunc->uf_flags & FC_DEAD) == 0 *** ../vim-8.2.4085/src/vim9instr.c 2022-01-12 19:47:00.339543337 +0000 --- src/vim9instr.c 2022-01-13 21:02:46.122662439 +0000 *************** *** 2030,2036 **** case ISN_NEWFUNC: { char_u *lambda = isn->isn_arg.newfunc.nf_lambda; ! ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL); if (ufunc != NULL) { --- 2030,2036 ---- case ISN_NEWFUNC: { char_u *lambda = isn->isn_arg.newfunc.nf_lambda; ! ufunc_T *ufunc = find_func_even_dead(lambda, TRUE); if (ufunc != NULL) { *** ../vim-8.2.4085/src/evalfunc.c 2022-01-10 13:36:31.264892417 +0000 --- src/evalfunc.c 2022-01-13 21:03:27.082635218 +0000 *************** *** 4117,4123 **** 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 : !translated_function_exists(trans_name, is_global))) semsg(_(e_unknown_function_str_2), s); else --- 4117,4123 ---- 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 : !translated_function_exists(trans_name, is_global))) semsg(_(e_unknown_function_str_2), s); else *************** *** 4245,4251 **** } else if (is_funcref) { ! pt->pt_func = find_func(trans_name, is_global, NULL); func_ptr_ref(pt->pt_func); vim_free(name); } --- 4245,4251 ---- } else if (is_funcref) { ! pt->pt_func = find_func(trans_name, is_global); func_ptr_ref(pt->pt_func); vim_free(name); } *** ../vim-8.2.4085/src/evalvars.c 2022-01-13 20:39:38.102029412 +0000 --- src/evalvars.c 2022-01-13 21:03:44.074623666 +0000 *************** *** 2727,2733 **** } else if (in_vim9script() && (flags & EVAL_VAR_NO_FUNC) == 0) { ! ufunc_T *ufunc = find_func(name, FALSE, NULL); // In Vim9 script we can get a function reference by using the // function name. --- 2727,2733 ---- } else if (in_vim9script() && (flags & EVAL_VAR_NO_FUNC) == 0) { ! ufunc_T *ufunc = find_func(name, FALSE); // In Vim9 script we can get a function reference by using the // function name. *************** *** 3063,3069 **** is_global = TRUE; fname = name + 2; } ! if (find_func(fname, is_global, NULL) != NULL) res = OK; } } --- 3063,3069 ---- is_global = TRUE; fname = name + 2; } ! if (find_func(fname, is_global) != NULL) res = OK; } } *** ../vim-8.2.4085/src/testing.c 2022-01-01 14:19:44.056353820 +0000 --- src/testing.c 2022-01-13 21:03:57.446614472 +0000 *************** *** 1113,1119 **** { ufunc_T *fp; ! fp = find_func(argvars[0].vval.v_string, FALSE, NULL); if (fp != NULL) retval = fp->uf_refcount; } --- 1113,1119 ---- { ufunc_T *fp; ! fp = find_func(argvars[0].vval.v_string, FALSE); if (fp != NULL) retval = fp->uf_refcount; } *** ../vim-8.2.4085/src/vim9execute.c 2022-01-12 19:47:00.339543337 +0000 --- src/vim9execute.c 2022-01-13 21:05:44.546537755 +0000 *************** *** 1007,1013 **** return call_bfunc(func_idx, argcount, ectx); } ! ufunc = find_func(name, FALSE, NULL); if (ufunc == NULL) { --- 1007,1013 ---- return call_bfunc(func_idx, argcount, ectx); } ! ufunc = find_func(name, FALSE); if (ufunc == NULL) { *************** *** 1015,1021 **** if (script_autoload(name, TRUE)) // loaded a package, search for the function again ! ufunc = find_func(name, FALSE, NULL); if (vim9_aborting(prev_uncaught_emsg)) return FAIL; // bail out if loading the script caused an error --- 1015,1021 ---- if (script_autoload(name, TRUE)) // loaded a package, search for the function again ! ufunc = find_func(name, FALSE); if (vim9_aborting(prev_uncaught_emsg)) return FAIL; // bail out if loading the script caused an error *************** *** 3319,3325 **** } else { ! ufunc = find_func(funcref->fr_func_name, FALSE, NULL); } if (ufunc == NULL) { --- 3319,3325 ---- } else { ! ufunc = find_func(funcref->fr_func_name, FALSE); } if (ufunc == NULL) { *************** *** 6039,6052 **** return; } ! ufunc = find_func(fname, is_global, NULL); 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); } vim_free(fname); if (ufunc == NULL) --- 6039,6052 ---- return; } ! 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); } vim_free(fname); if (ufunc == NULL) *** ../vim-8.2.4085/src/vim9expr.c 2022-01-12 19:47:00.339543337 +0000 --- src/vim9expr.c 2022-01-13 21:06:18.542512370 +0000 *************** *** 350,356 **** static int generate_funcref(cctx_T *cctx, char_u *name) { ! ufunc_T *ufunc = find_func(name, FALSE, cctx); if (ufunc == NULL) return FAIL; --- 350,356 ---- static int generate_funcref(cctx_T *cctx, char_u *name) { ! ufunc_T *ufunc = find_func(name, FALSE); if (ufunc == NULL) return FAIL; *************** *** 418,424 **** case 'v': res = generate_LOADV(cctx, name, error); break; case 's': if (is_expr && ASCII_ISUPPER(*name) ! && find_func(name, FALSE, cctx) != NULL) res = generate_funcref(cctx, name); else res = compile_load_scriptvar(cctx, name, --- 418,424 ---- case 'v': res = generate_LOADV(cctx, name, error); break; case 's': if (is_expr && ASCII_ISUPPER(*name) ! && find_func(name, FALSE) != NULL) res = generate_funcref(cctx, name); else res = compile_load_scriptvar(cctx, name, *************** *** 427,433 **** case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL) { if (is_expr && ASCII_ISUPPER(*name) ! && find_func(name, FALSE, cctx) != NULL) res = generate_funcref(cctx, name); else isn_type = ISN_LOADG; --- 427,433 ---- case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL) { if (is_expr && ASCII_ISUPPER(*name) ! && find_func(name, FALSE) != NULL) res = generate_funcref(cctx, name); else isn_type = ISN_LOADG; *************** *** 779,785 **** { // 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); if (ufunc != NULL && !func_is_global(ufunc)) { res = generate_CALL(cctx, ufunc, argcount); --- 779,785 ---- { // 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); if (ufunc != NULL && !func_is_global(ufunc)) { res = generate_CALL(cctx, ufunc, argcount); *** ../vim-8.2.4085/src/vim9script.c 2022-01-13 13:47:38.634084725 +0000 --- src/vim9script.c 2022-01-13 21:06:37.218498241 +0000 *************** *** 132,138 **** } si->sn_state = SN_STATE_HAD_COMMAND; ! // Store the prefix with the script. It isused to find exported functions. if (si->sn_autoload_prefix == NULL) si->sn_autoload_prefix = get_autoload_prefix(si); --- 132,138 ---- } si->sn_state = SN_STATE_HAD_COMMAND; ! // 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,718 **** funcname[2] = (int)KE_SNR; sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name); } ! *ufunc = find_func(funcname, FALSE, NULL); if (funcname != buffer) vim_free(funcname); --- 712,718 ---- funcname[2] = (int)KE_SNR; sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name); } ! *ufunc = find_func(funcname, FALSE); if (funcname != buffer) vim_free(funcname); *** ../vim-8.2.4085/src/vim9type.c 2022-01-08 12:41:12.212795547 +0000 --- src/vim9type.c 2022-01-13 21:06:43.106493743 +0000 *************** *** 361,367 **** member_type = internal_func_ret_type(idx, 0, NULL); } else ! ufunc = find_func(name, FALSE, NULL); } if (ufunc != NULL) { --- 361,367 ---- member_type = internal_func_ret_type(idx, 0, NULL); } else ! ufunc = find_func(name, FALSE); } if (ufunc != NULL) { *** ../vim-8.2.4085/src/version.c 2022-01-13 20:51:51.202887526 +0000 --- src/version.c 2022-01-13 21:01:45.854700600 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4086, /**/ -- You got to work at a mill? Lucky! I got sent back to work in the acid-mines for my daily crust of stale bread... which not even the birds would eat. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///