From 543e0256c19f397921a332e06b423215fd9aecb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 30 Nov 2023 15:51:05 +0800 Subject: build: don't define FUNC_ATTR_* as empty in headers (#26317) FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header. --- src/nvim/ex_eval.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index d2a1d53b78..bc4cb634e8 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -18,7 +18,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_eval_defs.h" -#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/memory.h" -- cgit From 7f6b775b45de5011ff1c44e63e57551566d80704 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 16 Dec 2023 22:14:28 +0100 Subject: refactor: use `bool` to represent boolean values --- src/nvim/ex_eval.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index bc4cb634e8..c239e8a9ea 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -92,7 +92,7 @@ static void discard_pending_return(typval_T *p) // expression evaluation is done without producing any error messages, but all // error messages on parsing errors during the expression evaluation are given // (even if a try conditional is active). -static int cause_abort = false; +static bool cause_abort = false; /// @return true when immediately aborting on error, or when an interrupt /// occurred or an exception was thrown but not caught. @@ -844,7 +844,7 @@ void ex_if(exarg_T *eap) int skip = CHECK_SKIP; bool error; - int result = eval_to_bool(eap->arg, &error, eap, skip); + bool result = eval_to_bool(eap->arg, &error, eap, skip); if (!skip && !error) { if (result) { @@ -971,7 +971,7 @@ void ex_while(exarg_T *eap) if (cstack->cs_idx == CSTACK_LEN - 1) { eap->errmsg = _("E585: :while/:for nesting too deep"); } else { - int result; + bool result; // The loop flag is set when we have jumped back from the matching // ":endwhile" or ":endfor". When not set, need to initialise this // cstack entry. @@ -1183,7 +1183,7 @@ void ex_throw(exarg_T *eap) /// used for rethrowing an uncaught exception. void do_throw(cstack_T *cstack) { - int inactivate_try = false; + bool inactivate_try = false; // Cleanup and deactivate up to the next surrounding try conditional that // is not in its finally clause. Normally, do not deactivate the try @@ -1861,7 +1861,7 @@ void leave_cleanup(cleanup_T *csp) int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive) { int idx; - int stop = false; + bool stop = false; for (idx = cstack->cs_idx; idx >= 0; idx--) { if (cstack->cs_flags[idx] & CSF_TRY) { @@ -1998,7 +1998,7 @@ void ex_endfunction(exarg_T *eap) } /// @return true if the string "p" looks like a ":while" or ":for" command. -int has_loop_cmd(char *p) +bool has_loop_cmd(char *p) { // skip modifiers, white space and ':' while (true) { -- cgit From c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 28 Dec 2023 13:42:24 +0100 Subject: refactor: follow style guide --- src/nvim/ex_eval.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index c239e8a9ea..fd41ea1b91 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -105,7 +105,7 @@ static bool cause_abort = false; /// That is, during cancellation of an expression evaluation after an aborting /// function call or due to a parsing error, aborting() always returns the same /// value. "got_int" is also set by calling interrupt(). -int aborting(void) +bool aborting(void) { return (did_emsg && force_abort) || got_int || did_throw; } @@ -125,7 +125,7 @@ void update_force_abort(void) /// abort the script processing. Can be used to suppress an autocommand after /// execution of a failing subcommand as long as the error message has not been /// displayed and actually caused the abortion. -int should_abort(int retcode) +bool should_abort(int retcode) { return (retcode == FAIL && trylevel != 0 && !emsg_silent) || aborting(); } @@ -134,7 +134,7 @@ int should_abort(int retcode) /// ended on an error. This means that parsing commands is continued in order /// to find finally clauses to be executed, and that some errors in skipped /// commands are still reported. -int aborted_in_try(void) +bool aborted_in_try(void) FUNC_ATTR_PURE { // This function is only called after an error. In this case, "force_abort" @@ -326,7 +326,7 @@ void do_errthrow(cstack_T *cstack, char *cmdname) /// /// @return true if the current exception is discarded or, /// false otherwise. -int do_intthrow(cstack_T *cstack) +bool do_intthrow(cstack_T *cstack) { // If no interrupt occurred or no try conditional is active and no exception // is being thrown, do nothing (for compatibility of non-EH scripts). @@ -369,7 +369,7 @@ int do_intthrow(cstack_T *cstack) } /// Get an exception message that is to be stored in current_exception->value. -char *get_exception_string(void *value, except_type_T type, char *cmdname, int *should_free) +char *get_exception_string(void *value, except_type_T type, char *cmdname, bool *should_free) { char *ret; @@ -454,7 +454,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) excp->messages = (msglist_T *)value; } - int should_free; + bool should_free; excp->value = get_exception_string(value, type, cmdname, &should_free); if (excp->value == NULL && should_free) { goto nomem; @@ -841,7 +841,7 @@ void ex_if(exarg_T *eap) cstack->cs_idx++; cstack->cs_flags[cstack->cs_idx] = 0; - int skip = CHECK_SKIP; + bool skip = CHECK_SKIP; bool error; bool result = eval_to_bool(eap->arg, &error, eap, skip); @@ -875,7 +875,7 @@ void ex_endif(exarg_T *eap) // discarded by throwing the interrupt exception later on. if (!(eap->cstack->cs_flags[eap->cstack->cs_idx] & CSF_TRUE) && dbg_check_skipped(eap)) { - (void)do_intthrow(eap->cstack); + do_intthrow(eap->cstack); } eap->cstack->cs_idx--; @@ -926,7 +926,7 @@ void ex_else(exarg_T *eap) // for a parsing errors is discarded when throwing the interrupt exception // later on. if (!skip && dbg_check_skipped(eap) && got_int) { - (void)do_intthrow(cstack); + do_intthrow(cstack); skip = true; } @@ -1132,7 +1132,7 @@ void ex_endwhile(exarg_T *eap) } } // Cleanup and rewind all contained (and unclosed) conditionals. - (void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, false); + cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, false); rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel); } else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE) @@ -1145,7 +1145,7 @@ void ex_endwhile(exarg_T *eap) // throw an interrupt exception if appropriate. Doing this here // prevents that an exception for a parsing error is discarded when // throwing the interrupt exception later on. - (void)do_intthrow(cstack); + do_intthrow(cstack); } // Set loop flag, so do_cmdline() will jump back to the matching @@ -1476,7 +1476,7 @@ void ex_finally(exarg_T *eap) // occurred before the ":finally". That is, discard the // original exception and replace it by an interrupt // exception. - (void)do_intthrow(cstack); + do_intthrow(cstack); } // If there is a preceding catch clause and it caught the exception, @@ -1617,7 +1617,7 @@ void ex_endtry(exarg_T *eap) // set "skip" and "rethrow". if (got_int) { skip = true; - (void)do_intthrow(cstack); + do_intthrow(cstack); // The do_intthrow() call may have reset did_throw or // cstack->cs_pending[idx]. rethrow = false; @@ -1649,7 +1649,7 @@ void ex_endtry(exarg_T *eap) // was no finally clause, finish the exception now. This happens also // after errors except when this ":endtry" is not within a ":try". // Restore "emsg_silent" if it has been reset by this try conditional. - (void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, true); + cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, true); if (cstack->cs_idx >= 0 && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { cstack->cs_idx--; -- cgit From b49d4e18a67d16548fa72013237a87564656170e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 1 Jan 2024 15:56:00 +0100 Subject: refactor: remove redundant NOLINT comments --- 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 fd41ea1b91..90dfa45c47 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -223,7 +223,7 @@ bool cause_errthrow(const char *mesg, bool multiline, bool severe, bool *ignore) // catch clause; just finally clauses are executed before the script // is terminated. return false; - } else // NOLINT(readability/braces) + } else #endif { // Prepare the throw of an error exception, so that everything will -- cgit From 1813661a6197c76ea6621284570aca1d56597099 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 4 Jan 2024 15:38:16 +0100 Subject: refactor(IWYU): fix headers Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want. --- src/nvim/ex_eval.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 90dfa45c47..472741d537 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -13,18 +13,22 @@ #include "nvim/debugger.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/eval/userfunc.h" +#include "nvim/eval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_eval_defs.h" -#include "nvim/gettext.h" +#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_vars.h" #include "nvim/regexp.h" +#include "nvim/regexp_defs.h" #include "nvim/runtime.h" +#include "nvim/runtime_defs.h" #include "nvim/strings.h" #include "nvim/vim_defs.h" -- cgit