aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c21
-rw-r--r--src/nvim/menu.c11
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/quickfix.c10
-rw-r--r--src/nvim/tag.c236
5 files changed, 131 insertions, 149 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 06054b53ec..bd61925b0d 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -19811,16 +19811,15 @@ void ex_echo(exarg_T *eap)
{
char_u *arg = eap->arg;
typval_T rettv;
- bool needclr = true;
bool atstart = true;
const int did_emsg_before = did_emsg;
if (eap->skip)
++emsg_skip;
while (*arg != NUL && *arg != '|' && *arg != '\n' && !got_int) {
- /* If eval1() causes an error message the text from the command may
- * still need to be cleared. E.g., "echo 22,44". */
- need_clr_eos = needclr;
+ // If eval1() causes an error message the text from the command may
+ // still need to be cleared. E.g., "echo 22,44".
+ need_clr_eos = true;
{
char_u *p = arg;
@@ -19864,14 +19863,14 @@ void ex_echo(exarg_T *eap)
}
eap->nextcmd = check_nextcmd(arg);
- if (eap->skip)
- --emsg_skip;
- else {
- /* remove text that may still be there from the command */
- if (needclr)
- msg_clr_eos();
- if (eap->cmdidx == CMD_echo)
+ if (eap->skip) {
+ emsg_skip--;
+ } else {
+ // remove text that may still be there from the command
+ msg_clr_eos();
+ if (eap->cmdidx == CMD_echo) {
msg_end();
+ }
}
}
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 523bb20738..472481bb30 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -774,15 +774,12 @@ static vimmenu_T *find_menu(vimmenu_T *menu, char_u *name, int modes)
if (menu_name_equal(name, menu)) {
// Found menu
if (*p != NUL && menu->children == NULL) {
- if (*p != NUL) {
EMSG(_(e_notsubmenu));
return NULL;
- } else if ((menu->modes & modes) == 0x0) {
- EMSG(_(e_othermode));
- return NULL;
- }
- }
- if (*p == NUL) { // found a full match
+ } else if ((menu->modes & modes) == 0x0) {
+ EMSG(_(e_othermode));
+ return NULL;
+ } else if (*p == NUL) { // found a full match
return menu;
}
break;
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 28855402f4..4c5f357451 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1880,7 +1880,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr,
}
// Concat pieces with the same highlight
ga_concat_len(&msg_ext_last_chunk, (char *)str,
- strnlen((char *)str, maxlen));
+ strnlen((char *)str, maxlen)); // -V781
return;
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 269c4d43ca..be643a6062 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1442,15 +1442,13 @@ static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname,
}
if (module == NULL || *module == NUL) {
qfp->qf_module = NULL;
- } else if ((qfp->qf_module = vim_strsave(module)) == NULL) {
- xfree(qfp->qf_text);
- xfree(qfp->qf_pattern);
- xfree(qfp);
- return QF_FAIL;
+ } else {
+ qfp->qf_module = vim_strsave(module);
}
qfp->qf_nr = nr;
- if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
+ if (type != 1 && !vim_isprintc(type)) { // only printable chars allowed
type = 0;
+ }
qfp->qf_type = (char_u)type;
qfp->qf_valid = valid;
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 67ac16ea0e..4d0e5b0b1b 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -2867,78 +2867,66 @@ int get_tags(list_T *list, char_u *pat, char_u *buf_fname)
// Return information about 'tag' in dict 'retdict'.
static void get_tag_details(taggy_T *tag, dict_T *retdict)
{
- list_T *pos;
- fmark_T *fmark;
-
- tv_dict_add_str(retdict, S_LEN("tagname"), (const char *)tag->tagname);
- tv_dict_add_nr(retdict, S_LEN("matchnr"), tag->cur_match + 1);
- tv_dict_add_nr(retdict, S_LEN("bufnr"), tag->cur_fnum);
-
- if ((pos = tv_list_alloc(4)) == NULL) {
- return;
- }
- tv_dict_add_list(retdict, S_LEN("from"), pos);
-
- fmark = &tag->fmark;
- tv_list_append_number(pos,
- (varnumber_T)(fmark->fnum != -1 ? fmark->fnum : 0));
- tv_list_append_number(pos, (varnumber_T)fmark->mark.lnum);
- tv_list_append_number(pos, (varnumber_T)(fmark->mark.col == MAXCOL ?
- MAXCOL : fmark->mark.col + 1));
- tv_list_append_number(pos, (varnumber_T)fmark->mark.coladd);
+ list_T *pos;
+ fmark_T *fmark;
+
+ tv_dict_add_str(retdict, S_LEN("tagname"), (const char *)tag->tagname);
+ tv_dict_add_nr(retdict, S_LEN("matchnr"), tag->cur_match + 1);
+ tv_dict_add_nr(retdict, S_LEN("bufnr"), tag->cur_fnum);
+
+ pos = tv_list_alloc(4);
+ tv_dict_add_list(retdict, S_LEN("from"), pos);
+
+ fmark = &tag->fmark;
+ tv_list_append_number(pos,
+ (varnumber_T)(fmark->fnum != -1 ? fmark->fnum : 0));
+ tv_list_append_number(pos, (varnumber_T)fmark->mark.lnum);
+ tv_list_append_number(pos, (varnumber_T)(fmark->mark.col == MAXCOL
+ ? MAXCOL : fmark->mark.col + 1));
+ tv_list_append_number(pos, (varnumber_T)fmark->mark.coladd);
}
// Return the tag stack entries of the specified window 'wp' in dictionary
// 'retdict'.
void get_tagstack(win_T *wp, dict_T *retdict)
{
- list_T *l;
- int i;
- dict_T *d;
-
- tv_dict_add_nr(retdict, S_LEN("length"), wp->w_tagstacklen);
- tv_dict_add_nr(retdict, S_LEN("curidx"), wp->w_tagstackidx + 1);
- l = tv_list_alloc(2);
- if (l == NULL) {
- return;
- }
- tv_dict_add_list(retdict, S_LEN("items"), l);
+ list_T *l;
+ int i;
+ dict_T *d;
- for (i = 0; i < wp->w_tagstacklen; i++) {
- if ((d = tv_dict_alloc()) == NULL) {
- return;
- }
- tv_list_append_dict(l, d);
+ tv_dict_add_nr(retdict, S_LEN("length"), wp->w_tagstacklen);
+ tv_dict_add_nr(retdict, S_LEN("curidx"), wp->w_tagstackidx + 1);
+ l = tv_list_alloc(2);
+ tv_dict_add_list(retdict, S_LEN("items"), l);
- get_tag_details(&wp->w_tagstack[i], d);
- }
+ for (i = 0; i < wp->w_tagstacklen; i++) {
+ d = tv_dict_alloc();
+ tv_list_append_dict(l, d);
+ get_tag_details(&wp->w_tagstack[i], d);
+ }
}
// Free all the entries in the tag stack of the specified window
static void tagstack_clear(win_T *wp)
{
- int i;
-
- // Free the current tag stack
- for (i = 0; i < wp->w_tagstacklen; i++) {
- xfree(wp->w_tagstack[i].tagname);
- }
- wp->w_tagstacklen = 0;
- wp->w_tagstackidx = 0;
+ // Free the current tag stack
+ for (int i = 0; i < wp->w_tagstacklen; i++) {
+ xfree(wp->w_tagstack[i].tagname);
+ }
+ wp->w_tagstacklen = 0;
+ wp->w_tagstackidx = 0;
}
// Remove the oldest entry from the tag stack and shift the rest of
// the entires to free up the top of the stack.
static void tagstack_shift(win_T *wp)
{
- taggy_T *tagstack = wp->w_tagstack;
- int i;
-
- xfree(tagstack[0].tagname);
- for (i = 1; i < wp->w_tagstacklen; i++) {
- tagstack[i - 1] = tagstack[i];
- }
- wp->w_tagstacklen--;
+ taggy_T *tagstack = wp->w_tagstack;
+ xfree(tagstack[0].tagname);
+ for (int i = 1; i < wp->w_tagstacklen; i++) {
+ tagstack[i - 1] = tagstack[i];
+ }
+ wp->w_tagstacklen--;
}
// Push a new item to the tag stack
@@ -2950,102 +2938,102 @@ static void tagstack_push_item(
pos_T mark,
int fnum)
{
- taggy_T *tagstack = wp->w_tagstack;
- int idx = wp->w_tagstacklen; // top of the stack
+ taggy_T *tagstack = wp->w_tagstack;
+ int idx = wp->w_tagstacklen; // top of the stack
- // if the tagstack is full: remove the oldest entry
- if (idx >= TAGSTACKSIZE) {
- tagstack_shift(wp);
- idx = TAGSTACKSIZE - 1;
- }
+ // if the tagstack is full: remove the oldest entry
+ if (idx >= TAGSTACKSIZE) {
+ tagstack_shift(wp);
+ idx = TAGSTACKSIZE - 1;
+ }
- wp->w_tagstacklen++;
- tagstack[idx].tagname = tagname;
- tagstack[idx].cur_fnum = cur_fnum;
- tagstack[idx].cur_match = cur_match;
- if (tagstack[idx].cur_match < 0) {
- tagstack[idx].cur_match = 0;
- }
- tagstack[idx].fmark.mark = mark;
- tagstack[idx].fmark.fnum = fnum;
+ wp->w_tagstacklen++;
+ tagstack[idx].tagname = tagname;
+ tagstack[idx].cur_fnum = cur_fnum;
+ tagstack[idx].cur_match = cur_match;
+ if (tagstack[idx].cur_match < 0) {
+ tagstack[idx].cur_match = 0;
+ }
+ tagstack[idx].fmark.mark = mark;
+ tagstack[idx].fmark.fnum = fnum;
}
// Add a list of items to the tag stack in the specified window
static void tagstack_push_items(win_T *wp, list_T *l)
{
- listitem_T *li;
- dictitem_T *di;
- dict_T *itemdict;
- char_u *tagname;
- pos_T mark;
- int fnum;
-
- // Add one entry at a time to the tag stack
- for (li = tv_list_first(l); li != NULL; li = TV_LIST_ITEM_NEXT(l, li)) {
- if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT
- || TV_LIST_ITEM_TV(li)->vval.v_dict == NULL) {
- continue; // Skip non-dict items
- }
- itemdict = TV_LIST_ITEM_TV(li)->vval.v_dict;
+ listitem_T *li;
+ dictitem_T *di;
+ dict_T *itemdict;
+ char_u *tagname;
+ pos_T mark;
+ int fnum;
+
+ // Add one entry at a time to the tag stack
+ for (li = tv_list_first(l); li != NULL; li = TV_LIST_ITEM_NEXT(l, li)) {
+ if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT
+ || TV_LIST_ITEM_TV(li)->vval.v_dict == NULL) {
+ continue; // Skip non-dict items
+ }
+ itemdict = TV_LIST_ITEM_TV(li)->vval.v_dict;
- // parse 'from' for the cursor position before the tag jump
- if ((di = tv_dict_find(itemdict, "from", -1)) == NULL) {
- continue;
- }
- if (list2fpos(&di->di_tv, &mark, &fnum, NULL) != OK) {
- continue;
- }
- if ((tagname = (char_u *)
- tv_dict_get_string(itemdict, "tagname", true)) == NULL) {
- continue;
- }
+ // parse 'from' for the cursor position before the tag jump
+ if ((di = tv_dict_find(itemdict, "from", -1)) == NULL) {
+ continue;
+ }
+ if (list2fpos(&di->di_tv, &mark, &fnum, NULL) != OK) {
+ continue;
+ }
+ if ((tagname = (char_u *)tv_dict_get_string(itemdict, "tagname", true))
+ == NULL) {
+ continue;
+ }
- if (mark.col > 0) {
- mark.col--;
- }
- tagstack_push_item(wp, tagname,
- (int)tv_dict_get_number(itemdict, "bufnr"),
- (int)tv_dict_get_number(itemdict, "matchnr") - 1,
- mark, fnum);
+ if (mark.col > 0) {
+ mark.col--;
}
+ tagstack_push_item(wp, tagname,
+ (int)tv_dict_get_number(itemdict, "bufnr"),
+ (int)tv_dict_get_number(itemdict, "matchnr") - 1,
+ mark, fnum);
+ }
}
// Set the current index in the tag stack. Valid values are between 0
// and the stack length (inclusive).
static void tagstack_set_curidx(win_T *wp, int curidx)
{
- wp->w_tagstackidx = curidx;
- if (wp->w_tagstackidx < 0) { // sanity check
- wp->w_tagstackidx = 0;
- }
- if (wp->w_tagstackidx > wp->w_tagstacklen) {
- wp->w_tagstackidx = wp->w_tagstacklen;
- }
+ wp->w_tagstackidx = curidx;
+ if (wp->w_tagstackidx < 0) { // sanity check
+ wp->w_tagstackidx = 0;
+ }
+ if (wp->w_tagstackidx > wp->w_tagstacklen) {
+ wp->w_tagstackidx = wp->w_tagstacklen;
+ }
}
// Set the tag stack entries of the specified window.
// 'action' is set to either 'a' for append or 'r' for replace.
int set_tagstack(win_T *wp, dict_T *d, int action)
{
- dictitem_T *di;
- list_T *l;
-
- if ((di = tv_dict_find(d, "items", -1)) != NULL) {
- if (di->di_tv.v_type != VAR_LIST) {
- return FAIL;
- }
- l = di->di_tv.vval.v_list;
+ dictitem_T *di;
+ list_T *l;
- if (action == 'r') {
- tagstack_clear(wp);
- }
-
- tagstack_push_items(wp, l);
+ if ((di = tv_dict_find(d, "items", -1)) != NULL) {
+ if (di->di_tv.v_type != VAR_LIST) {
+ return FAIL;
}
+ l = di->di_tv.vval.v_list;
- if ((di = tv_dict_find(d, "curidx", -1)) != NULL) {
- tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1);
+ if (action == 'r') {
+ tagstack_clear(wp);
}
- return OK;
+ tagstack_push_items(wp, l);
+ }
+
+ if ((di = tv_dict_find(d, "curidx", -1)) != NULL) {
+ tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1);
+ }
+
+ return OK;
}