mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.0248: duplicate code in finding a script in the execution stack
Problem: Duplicate code in finding a script in the execution stack. Solution: Reduce duplicate code. (closes #10961)
This commit is contained in:
@@ -162,32 +162,21 @@ estack_sfile(estack_arg_T which UNUSED)
|
|||||||
// instead.
|
// instead.
|
||||||
if (which == ESTACK_SCRIPT)
|
if (which == ESTACK_SCRIPT)
|
||||||
{
|
{
|
||||||
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
|
|
||||||
// Walk the stack backwards, starting from the current frame.
|
// Walk the stack backwards, starting from the current frame.
|
||||||
for (idx = exestack.ga_len - 1; idx >= 0; --idx, --entry)
|
for (idx = exestack.ga_len - 1; idx >= 0; --idx, --entry)
|
||||||
{
|
{
|
||||||
if (entry->es_type == ETYPE_UFUNC)
|
if (entry->es_type == ETYPE_UFUNC || entry->es_type == ETYPE_AUCMD)
|
||||||
{
|
{
|
||||||
sctx_T *def_ctx = &entry->es_info.ufunc->uf_script_ctx;
|
sctx_T *def_ctx = entry->es_type == ETYPE_UFUNC
|
||||||
|
? &entry->es_info.ufunc->uf_script_ctx
|
||||||
|
: acp_script_ctx(entry->es_info.aucmd);
|
||||||
|
|
||||||
if (def_ctx->sc_sid > 0)
|
return def_ctx->sc_sid > 0
|
||||||
return vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name);
|
? vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name)
|
||||||
else
|
: NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (entry->es_type == ETYPE_AUCMD)
|
|
||||||
{
|
|
||||||
sctx_T *def_ctx = acp_script_ctx(entry->es_info.aucmd);
|
|
||||||
|
|
||||||
if (def_ctx->sc_sid > 0)
|
|
||||||
return vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name);
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
else if (entry->es_type == ETYPE_SCRIPT)
|
else if (entry->es_type == ETYPE_SCRIPT)
|
||||||
{
|
|
||||||
return vim_strsave(entry->es_name);
|
return vim_strsave(entry->es_name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -731,6 +731,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
248,
|
||||||
/**/
|
/**/
|
||||||
247,
|
247,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user