mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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 #9393)
This commit is contained in:
committed by
Bram Moolenaar
parent
73a024209c
commit
e7f4abd38b
27
src/option.c
27
src/option.c
@@ -7205,33 +7205,8 @@ option_set_callback_func(char_u *optval UNUSED, callback_T *optcb UNUSED)
|
||||
// Lambda expression or a funcref
|
||||
tv = eval_expr(optval, NULL);
|
||||
else
|
||||
{
|
||||
// treat everything else as a function name string
|
||||
|
||||
// Function name starting with "s:" are supported only in a vimscript
|
||||
// context.
|
||||
if (STRNCMP(optval, "s:", 2) == 0)
|
||||
{
|
||||
char sid_buf[25];
|
||||
char_u *funcname;
|
||||
|
||||
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
|
||||
{
|
||||
emsg(_(e_using_sid_not_in_script_context));
|
||||
return FAIL;
|
||||
}
|
||||
// Expand s: prefix into <SNR>nr_<name>
|
||||
sprintf(sid_buf, "<SNR>%ld_", (long)current_sctx.sc_sid);
|
||||
funcname = alloc(STRLEN(sid_buf) + STRLEN(optval + 2) + 1);
|
||||
if (funcname == NULL)
|
||||
return FAIL;
|
||||
STRCPY(funcname, sid_buf);
|
||||
STRCAT(funcname, optval + 2);
|
||||
tv = alloc_string_tv(funcname);
|
||||
}
|
||||
else
|
||||
tv = alloc_string_tv(vim_strsave(optval));
|
||||
}
|
||||
tv = alloc_string_tv(vim_strsave(optval));
|
||||
if (tv == NULL)
|
||||
return FAIL;
|
||||
|
||||
|
Reference in New Issue
Block a user