Patch 9.0.0248
Problem: Duplicate code in finding a script in the execution stack.
Solution: Reduce duplicate code. (closes #10961)
Files: src/scriptfile.c
*** ../vim-9.0.0247/src/scriptfile.c 2022-08-22 13:14:31.892769316 +0100
--- src/scriptfile.c 2022-08-23 19:22:49.339524034 +0100
***************
*** 162,193 ****
// instead.
if (which == ESTACK_SCRIPT)
{
- entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
// Walk the stack backwards, starting from the current frame.
for (idx = exestack.ga_len - 1; idx >= 0; --idx, --entry)
{
! if (entry->es_type == ETYPE_UFUNC)
{
! sctx_T *def_ctx = &entry->es_info.ufunc->uf_script_ctx;
! 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_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)
- {
return vim_strsave(entry->es_name);
- }
}
return NULL;
}
--- 162,182 ----
// instead.
if (which == ESTACK_SCRIPT)
{
// Walk the stack backwards, starting from the current frame.
for (idx = exestack.ga_len - 1; idx >= 0; --idx, --entry)
{
! if (entry->es_type == ETYPE_UFUNC || entry->es_type == ETYPE_AUCMD)
{
! sctx_T *def_ctx = entry->es_type == ETYPE_UFUNC
! ? &entry->es_info.ufunc->uf_script_ctx
! : acp_script_ctx(entry->es_info.aucmd);
! return def_ctx->sc_sid > 0
! ? vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name)
! : NULL;
}
else if (entry->es_type == ETYPE_SCRIPT)
return vim_strsave(entry->es_name);
}
return NULL;
}
*** ../vim-9.0.0247/src/version.c 2022-08-23 18:39:14.760797662 +0100
--- src/version.c 2022-08-23 19:24:39.919203769 +0100
***************
*** 733,734 ****
--- 733,736 ----
{ /* Add new patch number below this line */
+ /**/
+ 248,
/**/
--
Compilation process failed successfully.
/// Bram Moolenaar -- Br...@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 ///