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.
diff --git a/src/globals.h b/src/globals.h
index 87f7b0b..acdce70 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -266,8 +266,15 @@
EXTERN int msg_no_more INIT(= FALSE); // don't use more prompt, truncate
// messages
-EXTERN char_u *sourcing_name INIT( = NULL);// name of error message source
-EXTERN linenr_T sourcing_lnum INIT(= 0); // line number of the source file
+/*
+ * Stack of execution contexts. Each entry is an estack_T.
+ * Current context is at ga_len - 1.
+ */
+EXTERN garray_T exestack INIT(= {0 COMMA 0 COMMA sizeof(estack_T) COMMA 50 COMMA NULL});
+// name of error message source
+#define SOURCING_NAME (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_name)
+// line number in the message source or zero
+#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum)
#ifdef FEAT_EVAL
EXTERN int ex_nesting_level INIT(= 0); // nesting level