From f79773a3b4b3ce5a3b37652a72b12089880f32a4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Aug 2022 19:16:24 +0800 Subject: refactor: move non-symbols in ex_eval.h to ex_eval_defs.h (#19739) This avoids including ex_eval.h in any other header, thus preventing future circular includes. --- src/nvim/ex_eval.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index f67c8a6720..4e50a51a8a 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -151,8 +151,8 @@ int aborted_in_try(void) bool cause_errthrow(const char *mesg, bool severe, bool *ignore) FUNC_ATTR_NONNULL_ALL { - struct msglist *elem; - struct msglist **plist; + msglist_T *elem; + msglist_T **plist; /* * Do nothing when displaying the interrupt message or reporting an @@ -254,7 +254,7 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore) plist = &(*plist)->next; } - elem = xmalloc(sizeof(struct msglist)); + elem = xmalloc(sizeof(msglist_T)); elem->msg = xstrdup(mesg); elem->next = NULL; elem->throw_msg = NULL; @@ -281,9 +281,9 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore) } /// Free a "msg_list" and the messages it contains. -static void free_msglist(struct msglist *l) +static void free_msglist(msglist_T *l) { - struct msglist *messages, *next; + msglist_T *messages, *next; messages = l; while (messages != NULL) { @@ -389,7 +389,7 @@ char *get_exception_string(void *value, except_type_T type, char *cmdname, int * if (type == ET_ERROR) { *should_free = true; - mesg = ((struct msglist *)value)->throw_msg; + mesg = ((msglist_T *)value)->throw_msg; if (cmdname != NULL && *cmdname != NUL) { size_t cmdlen = STRLEN(cmdname); ret = xstrnsave("Vim(", 4 + cmdlen + 2 + STRLEN(mesg)); @@ -469,7 +469,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) if (type == ET_ERROR) { // Store the original message and prefix the exception value with // "Vim:" or, if a command name is given, "Vim(cmdname):". - excp->messages = (struct msglist *)value; + excp->messages = (msglist_T *)value; } excp->value = get_exception_string(value, type, cmdname, &should_free); -- cgit From 342d18b91ec176c5e3aa6d32d439d01e6ac88ee6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 12 Aug 2022 21:16:28 +0800 Subject: refactor: remove some unused includes (#19740) Mostly avoids including eval.h, ex_cmds2.h and ex_docmd.h in other headers. --- src/nvim/ex_eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 4e50a51a8a..9e029aa68a 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -16,12 +16,12 @@ #include "nvim/debugger.h" #include "nvim/eval.h" #include "nvim/eval/userfunc.h" -#include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/regexp.h" +#include "nvim/runtime.h" #include "nvim/strings.h" #include "nvim/vim.h" -- cgit From f52c236c5b432629f0e074c3511e7e9d481197b1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 13:48:11 +0800 Subject: vim-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. https://github.com/vim/vim/commit/1a47ae32cdc19b0fd5a82e19fe5fddf45db1a506 Omit test_debugger.vim: superseded by later patches. Omit check_map_keycodes(): N/A. Omit kword_test.c: N/A (converted to a unit test). --- src/nvim/ex_eval.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 9e029aa68a..0d10be2a97 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -478,8 +478,11 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) } excp->type = type; - excp->throw_name = xstrdup(sourcing_name == NULL ? "" : sourcing_name); - excp->throw_lnum = sourcing_lnum; + excp->throw_name = estack_sfile(); + if (excp->throw_name == NULL) { + excp->throw_name = xstrdup(""); + } + excp->throw_lnum = SOURCING_LNUM; if (p_verbose >= 13 || debug_break_level > 0) { int save_msg_silent = msg_silent; -- cgit From 1ca2247639424994890ef70ab34f2bffa23ddd9f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Aug 2022 17:52:04 +0800 Subject: vim-patch:8.2.0823: Vim9: script reload test is disabled Problem: Vim9: script reload test is disabled. Solution: Compile a function in the context of the script where it was defined. Set execution stack for compiled function. Add a test that an error is reported for the right file/function. https://github.com/vim/vim/commit/25e0f5863e9010a75a1ff0d04e8f886403968755 Omit stack_top_is_ufunc(): only used by Vim9 script. --- src/nvim/ex_eval.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 0d10be2a97..66c782d12e 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -275,6 +275,11 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore) (*msg_list)->throw_msg = tmsg; } } + + // Get the source name and lnum now, it may change before + // reaching do_errthrow(). + elem->sfile = estack_sfile(); + elem->slnum = SOURCING_LNUM; } return true; } @@ -289,6 +294,7 @@ static void free_msglist(msglist_T *l) while (messages != NULL) { next = messages->next; xfree(messages->msg); + xfree(messages->sfile); xfree(messages); messages = next; } @@ -478,11 +484,18 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) } excp->type = type; - excp->throw_name = estack_sfile(); - if (excp->throw_name == NULL) { - excp->throw_name = xstrdup(""); + if (type == ET_ERROR && ((msglist_T *)value)->sfile != NULL) { + msglist_T *entry = (msglist_T *)value; + excp->throw_name = entry->sfile; + entry->sfile = NULL; + excp->throw_lnum = entry->slnum; + } else { + excp->throw_name = estack_sfile(); + if (excp->throw_name == NULL) { + excp->throw_name = xstrdup(""); + } + excp->throw_lnum = SOURCING_LNUM; } - excp->throw_lnum = SOURCING_LNUM; if (p_verbose >= 13 || debug_break_level > 0) { int save_msg_silent = msg_silent; -- cgit From 98ab0bb5f7d2138be0b6019769e237e42aafad1a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Aug 2022 06:32:00 +0800 Subject: vim-patch:8.2.1297: when a test fails it's often not easy to see where Problem: When a test fails it's often not easy to see what the call stack is. Solution: Add more entries from the call stack in the exception message. https://github.com/vim/vim/commit/a5d0423fa16f18b4576a2a07e50034e489587a7d Use docs from latest Vim. --- src/nvim/ex_eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 66c782d12e..61456acc2a 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -278,7 +278,7 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore) // Get the source name and lnum now, it may change before // reaching do_errthrow(). - elem->sfile = estack_sfile(); + elem->sfile = estack_sfile(false); elem->slnum = SOURCING_LNUM; } return true; @@ -490,7 +490,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) entry->sfile = NULL; excp->throw_lnum = entry->slnum; } else { - excp->throw_name = estack_sfile(); + excp->throw_name = estack_sfile(false); if (excp->throw_name == NULL) { excp->throw_name = xstrdup(""); } -- cgit From ed65724e57d2af13cedc380ecfe4a495dae3afb7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Aug 2022 07:07:32 +0800 Subject: vim-patch:8.2.1653: expand('') does not include the final line number Problem: Expand('') does not include the final line number. Solution: Add the line nuber. (closes vim/vim#6927) https://github.com/vim/vim/commit/4f25b1aba050b85fa97ca2316aa04dd4b0b22530 --- src/nvim/ex_eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 61456acc2a..c39bb16498 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -278,7 +278,7 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore) // Get the source name and lnum now, it may change before // reaching do_errthrow(). - elem->sfile = estack_sfile(false); + elem->sfile = estack_sfile(ESTACK_NONE); elem->slnum = SOURCING_LNUM; } return true; @@ -490,7 +490,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) entry->sfile = NULL; excp->throw_lnum = entry->slnum; } else { - excp->throw_name = estack_sfile(false); + excp->throw_name = estack_sfile(ESTACK_NONE); if (excp->throw_name == NULL) { excp->throw_name = xstrdup(""); } -- cgit From 542fa8a9cc10abb8eddab25a19844d19b94f53c1 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 16 Aug 2022 12:26:08 +0100 Subject: refactor: change pre-decrement/increment to post (#19799) Co-authored-by: zeertzjq --- src/nvim/ex_eval.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index c39bb16498..69d509abb7 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -505,7 +505,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) } else { verbose_enter(); } - ++no_wait_return; + no_wait_return++; if (debug_break_level > 0 || *p_vfile == NUL) { msg_scroll = TRUE; // always scroll up, don't overwrite } @@ -515,7 +515,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) if (debug_break_level > 0 || *p_vfile == NUL) { cmdline_row = msg_row; } - --no_wait_return; + no_wait_return--; if (debug_break_level > 0) { msg_silent = save_msg_silent; } else { @@ -558,7 +558,7 @@ static void discard_exception(except_T *excp, bool was_finished) } else { verbose_enter(); } - ++no_wait_return; + no_wait_return++; if (debug_break_level > 0 || *p_vfile == NUL) { msg_scroll = TRUE; // always scroll up, don't overwrite } @@ -626,7 +626,7 @@ static void catch_exception(except_T *excp) } else { verbose_enter(); } - ++no_wait_return; + no_wait_return++; if (debug_break_level > 0 || *p_vfile == NUL) { msg_scroll = TRUE; // always scroll up, don't overwrite } @@ -636,7 +636,7 @@ static void catch_exception(except_T *excp) if (debug_break_level > 0 || *p_vfile == NUL) { cmdline_row = msg_row; } - --no_wait_return; + no_wait_return--; if (debug_break_level > 0) { msg_silent = save_msg_silent; } else { @@ -748,12 +748,12 @@ static void report_pending(int action, int pending, void *value) if (debug_break_level > 0) { msg_silent = FALSE; // display messages } - ++no_wait_return; - msg_scroll = TRUE; // always scroll up, don't overwrite + no_wait_return++; + msg_scroll = true; // always scroll up, don't overwrite smsg(mesg, s); msg_puts("\n"); // don't overwrite this either cmdline_row = msg_row; - --no_wait_return; + no_wait_return--; if (debug_break_level > 0) { msg_silent = save_msg_silent; } @@ -2054,7 +2054,7 @@ int has_loop_cmd(char *p) // skip modifiers, white space and ':' for (;;) { while (*p == ' ' || *p == '\t' || *p == ':') { - ++p; + p++; } len = modifier_len(p); if (len == 0) { -- cgit