diff options
Diffstat (limited to 'src/nvim/ex_eval.c')
-rw-r--r-- | src/nvim/ex_eval.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index d2a1d53b78..472741d537 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -13,19 +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/func_attr.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" @@ -93,7 +96,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. @@ -106,7 +109,7 @@ static int 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; } @@ -126,7 +129,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(); } @@ -135,7 +138,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" @@ -224,7 +227,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 @@ -327,7 +330,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). @@ -370,7 +373,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; @@ -455,7 +458,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; @@ -842,10 +845,10 @@ 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; - 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) { @@ -876,7 +879,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--; @@ -927,7 +930,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; } @@ -972,7 +975,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. @@ -1133,7 +1136,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) @@ -1146,7 +1149,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 @@ -1184,7 +1187,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 @@ -1477,7 +1480,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, @@ -1618,7 +1621,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; @@ -1650,7 +1653,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--; @@ -1862,7 +1865,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) { @@ -1999,7 +2002,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) { |