diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-23 19:26:05 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-23 19:26:05 +0100 |
commit | a247142ae45308087b25f91c8af48399c8ac2943 (patch) | |
tree | 7af0668d351c9723774bc556d6cb5fa3f0aa2cfb | |
parent | f396ce83eebf6c61596184231d39ce4d41eeac04 (diff) | |
download | vim-git-a247142ae45308087b25f91c8af48399c8ac2943.tar.gz |
patch 9.0.0248: duplicate code in finding a script in the execution stackv9.0.0248
Problem: Duplicate code in finding a script in the execution stack.
Solution: Reduce duplicate code. (closes #10961)
-rw-r--r-- | src/scriptfile.c | 25 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 9 insertions, 18 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c index aae3be20a..c176763d5 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -162,32 +162,21 @@ estack_sfile(estack_arg_T which UNUSED) // 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) + 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 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; + 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; } diff --git a/src/version.c b/src/version.c index 66ef53ca9..0a3d26b1e 100644 --- a/src/version.c +++ b/src/version.c @@ -732,6 +732,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 248, +/**/ 247, /**/ 246, |