diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-26 15:34:17 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-30 21:00:17 -0400 |
commit | 2a57dce9f2ea157a6f9b15613788cdd8cebc26e5 (patch) | |
tree | 74fb8a6dba09c1dc4e4bdc41fc7e3da4bada6bee /src/nvim/eval/userfunc.c | |
parent | 4edf7b9ff22ca702876a7d0b5534fa2fc16b1897 (diff) | |
download | rneovim-2a57dce9f2ea157a6f9b15613788cdd8cebc26e5.tar.gz rneovim-2a57dce9f2ea157a6f9b15613788cdd8cebc26e5.tar.bz2 rneovim-2a57dce9f2ea157a6f9b15613788cdd8cebc26e5.zip |
vim-patch:8.1.1319: computing function length name in many places
Problem: Computing function length name in many places.
Solution: compute name length in call_func().
https://github.com/vim/vim/commit/6ed8819822994512c160006bd1204aa11ae3c494
In call_func(), reassign "len" param to (int)STRLEN(funcname)
instead of using vim_strsave() which runs strlen().
"len" param is checked for v:lua functions.
call_func() states that strlen() is used if "len" is set to -1.
Diffstat (limited to 'src/nvim/eval/userfunc.c')
-rw-r--r-- | src/nvim/eval/userfunc.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index d5a19dd7b9..873fe90797 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -367,7 +367,7 @@ void emsg_funcname(char *ermsg, const char_u *name) int get_func_tv( const char_u *name, // name of the function - int len, // length of "name" + int len, // length of "name" or -1 to use strlen() typval_T *rettv, char_u **arg, // argument, pointing to the '(' linenr_T firstline, // first line of range @@ -1291,7 +1291,7 @@ int func_call(char_u *name, typval_T *args, partial_T *partial, tv_copy(TV_LIST_ITEM_TV(item), &argv[argc++]); }); - r = call_func(name, (int)STRLEN(name), rettv, argc, argv, NULL, + r = call_func(name, -1, rettv, argc, argv, NULL, curwin->w_cursor.lnum, curwin->w_cursor.lnum, &dummy, true, partial, selfdict); @@ -1316,7 +1316,7 @@ func_call_skip_call: int call_func( const char_u *funcname, // name of the function - int len, // length of "name" + int len, // length of "name" or -1 to use strlen() typval_T *rettv, // [out] value goes here int argcount_in, // number of "argvars" typval_T *argvars_in, // vars for arguments, must have "argcount" @@ -1350,6 +1350,9 @@ call_func( // Make a copy of the name, if it comes from a funcref variable it could // be changed or deleted in the called function. + if (len <= 0) { + len = (int)STRLEN(funcname); + } name = vim_strnsave(funcname, len); fname = fname_trans_sid(name, fname_buf, &tofree, &error); @@ -2853,7 +2856,7 @@ void ex_call(exarg_T *eap) curwin->w_cursor.coladd = 0; } arg = startarg; - if (get_func_tv(name, (int)STRLEN(name), &rettv, &arg, + if (get_func_tv(name, -1, &rettv, &arg, eap->line1, eap->line2, &doesrange, true, partial, fudi.fd_dict) == FAIL) { failed = true; |