diff src/buffer.c @ 18991:847cc7932c42 v8.2.0056

patch 8.2.0056: execution stack is incomplete and inefficient Commit: https://github.com/vim/vim/commit/1a47ae32cdc19b0fd5a82e19fe5fddf45db1a506 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 29 23:04:25 2019 +0100 patch 8.2.0056: execution stack is incomplete and inefficient 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.
author Bram Moolenaar <Bram@vim.org>
date Sun, 29 Dec 2019 23:15:04 +0100
parents e378907d79bf
children 0883a37ccf84
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5279,8 +5279,6 @@ chk_modeline(
     int		vers;
     int		end;
     int		retval = OK;
-    char_u	*save_sourcing_name;
-    linenr_T	save_sourcing_lnum;
 #ifdef FEAT_EVAL
     sctx_T	save_current_sctx;
 #endif
@@ -5325,10 +5323,8 @@ chk_modeline(
 	if (linecopy == NULL)
 	    return FAIL;
 
-	save_sourcing_lnum = sourcing_lnum;
-	save_sourcing_name = sourcing_name;
-	sourcing_lnum = lnum;		// prepare for emsg()
-	sourcing_name = (char_u *)"modelines";
+	// prepare for emsg()
+	estack_push(ETYPE_MODELINE, (char_u *)"modelines", lnum);
 
 	end = FALSE;
 	while (end == FALSE)
@@ -5371,7 +5367,7 @@ chk_modeline(
 		save_current_sctx = current_sctx;
 		current_sctx.sc_sid = SID_MODELINE;
 		current_sctx.sc_seq = 0;
-		current_sctx.sc_lnum = 0;
+		current_sctx.sc_lnum = lnum;
 		current_sctx.sc_version = 1;
 #endif
 		// Make sure no risky things are executed as a side effect.
@@ -5389,9 +5385,7 @@ chk_modeline(
 	    s = e + 1;			// advance to next part
 	}
 
-	sourcing_lnum = save_sourcing_lnum;
-	sourcing_name = save_sourcing_name;
-
+	estack_pop();
 	vim_free(linecopy);
     }
     return retval;