diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 71 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_eval.c | 34 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/message.c | 9 |
5 files changed, 59 insertions, 59 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8e3109b8be..5aeb6fa746 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1679,7 +1679,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) arg = (const char *)find_name_end((char_u *)arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) { - emsg_severe = TRUE; + emsg_severe = true; EMSG(_(e_trailing)); break; } @@ -1692,7 +1692,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first) /* This is mainly to keep test 49 working: when expanding * curly braces fails overrule the exception error message. */ if (len < 0 && !aborting()) { - emsg_severe = TRUE; + emsg_severe = true; EMSG2(_(e_invarg2), arg); break; } @@ -2007,7 +2007,7 @@ char_u *get_lval(char_u *const name, typval_T *const rettv, * expression evaluation has been cancelled due to an * aborting error, an interrupt, or an exception. */ if (!aborting() && !quiet) { - emsg_severe = TRUE; + emsg_severe = true; EMSG2(_(e_invarg2), name); return NULL; } @@ -2675,6 +2675,7 @@ void ex_lockvar(exarg_T *eap) static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep) { char_u *arg = argstart; + char_u *name_end; bool error = false; lval_T lv; @@ -2687,43 +2688,43 @@ static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep) return; } os_unsetenv(name); - arg = skipwhite(arg); - continue; - } - - // Parse the name and find the end. - char_u *const name_end = (char_u *)get_lval(arg, NULL, &lv, true, - eap->skip || error, - 0, FNE_CHECK_START); - if (lv.ll_name == NULL) { - error = true; // error, but continue parsing. - } - if (name_end == NULL || (!ascii_iswhite(*name_end) - && !ends_excmd(*name_end))) { - if (name_end != NULL) { - emsg_severe = TRUE; - EMSG(_(e_trailing)); + name_end = arg; + } else { + // Parse the name and find the end. + name_end = get_lval(arg, NULL, &lv, true, eap->skip || error, + 0, FNE_CHECK_START); + if (lv.ll_name == NULL) { + error = true; // error, but continue parsing. + } + if (name_end == NULL + || (!ascii_iswhite(*name_end) && !ends_excmd(*name_end))) { + if (name_end != NULL) { + emsg_severe = true; + EMSG(_(e_trailing)); + } + if (!(eap->skip || error)) { + clear_lval(&lv); + } + break; } - if (!(eap->skip || error)) - clear_lval(&lv); - break; - } - if (!error && !eap->skip) { - if (eap->cmdidx == CMD_unlet) { - if (do_unlet_var(&lv, name_end, eap->forceit) == FAIL) - error = TRUE; - } else { - if (do_lock_var(&lv, name_end, deep, - eap->cmdidx == CMD_lockvar) == FAIL) { - error = true; + if (!error && !eap->skip) { + if (eap->cmdidx == CMD_unlet) { + if (do_unlet_var(&lv, name_end, eap->forceit) == FAIL) { + error = true; + } + } else { + if (do_lock_var(&lv, name_end, deep, + eap->cmdidx == CMD_lockvar) == FAIL) { + error = true; + } } } - } - - if (!eap->skip) - clear_lval(&lv); + if (!eap->skip) { + clear_lval(&lv); + } + } arg = skipwhite(name_end); } while (!ends_excmd(*arg)); diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 46eccd5181..c4a7a210f1 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2886,7 +2886,7 @@ void ex_call(exarg_T *eap) if (!failed || eap->cstack->cs_trylevel > 0) { // Check for trailing illegal characters and a following command. if (!ends_excmd(*arg)) { - emsg_severe = TRUE; + emsg_severe = true; EMSG(_(e_trailing)); } else { eap->nextcmd = check_nextcmd(arg); diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index e99e5b01cd..0c7562980a 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -138,16 +138,15 @@ int aborted_in_try(void) return force_abort; } -/* - * cause_errthrow(): Cause a throw of an error exception if appropriate. - * Return TRUE if the error message should not be displayed by emsg(). - * Sets "ignore", if the emsg() call should be ignored completely. - * - * When several messages appear in the same command, the first is usually the - * most specific one and used as the exception value. The "severe" flag can be - * set to TRUE, if a later but severer message should be used instead. - */ -int cause_errthrow(char_u *mesg, int severe, int *ignore) +// cause_errthrow(): Cause a throw of an error exception if appropriate. +// Return true if the error message should not be displayed by emsg(). +// Sets "ignore", if the emsg() call should be ignored completely. +// +// When several messages appear in the same command, the first is usually the +// most specific one and used as the exception value. The "severe" flag can be +// set to true, if a later but severer message should be used instead. +bool cause_errthrow(const char_u *mesg, bool severe, bool *ignore) + FUNC_ATTR_NONNULL_ALL { struct msglist *elem; struct msglist **plist; @@ -158,8 +157,9 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore) * level. Also when no exception can be thrown. The message will be * displayed by emsg(). */ - if (suppress_errthrow) - return FALSE; + if (suppress_errthrow) { + return false; + } /* * If emsg() has not been called previously, temporarily reset @@ -195,8 +195,8 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore) * not replaced by an interrupt message error exception. */ if (mesg == (char_u *)_(e_interr)) { - *ignore = TRUE; - return TRUE; + *ignore = true; + return true; } /* @@ -231,8 +231,8 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore) * catch clause; just finally clauses are executed before the script * is terminated. */ - return FALSE; - } else + return false; + } else // NOLINT(readability/braces) #endif { /* @@ -271,7 +271,7 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore) (*msg_list)->throw_msg = tmsg; } } - return TRUE; + return true; } } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index d6d00d6e83..91a0eab947 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -208,7 +208,7 @@ EXTERN int need_clr_eos INIT(= false); // need to clear text before // displaying a message. EXTERN int emsg_skip INIT(= 0); // don't display errors for // expression that is skipped -EXTERN int emsg_severe INIT(= false); // use message of next of several +EXTERN bool emsg_severe INIT(= false); // use message of next of several // emsg() calls for throw EXTERN int did_endif INIT(= false); // just had ":endif" EXTERN dict_T vimvardict; // Dictionary with v: variables diff --git a/src/nvim/message.c b/src/nvim/message.c index 8999365d32..e4f47917ec 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -607,8 +607,7 @@ int emsg_not_now(void) static bool emsg_multiline(const char *s, bool multiline) { int attr; - int ignore = false; - int severe; + bool ignore = false; // Skip this if not giving error messages at the moment. if (emsg_not_now()) { @@ -617,9 +616,9 @@ static bool emsg_multiline(const char *s, bool multiline) called_emsg = true; - // If "emsg_severe" is TRUE: When an error exception is to be thrown, + // If "emsg_severe" is true: When an error exception is to be thrown, // prefer this message over previous messages for the same command. - severe = emsg_severe; + bool severe = emsg_severe; emsg_severe = false; if (!emsg_off || vim_strchr(p_debug, 't') != NULL) { @@ -630,7 +629,7 @@ static bool emsg_multiline(const char *s, bool multiline) * when the message should be ignored completely (used for the * interrupt message). */ - if (cause_errthrow((char_u *)s, severe, &ignore) == true) { + if (cause_errthrow((char_u *)s, severe, &ignore)) { if (!ignore) { did_emsg++; } |