aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-02 21:00:27 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-03 03:39:56 +0800
commit70ac0c9358251bf54f29a30a369880d94680ace7 (patch)
tree894b96de2f83a0394f30ef45591f185601c71ad0 /src/nvim/eval.c
parent07e6296520fc83b1fdb287b5173494cdd0e9136f (diff)
downloadrneovim-70ac0c9358251bf54f29a30a369880d94680ace7.tar.gz
rneovim-70ac0c9358251bf54f29a30a369880d94680ace7.tar.bz2
rneovim-70ac0c9358251bf54f29a30a369880d94680ace7.zip
vim-patch:8.2.3889: duplicate code for translating script-local function name
Problem: Duplicate code for translating script-local function name. Solution: Move the code to get_scriptlocal_funcname(). (Yegappan Lakshmanan, closes vim/vim#9393) https://github.com/vim/vim/commit/e7f4abd38b6e05100c699900c8f87281e363beb2 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c4afd6934c..d8dbcf6eb0 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5018,18 +5018,11 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref)
int arg_idx = 0;
list_T *list = NULL;
if (strncmp(s, "s:", 2) == 0 || strncmp(s, "<SID>", 5) == 0) {
- char sid_buf[25];
- int off = *s == 's' ? 2 : 5;
-
// Expand s: and <SID> into <SNR>nr_, so that the function can
// also be called from another script. Using trans_function_name()
// would also work, but some plugins depend on the name being
// printable text.
- snprintf(sid_buf, sizeof(sid_buf), "<SNR>%" PRId64 "_",
- (int64_t)current_sctx.sc_sid);
- name = xmalloc(strlen(sid_buf) + strlen(s + off) + 1);
- STRCPY(name, sid_buf);
- STRCAT(name, s + off);
+ name = get_scriptlocal_funcname(s);
} else {
name = xstrdup(s);
}
@@ -5538,6 +5531,14 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg)
callback->type = kCallbackNone;
callback->data.funcref = NULL;
} else {
+ if (arg->v_type == VAR_STRING) {
+ char *newname = get_scriptlocal_funcname(arg->vval.v_string);
+ if (newname != NULL) {
+ xfree(arg->vval.v_string);
+ name = arg->vval.v_string = newname;
+ }
+ }
+
func_ref((char_u *)name);
callback->data.funcref = xstrdup(name);
callback->type = kCallbackFuncref;