summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-29 23:04:25 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-29 23:04:25 +0100
commit1a47ae32cdc19b0fd5a82e19fe5fddf45db1a506 (patch)
tree8f5dc27f3eeea927ad3ca8de42fe0df06a041dd5 /src/main.c
parent257a396879ff67a0482841a39237f30a8e1e27c5 (diff)
patch 8.2.0056: execution stack is incomplete and inefficientv8.2.0056
Problem: Execution stack is incomplete and inefficient. Solution: Introduce a proper execution stack and use it instead of sourcing_name/sourcing_lnum. Create a string only when used.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index eec02ea85b..51b8970b9b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -911,6 +911,7 @@ vim_main2(void)
void
common_init(mparm_T *paramp)
{
+ estack_init();
cmdline_init();
(void)mb_init(); // init mb_bytelen_tab[] to ones
@@ -3089,13 +3090,13 @@ exe_pre_commands(mparm_T *parmp)
if (cnt > 0)
{
curwin->w_cursor.lnum = 0; // just in case..
- sourcing_name = (char_u *)_("pre-vimrc command line");
+ estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
# ifdef FEAT_EVAL
current_sctx.sc_sid = SID_CMDARG;
# endif
for (i = 0; i < cnt; ++i)
do_cmdline_cmd(cmds[i]);
- sourcing_name = NULL;
+ estack_pop();
# ifdef FEAT_EVAL
current_sctx.sc_sid = 0;
# endif
@@ -3119,7 +3120,7 @@ exe_commands(mparm_T *parmp)
msg_scroll = TRUE;
if (parmp->tagname == NULL && curwin->w_cursor.lnum <= 1)
curwin->w_cursor.lnum = 0;
- sourcing_name = (char_u *)"command line";
+ estack_push(ETYPE_ARGS, (char_u *)"command line", 0);
#ifdef FEAT_EVAL
current_sctx.sc_sid = SID_CARG;
current_sctx.sc_seq = 0;
@@ -3130,7 +3131,7 @@ exe_commands(mparm_T *parmp)
if (parmp->cmds_tofree[i])
vim_free(parmp->commands[i]);
}
- sourcing_name = NULL;
+ estack_pop();
#ifdef FEAT_EVAL
current_sctx.sc_sid = 0;
#endif
@@ -3336,8 +3337,6 @@ process_env(
int is_viminit) // when TRUE, called for VIMINIT
{
char_u *initstr;
- char_u *save_sourcing_name;
- linenr_T save_sourcing_lnum;
#ifdef FEAT_EVAL
sctx_T save_current_sctx;
#endif
@@ -3346,10 +3345,7 @@ process_env(
{
if (is_viminit)
vimrc_found(NULL, NULL);
- save_sourcing_name = sourcing_name;
- save_sourcing_lnum = sourcing_lnum;
- sourcing_name = env;
- sourcing_lnum = 0;
+ estack_push(ETYPE_ENV, env, 0);
#ifdef FEAT_EVAL
save_current_sctx = current_sctx;
current_sctx.sc_sid = SID_ENV;
@@ -3358,8 +3354,8 @@ process_env(
current_sctx.sc_version = 1;
#endif
do_cmdline_cmd(initstr);
- sourcing_name = save_sourcing_name;
- sourcing_lnum = save_sourcing_lnum;
+
+ estack_pop();
#ifdef FEAT_EVAL
current_sctx = save_current_sctx;
#endif