diff options
| author | ZyX <kp-pav@yandex.ru> | 2016-05-01 20:35:51 +0300 |
|---|---|---|
| committer | ZyX <kp-pav@yandex.ru> | 2016-05-01 20:35:51 +0300 |
| commit | cf4e1fb0f4962319eee292248d9c1f73be3a8d0c (patch) | |
| tree | 60b1d2aad6205c74b7c2611fbbed45759a302f4f /src | |
| parent | a1f985f60a228604970a70872b7ea1fb5299eba3 (diff) | |
| download | rneovim-cf4e1fb0f4962319eee292248d9c1f73be3a8d0c.tar.gz rneovim-cf4e1fb0f4962319eee292248d9c1f73be3a8d0c.tar.bz2 rneovim-cf4e1fb0f4962319eee292248d9c1f73be3a8d0c.zip | |
*: Fix new linter errors
Originally there were 128 new errors, so I thought this is a good idea to fix
all of them. Of course, this commit also fixes many suppressed errors.
Diffstat (limited to 'src')
38 files changed, 561 insertions, 613 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index a52f53a3e6..f644453358 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -57,8 +57,8 @@ void window_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err) { win_T *win = find_window_by_handle(window, err); - if (pos.size != 2 || pos.items[0].type != kObjectTypeInteger || - pos.items[1].type != kObjectTypeInteger) { + if (pos.size != 2 || pos.items[0].type != kObjectTypeInteger + || pos.items[1].type != kObjectTypeInteger) { api_set_error(err, Validation, _("Argument \"pos\" must be a [row, col] array")); diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index b432e12c02..db97bd9dc4 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -1367,8 +1367,8 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int prev_laa = A_firstc_laa(prev_c, prev_c1); if (curr_laa) { - if (A_is_valid(prev_c) && !A_is_f(shape_c) && !A_is_s(shape_c) && - !prev_laa) { + if (A_is_valid(prev_c) && !A_is_f(shape_c) && !A_is_s(shape_c) + && !prev_laa) { curr_c = chg_c_laa2f(curr_laa); } else { curr_c = chg_c_laa2i(curr_laa); @@ -1454,19 +1454,19 @@ static bool A_is_harakat(int c) // (alphabet/number/punctuation) static bool A_is_iso(int c) { - return (c >= a_HAMZA && c <= a_GHAIN) || - (c >= a_TATWEEL && c <= a_HAMZA_BELOW) || - c == a_MINI_ALEF; + return ((c >= a_HAMZA && c <= a_GHAIN) + || (c >= a_TATWEEL && c <= a_HAMZA_BELOW) + || c == a_MINI_ALEF); } // A_is_formb returns true if 'c' is an Arabic 10646-1 FormB character. // (alphabet/number/punctuation) static bool A_is_formb(int c) { - return (c >= a_s_FATHATAN && c <= a_s_DAMMATAN) || - c == a_s_KASRATAN || - (c >= a_s_FATHA && c <= a_f_LAM_ALEF) || - c == a_BYTE_ORDER_MARK; + return ((c >= a_s_FATHATAN && c <= a_s_DAMMATAN) + || c == a_s_KASRATAN + || (c >= a_s_FATHA && c <= a_f_LAM_ALEF) + || c == a_BYTE_ORDER_MARK); } // A_is_ok returns true if 'c' is an Arabic 10646 (8859-6 or Form-B). diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 6ed5b3136f..b00f5e8e5b 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -407,10 +407,9 @@ close_buffer ( buf->b_nwindows = nwindows; buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); - if ( - win_valid(win) && - win->w_buffer == buf) - win->w_buffer = NULL; /* make sure we don't use the buffer now */ + if (win_valid(win) && win->w_buffer == buf) { + win->w_buffer = NULL; // make sure we don't use the buffer now + } /* Autocommands may have deleted the buffer. */ if (!buf_valid(buf)) @@ -1340,8 +1339,8 @@ buflist_new ( /* We can use inode numbers when the file exists. Works better * for hard links. */ FileID file_id; - bool file_id_valid = (sfname != NULL && - os_fileid((char *)sfname, &file_id)); + bool file_id_valid = (sfname != NULL + && os_fileid((char *)sfname, &file_id)); if (ffname != NULL && !(flags & BLN_DUMMY) && (buf = buflist_findname_file_id(ffname, &file_id, file_id_valid)) != NULL) { diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 26966b35c1..2c240a0f59 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -4424,11 +4424,10 @@ static int ins_complete(int c, bool enable_pum) prefix = (char_u *)""; STRCPY((char *)compl_pattern, prefix); (void)quote_meta(compl_pattern + STRLEN(prefix), - line + compl_col, compl_length); - } else if (--startcol < 0 || - !vim_iswordp(mb_prevptr(line, line + startcol + 1)) - ) { - /* Match any word of at least two chars */ + line + compl_col, compl_length); + } else if (--startcol < 0 + || !vim_iswordp(mb_prevptr(line, line + startcol + 1))) { + // Match any word of at least two chars compl_pattern = vim_strsave((char_u *)"\\<\\k\\k"); compl_col += curs_col; compl_length = 0; @@ -6684,8 +6683,8 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } else if (*look == 'e') { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) { p = get_cursor_line_ptr(); - if (skipwhite(p) == p + curwin->w_cursor.col - 4 && - STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) { + if (skipwhite(p) == p + curwin->w_cursor.col - 4 + && STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) { return true; } } @@ -7384,17 +7383,16 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) * can't backup past starting point unless 'backspace' > 1 * can backup to a previous line if 'backspace' == 0 */ - if ( bufempty() - || ( - !revins_on && - ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0) - || (!can_bs(BS_START) - && (arrow_used - || (curwin->w_cursor.lnum == Insstart_orig.lnum - && curwin->w_cursor.col <= Insstart_orig.col))) - || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0 - && curwin->w_cursor.col <= ai_col) - || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) { + if (bufempty() + || (!revins_on + && ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0) + || (!can_bs(BS_START) + && (arrow_used + || (curwin->w_cursor.lnum == Insstart_orig.lnum + && curwin->w_cursor.col <= Insstart_orig.col))) + || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0 + && curwin->w_cursor.col <= ai_col) + || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) { vim_beep(BO_BS); return false; } @@ -7640,14 +7638,14 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) if (revins_on && gchar_cursor() == NUL) break; } - /* Just a single backspace?: */ - if (mode == BACKSPACE_CHAR) + // Just a single backspace?: + if (mode == BACKSPACE_CHAR) { break; - } while ( - revins_on || - (curwin->w_cursor.col > mincol - && (curwin->w_cursor.lnum != Insstart_orig.lnum - || curwin->w_cursor.col != Insstart_orig.col))); + } + } while (revins_on + || (curwin->w_cursor.col > mincol + && (curwin->w_cursor.lnum != Insstart_orig.lnum + || curwin->w_cursor.col != Insstart_orig.col))); } did_backspace = true; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c9fecbf599..fdeb2c1371 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2266,8 +2266,8 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name), &tv, &di, true, false) == OK) { if ((di == NULL - || (!var_check_ro(di->di_flags, lp->ll_name, false) && - !tv_check_lock(di->di_tv.v_lock, lp->ll_name, false))) + || (!var_check_ro(di->di_flags, lp->ll_name, false) + && !tv_check_lock(di->di_tv.v_lock, lp->ll_name, false))) && tv_op(&tv, rettv, op) == OK) { set_var(lp->ll_name, &tv, false); } @@ -7655,8 +7655,9 @@ static void assert_bool(typval_T *argvars, bool is_true) int error = (int)false; garray_T ga; - if ((argvars[0].v_type != VAR_NUMBER || - (get_tv_number_chk(&argvars[0], &error) == 0) == is_true || error) + if ((argvars[0].v_type != VAR_NUMBER + || (get_tv_number_chk(&argvars[0], &error) == 0) == is_true + || error) && (argvars[0].v_type != VAR_SPECIAL || (argvars[0].vval.v_special != (SpecialVarValue) (is_true @@ -15140,12 +15141,12 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) EMSG2(_(e_listarg), sort ? "sort()" : "uniq()"); } else { l = argvars[0].vval.v_list; - if (l == NULL || - tv_check_lock(l->lv_lock, - (char_u *)(sort - ? N_("sort() argument") - : N_("uniq() argument")), - true)) { + if (l == NULL + || tv_check_lock(l->lv_lock, + (char_u *)(sort + ? N_("sort() argument") + : N_("uniq() argument")), + true)) { return; } rettv->vval.v_list = l; @@ -19265,9 +19266,10 @@ void ex_function(exarg_T *eap) if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p')) || (p[0] == 'i' && (!ASCII_ISALPHA(p[1]) || (p[1] == 'n' - && (!ASCII_ISALPHA(p[2]) || - (p[2] == 's')))))) + && (!ASCII_ISALPHA(p[2]) + || (p[2] == 's')))))) { skip_until = vim_strsave((char_u *)"."); + } // Check for ":python <<EOF", ":lua <<EOF", etc. arg = skipwhite(skiptowhite(p)); @@ -19534,11 +19536,12 @@ trans_function_name ( *pp = end; } else { if (!skip && !(flags & TFN_QUIET) && (fdp == NULL - || lv.ll_dict == NULL || - fdp->fd_newkey == NULL)) + || lv.ll_dict == NULL + || fdp->fd_newkey == NULL)) { EMSG(_(e_funcref)); - else + } else { *pp = end; + } name = NULL; } goto theend; @@ -20438,9 +20441,9 @@ call_user_func ( --RedrawingDisabled; - /* when the function was aborted because of an error, return -1 */ - if ((did_emsg && - (fp->uf_flags & FC_ABORT)) || rettv->v_type == VAR_UNKNOWN) { + // when the function was aborted because of an error, return -1 + if ((did_emsg + && (fp->uf_flags & FC_ABORT)) || rettv->v_type == VAR_UNKNOWN) { clear_tv(rettv); rettv->v_type = VAR_NUMBER; rettv->vval.v_number = -1; diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index e6012595fd..9bb62891c7 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -187,9 +187,9 @@ int process_wait(Process *proc, int ms, Queue *events) FUNC_ATTR_NONNULL_ARG(1) // being freed) before we have a chance to get the status. proc->refcount++; LOOP_PROCESS_EVENTS_UNTIL(proc->loop, events, ms, - // Until... - got_int || // interrupted by the user - proc->refcount == 1); // job exited + // Until... + got_int // interrupted by the user + || proc->refcount == 1); // job exited // we'll assume that a user frantically hitting interrupt doesn't like // the current job. Signal that it has to be killed. diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d020bc8f20..e8314e02e0 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -650,13 +650,13 @@ void ex_retab(exarg_T *eap) num_tabs += num_spaces / new_ts; num_spaces -= (num_spaces / new_ts) * new_ts; } - if (curbuf->b_p_et || got_tab || - (num_spaces + num_tabs < len)) { - if (did_undo == FALSE) { - did_undo = TRUE; + if (curbuf->b_p_et || got_tab + || (num_spaces + num_tabs < len)) { + if (did_undo == false) { + did_undo = true; if (u_save((linenr_T)(lnum - 1), - (linenr_T)(lnum + 1)) == FAIL) { - new_line = NULL; /* flag out-of-memory */ + (linenr_T)(lnum + 1)) == FAIL) { + new_line = NULL; // flag out-of-memory break; } } @@ -1623,15 +1623,14 @@ int do_write(exarg_T *eap) } } - /* - * Writing to the current file is not allowed in readonly mode - * and a file name is required. - * "nofile" and "nowrite" buffers cannot be written implicitly either. - */ - if (!other && ( - bt_dontwrite_msg(curbuf) || - check_fname() == FAIL || check_readonly(&eap->forceit, curbuf))) + // Writing to the current file is not allowed in readonly mode + // and a file name is required. + // "nofile" and "nowrite" buffers cannot be written implicitly either. + if (!other && (bt_dontwrite_msg(curbuf) + || check_fname() == FAIL + || check_readonly(&eap->forceit, curbuf))) { goto theend; + } if (!other) { ffname = curbuf->b_ffname; @@ -2258,16 +2257,15 @@ do_ecmd ( delbuf_msg(new_name); /* frees new_name */ goto theend; } - if (buf == curbuf) /* already in new buffer */ - auto_buf = TRUE; - else { - /* - * <VN> We could instead free the synblock - * and re-attach to buffer, perhaps. - */ - if (curwin->w_buffer != NULL && - curwin->w_s == &(curwin->w_buffer->b_s)) + if (buf == curbuf) { // already in new buffer + auto_buf = true; + } else { + // <VN> We could instead free the synblock + // and re-attach to buffer, perhaps. + if (curwin->w_buffer != NULL + && curwin->w_s == &(curwin->w_buffer->b_s)) { curwin->w_s = &(buf->b_s); + } curwin->w_buffer = buf; curbuf = buf; @@ -2294,11 +2292,11 @@ do_ecmd ( curwin->w_pcmark.lnum = 1; curwin->w_pcmark.col = 0; - } else { /* !other_file */ - if ( - (flags & ECMD_ADDBUF) || - check_fname() == FAIL) + } else { // !other_file + if ((flags & ECMD_ADDBUF) + || check_fname() == FAIL) { goto theend; + } oldbuf = (flags & ECMD_OLDBUF); } @@ -5818,13 +5816,14 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg) switch (cmd_idx) { case SIGNCMD_DEFINE: - if (STRNCMP(last, "texthl", p - last) == 0 || - STRNCMP(last, "linehl", p - last) == 0) + if (STRNCMP(last, "texthl", p - last) == 0 + || STRNCMP(last, "linehl", p - last) == 0) { xp->xp_context = EXPAND_HIGHLIGHT; - else if (STRNCMP(last, "icon", p - last) == 0) + } else if (STRNCMP(last, "icon", p - last) == 0) { xp->xp_context = EXPAND_FILES; - else + } else { xp->xp_context = EXPAND_NOTHING; + } break; case SIGNCMD_PLACE: if (STRNCMP(last, "name", p - last) == 0) diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 6723bfc7e0..12efddc205 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -432,14 +432,12 @@ dbg_parsearg ( bp = &DEBUGGY(gap, gap->ga_len); - /* Find "func" or "file". */ - if (STRNCMP(p, "func", 4) == 0) + // Find "func" or "file". + if (STRNCMP(p, "func", 4) == 0) { bp->dbg_type = DBG_FUNC; - else if (STRNCMP(p, "file", 4) == 0) + } else if (STRNCMP(p, "file", 4) == 0) { bp->dbg_type = DBG_FILE; - else if ( - gap != &prof_ga && - STRNCMP(p, "here", 4) == 0) { + } else if (gap != &prof_ga && STRNCMP(p, "here", 4) == 0) { if (curbuf->b_ffname == NULL) { EMSG(_(e_noname)); return FAIL; @@ -452,16 +450,15 @@ dbg_parsearg ( } p = skipwhite(p + 4); - /* Find optional line number. */ - if (here) + // Find optional line number. + if (here) { bp->dbg_lnum = curwin->w_cursor.lnum; - else if ( - gap != &prof_ga && - ascii_isdigit(*p)) { + } else if (gap != &prof_ga && ascii_isdigit(*p)) { bp->dbg_lnum = getdigits_long(&p); p = skipwhite(p); - } else + } else { bp->dbg_lnum = 0; + } /* Find the function or file name. Don't accept a function name with (). */ if ((!here && *p == NUL) @@ -700,14 +697,13 @@ debuggy_find ( /* Skip entries that are not useful or are for a line that is beyond * an already found breakpoint. */ bp = &DEBUGGY(gap, i); - if (((bp->dbg_type == DBG_FILE) == file && ( - gap == &prof_ga || - (bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum))))) { - /* - * Save the value of got_int and reset it. We don't want a - * previous interruption cancel matching, only hitting CTRL-C - * while matching should abort it. - */ + if (((bp->dbg_type == DBG_FILE) == file + && (gap == &prof_ga + || (bp->dbg_lnum > after + && (lnum == 0 || bp->dbg_lnum < lnum))))) { + // Save the value of got_int and reset it. We don't want a + // previous interruption cancel matching, only hitting CTRL-C + // while matching should abort it. prev_got_int = got_int; got_int = FALSE; if (vim_regexec_prog(&bp->dbg_prog, false, name, (colnr_T)0)) { @@ -1937,8 +1933,8 @@ void ex_listdo(exarg_T *eap) if (buf != NULL) { goto_buffer(eap, DOBUF_FIRST, FORWARD, buf->b_fnum); } - } else if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo || - eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) { + } else if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo + || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) { qf_size = qf_get_size(eap); assert(eap->line1 >= 0); if (qf_size == 0 || (size_t)eap->line1 > qf_size) { @@ -2040,8 +2036,8 @@ void ex_listdo(exarg_T *eap) } } - if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo || - eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) { + if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo + || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) { assert(i >= 0); if ((size_t)i >= qf_size || i >= eap->line2) { break; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 641edda343..89c35a3c45 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1654,16 +1654,15 @@ static char_u * do_one_cmd(char_u **cmdlinep, * If we got a line, but no command, then go to the line. * If we find a '|' or '\n' we set ea.nextcmd. */ - if (*ea.cmd == NUL || *ea.cmd == '"' || - (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) { - /* - * strange vi behaviour: - * ":3" jumps to line 3 - * ":3|..." prints line 3 - * ":|" prints current line - */ - if (ea.skip) /* skip this if inside :if */ + if (*ea.cmd == NUL || *ea.cmd == '"' + || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) { + // strange vi behaviour: + // ":3" jumps to line 3 + // ":3|..." prints line 3 + // ":|" prints current line + if (ea.skip) { // skip this if inside :if goto doend; + } if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) { ea.cmdidx = CMD_print; ea.argt = RANGE | COUNT | TRLBAR; @@ -2824,10 +2823,11 @@ set_one_cmd_context ( } } - /* no arguments allowed */ - if (!(ea.argt & EXTRA) && *arg != NUL && - vim_strchr((char_u *)"|\"", *arg) == NULL) + // no arguments allowed + if (!(ea.argt & EXTRA) && *arg != NUL + && vim_strchr((char_u *)"|\"", *arg) == NULL) { return NULL; + } /* Find start of last argument (argument just before cursor): */ p = buff; @@ -4772,14 +4772,15 @@ static void uc_list(char_u *name, size_t name_len) IObuff[len++] = ' '; } while (len < 11); - /* Address Type */ - for (j = 0; addr_type_complete[j].expand != -1; ++j) - if (addr_type_complete[j].expand != ADDR_LINES && - addr_type_complete[j].expand == cmd->uc_addr_type) { + // Address Type + for (j = 0; addr_type_complete[j].expand != -1; j++) { + if (addr_type_complete[j].expand != ADDR_LINES + && addr_type_complete[j].expand == cmd->uc_addr_type) { STRCPY(IObuff + len, addr_type_complete[j].name); len += (int)STRLEN(IObuff + len); break; } + } do { IObuff[len++] = ' '; @@ -5654,12 +5655,13 @@ static void ex_quit(exarg_T *eap) wp = curwin; } - apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); - /* Refuse to quit when locked or when the buffer in the last window is - * being closed (can only happen in autocommands). */ - if (curbuf_locked() || - (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_closing)) + apply_autocmds(EVENT_QUITPRE, NULL, NULL, false, curbuf); + // Refuse to quit when locked or when the buffer in the last window is + // being closed (can only happen in autocommands). + if (curbuf_locked() + || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_closing)) { return; + } /* @@ -9185,16 +9187,15 @@ static char *get_view_file(int c) */ int put_eol(FILE *fd) { - if ( -#ifdef USE_CRNL - ( -# ifdef MKSESSION_NL - !mksession_nl && -# endif - (putc('\r', fd) < 0)) || +#if defined(USE_CRNL) && defined(MKSESSION_NL) + if ((!mksession_nl && putc('\r', fd) < 0) || putc('\n', fd) < 0) { +#elif defined(USE_CRNL) + if (putc('\r', fd) < 0 || putc('\n', fd) < 0) { +#else + if (putc('\n', fd) < 0) { #endif - (putc('\n', fd) < 0)) return FAIL; + } return OK; } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 41ad96a378..82d4c2b2d5 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -403,14 +403,15 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should && (p[3] == ':' || (ascii_isdigit(p[3]) && p[4] == ':')))))) { - if (*p == NUL || p == mesg) - STRCAT(val, mesg); /* 'E123' missing or at beginning */ - else { - /* '"filename" E123: message text' */ - if (mesg[0] != '"' || p-2 < &mesg[1] || - p[-2] != '"' || p[-1] != ' ') - /* "E123:" is part of the file name. */ + if (*p == NUL || p == mesg) { + STRCAT(val, mesg); // 'E123' missing or at beginning + } else { + // '"filename" E123: message text' + if (mesg[0] != '"' || p-2 < &mesg[1] + || p[-2] != '"' || p[-1] != ' ') { + // "E123:" is part of the file name. continue; + } STRCAT(val, p); p[-2] = NUL; @@ -1565,22 +1566,21 @@ void ex_endtry(exarg_T *eap) void *rettv = NULL; struct condstack *cstack = eap->cstack; - if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) + if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) { eap->errmsg = (char_u *)N_("E602: :endtry without :try"); - else { - /* - * Don't do something after an error, interrupt or throw in the try - * block, catch clause, or finally clause preceding this ":endtry" or - * when an error or interrupt occurred after a ":continue", ":break", - * ":return", or ":finish" in a try block or catch clause preceding this - * ":endtry" or when the try block never got active (because of an - * inactive surrounding conditional or after an error or interrupt or - * throw) or when there is a surrounding conditional and it has been - * made inactive by a ":continue", ":break", ":return", or ":finish" in - * the finally clause. The latter case need not be tested since then - * anything pending has already been discarded. */ - skip = did_emsg || got_int || did_throw || - !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE); + } else { + // Don't do something after an error, interrupt or throw in the try + // block, catch clause, or finally clause preceding this ":endtry" or + // when an error or interrupt occurred after a ":continue", ":break", + // ":return", or ":finish" in a try block or catch clause preceding this + // ":endtry" or when the try block never got active (because of an + // inactive surrounding conditional or after an error or interrupt or + // throw) or when there is a surrounding conditional and it has been + // made inactive by a ":continue", ":break", ":return", or ":finish" in + // the finally clause. The latter case need not be tested since then + // anything pending has already been discarded. + skip = (did_emsg || got_int || did_throw + || !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE)); if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { eap->errmsg = get_end_emsg(cstack); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 5537cb70a4..7d911ee93e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -624,8 +624,8 @@ static int command_line_execute(VimState *state, int key) // CTRL-\ e doesn't work when obtaining an expression, unless it // is in a mapping. if (s->c != Ctrl_N && s->c != Ctrl_G && (s->c != 'e' - || (ccline.cmdfirstc == '=' && - KeyTyped))) { + || (ccline.cmdfirstc == '=' + && KeyTyped))) { vunge |