From f8ad215d25e6bbaafbb309b9d844209b78eb6d48 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 30 Jan 2016 11:33:20 +0100 Subject: vim-patch:7.4.745 Problem: The entries added by matchaddpos() are returned by getmatches() but can't be set with setmatches(). (Lcd) Solution: Fix setmatches(). (Christian Brabandt) https://github.com/vim/vim/commit/0fce4257727f9d75e488963b73e407d31dd46546 --- src/nvim/eval.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- src/nvim/version.c | 2 +- 2 files changed, 44 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a1c5f958d1..d5dc694f6a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15209,6 +15209,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) list_T *l; listitem_T *li; dict_T *d; + list_T *s = NULL; rettv->vval.v_number = -1; if (argvars[0].v_type != VAR_LIST) { @@ -15227,7 +15228,8 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) return; } if (!(dict_find(d, (char_u *)"group", -1) != NULL - && dict_find(d, (char_u *)"pattern", -1) != NULL + && (dict_find(d, (char_u *)"pattern", -1) != NULL + || dict_find(d, (char_u *)"pos1", -1) != NULL) && dict_find(d, (char_u *)"priority", -1) != NULL && dict_find(d, (char_u *)"id", -1) != NULL)) { EMSG(_(e_invarg)); @@ -15239,11 +15241,47 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) clear_matches(curwin); li = l->lv_first; while (li != NULL) { + int i = 0; + char_u buf[4]; + dictitem_T *di; d = li->li_tv.vval.v_dict; - match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), - get_dict_string(d, (char_u *)"pattern", FALSE), - (int)get_dict_number(d, (char_u *)"priority"), - (int)get_dict_number(d, (char_u *)"id"), NULL); + + if (dict_find(d, (char_u *)"pattern", -1) == NULL) { + if (s == NULL) { + s = list_alloc(); + if (s == NULL) { + return; + } + } + + // match from matchaddpos() + for (i = 1; i < 9; ++i) { + sprintf((char *)buf, (char *)"pos%d", i); + if ((di = dict_find(d, (char_u *)buf, -1)) != NULL) { + if (di->di_tv.v_type != VAR_LIST) { + return; + } + + list_append_tv(s, &di->di_tv); + s->lv_refcount++; + } else { + break; + } + } + } + + if (i == 0) { + match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), + get_dict_string(d, (char_u *)"pattern", FALSE), + (int)get_dict_number(d, (char_u *)"priority"), + (int)get_dict_number(d, (char_u *)"id"), NULL); + } else { + match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), + NULL, (int)get_dict_number(d, (char_u *)"priority"), + (int)get_dict_number(d, (char_u *)"id"), s); + list_unref(s); + s = NULL; + } li = li->li_next; } rettv->vval.v_number = 0; diff --git a/src/nvim/version.c b/src/nvim/version.c index 30f104562f..33aa680ca3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -389,7 +389,7 @@ static int included_patches[] = { // 748, // 747, // 746, - // 745, + 745, // 744 NA // 743, // 742, -- cgit From 73234bfec6f9aa1741b30d19817284cd26392376 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 30 Jan 2016 12:18:36 +0100 Subject: vim-patch:7.4.746 Problem: ":[count]tag" is not always working. (cs86661) Solution: Set cur_match a bit later. (Hirohito Higashi) https://github.com/vim/vim/commit/01cf376da1726862afc8fa1d84cf5a773909fd0d --- src/nvim/tag.c | 22 +++++++++------------- src/nvim/version.c | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index d832924efd..3d2c069530 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -445,17 +445,10 @@ do_tag ( tagmatchname = vim_strsave(name); } - /* - * If a count is supplied to the ":tag " command, then - * jump to count'th matching tag. - */ - if (type == DT_TAG && *tag != NUL && count > 0) - cur_match = count - 1; - - if (type == DT_SELECT || type == DT_JUMP - || type == DT_LTAG - ) + if (type == DT_TAG || type == DT_SELECT || type == DT_JUMP + || type == DT_LTAG) { cur_match = MAXCOL - 1; + } max_num_matches = cur_match + 1; /* when the argument starts with '/', use it as a regexp */ @@ -511,8 +504,11 @@ do_tag ( if (type == DT_CSCOPE && num_matches > 1) { cs_print_tags(); ask_for_selection = TRUE; - } else if (type == DT_SELECT || - (type == DT_JUMP && num_matches > 1)) { + } else if (type == DT_TAG) { + // If a count is supplied to the ":tag " command, then + // jump to count'th matching tag. + cur_match = count > 0 ? count - 1 : 0; + } else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1)) { /* * List all the matching tags. * Assume that the first match indicates how long the tags can @@ -851,7 +847,7 @@ do_tag ( ic = (matches[cur_match][0] & MT_IC_OFF); - if (type != DT_SELECT && type != DT_JUMP + if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP && type != DT_CSCOPE && (num_matches > 1 || ic) && !skip_msg) { diff --git a/src/nvim/version.c b/src/nvim/version.c index 33aa680ca3..bf26497679 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -388,7 +388,7 @@ static int included_patches[] = { // 749, // 748, // 747, - // 746, + 746, 745, // 744 NA // 743, -- cgit From 7179f43666768ac81c0e5a350f57f53c2cc39c3c Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 30 Jan 2016 12:29:49 +0100 Subject: vim-patch:7.4.747 Problem: ":cnext" may jump to the wrong column when setting 'virtualedit=all' (cs86661) Solution: Reset the coladd field. (Hirohito Higashi) https://github.com/vim/vim/commit/b8c890035efd694daab5cdd71b5265c52c23fa81 --- src/nvim/quickfix.c | 1 + src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 85c69af192..78b4312dc6 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1606,6 +1606,7 @@ win_found: } if (qf_ptr->qf_col > 0) { curwin->w_cursor.col = qf_ptr->qf_col - 1; + curwin->w_cursor.coladd = 0; if (qf_ptr->qf_viscol == TRUE) { /* * Check each character from the beginning of the error diff --git a/src/nvim/version.c b/src/nvim/version.c index bf26497679..ed586ad04c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -387,7 +387,7 @@ static int included_patches[] = { // 750 NA // 749, // 748, - // 747, + 747, 746, 745, // 744 NA -- cgit From a984203bd6349a26042998db50b4efc90ae65751 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 30 Jan 2016 14:42:06 +0100 Subject: Fix linter errors. --- src/nvim/eval.c | 8 ++++---- src/nvim/quickfix.c | 12 +++++------- src/nvim/tag.c | 25 +++++++++++-------------- 3 files changed, 20 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d5dc694f6a..87d0ae4d88 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15256,7 +15256,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) // match from matchaddpos() for (i = 1; i < 9; ++i) { - sprintf((char *)buf, (char *)"pos%d", i); + snprintf((char *)buf, sizeof(buf), (char *)"pos%d", i); if ((di = dict_find(d, (char_u *)buf, -1)) != NULL) { if (di->di_tv.v_type != VAR_LIST) { return; @@ -15271,12 +15271,12 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) } if (i == 0) { - match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), - get_dict_string(d, (char_u *)"pattern", FALSE), + match_add(curwin, get_dict_string(d, (char_u *)"group", false), + get_dict_string(d, (char_u *)"pattern", false), (int)get_dict_number(d, (char_u *)"priority"), (int)get_dict_number(d, (char_u *)"id"), NULL); } else { - match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), + match_add(curwin, get_dict_string(d, (char_u *)"group", false), NULL, (int)get_dict_number(d, (char_u *)"priority"), (int)get_dict_number(d, (char_u *)"id"), s); list_unref(s); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 78b4312dc6..f3abf864fb 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1607,13 +1607,11 @@ win_found: if (qf_ptr->qf_col > 0) { curwin->w_cursor.col = qf_ptr->qf_col - 1; curwin->w_cursor.coladd = 0; - if (qf_ptr->qf_viscol == TRUE) { - /* - * Check each character from the beginning of the error - * line up to the error column. For each tab character - * found, reduce the error column value by the length of - * a tab character. - */ + if (qf_ptr->qf_viscol == true) { + // Check each character from the beginning of the error + // line up to the error column. For each tab character + // found, reduce the error column value by the length of + // a tab character. line = get_cursor_line_ptr(); screen_col = 0; for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) { diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 3d2c069530..8fcb02c3b6 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -499,21 +499,19 @@ do_tag ( EMSG2(_("E426: tag not found: %s"), name); g_do_tagpreview = 0; } else { - int ask_for_selection = FALSE; + bool ask_for_selection = false; if (type == DT_CSCOPE && num_matches > 1) { cs_print_tags(); - ask_for_selection = TRUE; + ask_for_selection = true; } else if (type == DT_TAG) { // If a count is supplied to the ":tag " command, then // jump to count'th matching tag. cur_match = count > 0 ? count - 1 : 0; } else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1)) { - /* - * List all the matching tags. - * Assume that the first match indicates how long the tags can - * be, and align the file names to that. - */ + // List all the matching tags. + // Assume that the first match indicates how long the tags can + // be, and align the file names to that. parse_match(matches[0], &tagp); taglen = (int)(tagp.tagname_end - tagp.tagname + 2); if (taglen < 18) @@ -662,9 +660,10 @@ do_tag ( msg_putchar('\n'); os_breakcheck(); } - if (got_int) - got_int = FALSE; /* only stop the listing */ - ask_for_selection = TRUE; + if (got_int) { + got_int = false; // only stop the listing + } + ask_for_selection = true; } else if (type == DT_LTAG) { list_T *list; char_u tag_name[128 + 1]; @@ -797,10 +796,8 @@ do_tag ( cur_match = 0; /* Jump to the first tag */ } - if (ask_for_selection == TRUE) { - /* - * Ask to select a tag from the list. - */ + if (ask_for_selection) { + // Ask to select a tag from the list. i = prompt_for_number(NULL); if (i <= 0 || i > num_matches || got_int) { /* no valid choice: don't change anything */ -- cgit From 515b7e3effcab07f56d3e3ec74bdd2fae600aa10 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 30 Jan 2016 14:42:22 +0100 Subject: vim-patch:7.4.748 Problem: Buffer overflow. Solution: Make the buffer larger. (Kazunobu Kuriyama) https://github.com/vim/vim/commit/6a7e2a668b492b5b574e489790e349a9058e2a48 --- src/nvim/eval.c | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 87d0ae4d88..781f33d484 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15242,7 +15242,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) li = l->lv_first; while (li != NULL) { int i = 0; - char_u buf[4]; + char_u buf[5]; dictitem_T *di; d = li->li_tv.vval.v_dict; diff --git a/src/nvim/version.c b/src/nvim/version.c index ed586ad04c..0fe438791e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -386,7 +386,7 @@ static int included_patches[] = { // 751 NA // 750 NA // 749, - // 748, + 748, 747, 746, 745, -- cgit