From 88e906d165b5dd57fb13b190ec9cb2d67bc6b223 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 26 Jan 2023 08:52:21 +0800 Subject: vim-patch:9.0.1245: code is indented more than necessary (#21998) Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11879) https://github.com/vim/vim/commit/032713f8299abd92fcfb1e490d1ae5c1ecadde41 Co-authored-by: Yegappan Lakshmanan --- src/nvim/tag.c | 228 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 116 insertions(+), 112 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 197184c181..42618e8924 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2732,55 +2732,57 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) tagp->tagline = 0; tagp->command_end = NULL; - if (retval == OK) { - // Try to find a kind field: "kind:" or just "" - p = tagp->command; - if (find_extra(&p) == OK) { - tagp->command_end = p; - if (p > tagp->command && p[-1] == '|') { - tagp->command_end = p - 1; // drop trailing bar - } - p += 2; // skip ";\"" - if (*p++ == TAB) { - // Accept ASCII alphabetic kind characters and any multi-byte - // character. - while (ASCII_ISALPHA(*p) || utfc_ptr2len(p) > 1) { - if (strncmp(p, "kind:", 5) == 0) { - tagp->tagkind = p + 5; - } else if (strncmp(p, "user_data:", 10) == 0) { - tagp->user_data = p + 10; - } else if (strncmp(p, "line:", 5) == 0) { - tagp->tagline = atoi(p + 5); - } - if (tagp->tagkind != NULL && tagp->user_data != NULL) { - break; - } + if (retval != OK) { + return retval; + } - pc = vim_strchr(p, ':'); - pt = vim_strchr(p, '\t'); - if (pc == NULL || (pt != NULL && pc > pt)) { - tagp->tagkind = p; - } - if (pt == NULL) { - break; - } - p = pt; - MB_PTR_ADV(p); + // Try to find a kind field: "kind:" or just "" + p = tagp->command; + if (find_extra(&p) == OK) { + tagp->command_end = p; + if (p > tagp->command && p[-1] == '|') { + tagp->command_end = p - 1; // drop trailing bar + } + p += 2; // skip ";\"" + if (*p++ == TAB) { + // Accept ASCII alphabetic kind characters and any multi-byte + // character. + while (ASCII_ISALPHA(*p) || utfc_ptr2len(p) > 1) { + if (strncmp(p, "kind:", 5) == 0) { + tagp->tagkind = p + 5; + } else if (strncmp(p, "user_data:", 10) == 0) { + tagp->user_data = p + 10; + } else if (strncmp(p, "line:", 5) == 0) { + tagp->tagline = atoi(p + 5); } + if (tagp->tagkind != NULL && tagp->user_data != NULL) { + break; + } + + pc = vim_strchr(p, ':'); + pt = vim_strchr(p, '\t'); + if (pc == NULL || (pt != NULL && pc > pt)) { + tagp->tagkind = p; + } + if (pt == NULL) { + break; + } + p = pt; + MB_PTR_ADV(p); } } - if (tagp->tagkind != NULL) { - for (p = tagp->tagkind; - *p && *p != '\t' && *p != '\r' && *p != '\n'; - MB_PTR_ADV(p)) {} - tagp->tagkind_end = p; - } - if (tagp->user_data != NULL) { - for (p = tagp->user_data; - *p && *p != '\t' && *p != '\r' && *p != '\n'; - MB_PTR_ADV(p)) {} - tagp->user_data_end = p; - } + } + if (tagp->tagkind != NULL) { + for (p = tagp->tagkind; + *p && *p != '\t' && *p != '\r' && *p != '\n'; + MB_PTR_ADV(p)) {} + tagp->tagkind_end = p; + } + if (tagp->user_data != NULL) { + for (p = tagp->user_data; + *p && *p != '\t' && *p != '\r' && *p != '\n'; + MB_PTR_ADV(p)) {} + tagp->user_data_end = p; } return retval; } @@ -3329,86 +3331,88 @@ int get_tags(list_T *list, char *pat, char *buf_fname) ret = find_tags(pat, &num_matches, &matches, TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname); - if (ret == OK && num_matches > 0) { - for (i = 0; i < num_matches; i++) { - int parse_result = parse_match(matches[i], &tp); + if (ret != OK || num_matches <= 0) { + return ret; + } - // Avoid an unused variable warning in release builds. - (void)parse_result; - assert(parse_result == OK); + for (i = 0; i < num_matches; i++) { + int parse_result = parse_match(matches[i], &tp); - is_static = test_for_static(&tp); + // Avoid an unused variable warning in release builds. + (void)parse_result; + assert(parse_result == OK); - // Skip pseudo-tag lines. - if (strncmp(tp.tagname, "!_TAG_", 6) == 0) { - xfree(matches[i]); - continue; - } + is_static = test_for_static(&tp); + + // Skip pseudo-tag lines. + if (strncmp(tp.tagname, "!_TAG_", 6) == 0) { + xfree(matches[i]); + continue; + } - dict = tv_dict_alloc(); - tv_list_append_dict(list, dict); - - full_fname = tag_full_fname(&tp); - if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL - || add_tag_field(dict, "filename", full_fname, NULL) == FAIL - || add_tag_field(dict, "cmd", tp.command, tp.command_end) == FAIL - || add_tag_field(dict, "kind", tp.tagkind, - tp.tagkind ? tp.tagkind_end : NULL) == FAIL - || tv_dict_add_nr(dict, S_LEN("static"), is_static) == FAIL) { - ret = FAIL; - } - - xfree(full_fname); - - if (tp.command_end != NULL) { - for (char *p = tp.command_end + 3; - *p != NUL && *p != '\n' && *p != '\r'; - MB_PTR_ADV(p)) { - if (p == tp.tagkind - || (p + 5 == tp.tagkind && strncmp(p, "kind:", 5) == 0)) { - // skip "kind:" and "" - p = tp.tagkind_end - 1; - } else if (strncmp(p, "file:", 5) == 0) { - // skip "file:" (static tag) - p += 4; - } else if (!ascii_iswhite(*p)) { - char *s, *n; - int len; - - // Add extra field as a dict entry. Fields are - // separated by Tabs. - n = p; - while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') { + dict = tv_dict_alloc(); + tv_list_append_dict(list, dict); + + full_fname = tag_full_fname(&tp); + if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL + || add_tag_field(dict, "filename", full_fname, NULL) == FAIL + || add_tag_field(dict, "cmd", tp.command, tp.command_end) == FAIL + || add_tag_field(dict, "kind", tp.tagkind, + tp.tagkind ? tp.tagkind_end : NULL) == FAIL + || tv_dict_add_nr(dict, S_LEN("static"), is_static) == FAIL) { + ret = FAIL; + } + + xfree(full_fname); + + if (tp.command_end != NULL) { + for (char *p = tp.command_end + 3; + *p != NUL && *p != '\n' && *p != '\r'; + MB_PTR_ADV(p)) { + if (p == tp.tagkind + || (p + 5 == tp.tagkind && strncmp(p, "kind:", 5) == 0)) { + // skip "kind:" and "" + p = tp.tagkind_end - 1; + } else if (strncmp(p, "file:", 5) == 0) { + // skip "file:" (static tag) + p += 4; + } else if (!ascii_iswhite(*p)) { + char *s, *n; + int len; + + // Add extra field as a dict entry. Fields are + // separated by Tabs. + n = p; + while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') { + p++; + } + len = (int)(p - n); + if (*p == ':' && len > 0) { + s = ++p; + while (*p != NUL && (uint8_t)(*p) >= ' ') { p++; } - len = (int)(p - n); - if (*p == ':' && len > 0) { - s = ++p; - while (*p != NUL && (uint8_t)(*p) >= ' ') { - p++; - } - n[len] = NUL; - if (add_tag_field(dict, n, s, p) == FAIL) { - ret = FAIL; - } - n[len] = ':'; - } else { - // Skip field without colon. - while (*p != NUL && (uint8_t)(*p) >= ' ') { - p++; - } + n[len] = NUL; + if (add_tag_field(dict, n, s, p) == FAIL) { + ret = FAIL; } - if (*p == NUL) { - break; + n[len] = ':'; + } else { + // Skip field without colon. + while (*p != NUL && (uint8_t)(*p) >= ' ') { + p++; } } + if (*p == NUL) { + break; + } } } - - xfree(matches[i]); } - xfree(matches); + + xfree(matches[i]); } + xfree(matches); return ret; } -- cgit From 27177e581902967dcf4f2f426464da1b636ca420 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:14:24 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22211) --- src/nvim/tag.c | 49 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 42618e8924..4fecbeebc3 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -979,27 +979,22 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char /// window. static int add_llist_tags(char *tag, int num_matches, char **matches) { - list_T *list; char tag_name[128 + 1]; - char *fname; - char *cmd; int i; char *p; tagptrs_T tagp; - fname = xmalloc(MAXPATHL + 1); - cmd = xmalloc(CMDBUFFSIZE + 1); - list = tv_list_alloc(0); + char *fname = xmalloc(MAXPATHL + 1); + char *cmd = xmalloc(CMDBUFFSIZE + 1); + list_T *list = tv_list_alloc(0); for (i = 0; i < num_matches; i++) { - int len, cmd_len; - long lnum; dict_T *dict; parse_match(matches[i], &tagp); // Save the tag name - len = (int)(tagp.tagname_end - tagp.tagname); + int len = (int)(tagp.tagname_end - tagp.tagname); if (len > 128) { len = 128; } @@ -1016,7 +1011,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) // Get the line number or the search pattern used to locate // the tag. - lnum = 0; + long lnum = 0; if (isdigit((uint8_t)(*tagp.command))) { // Line number is used to locate the tag lnum = atol(tagp.command); @@ -1065,7 +1060,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) STRCAT(cmd, "\\V"); len += 2; - cmd_len = (int)(cmd_end - cmd_start + 1); + int cmd_len = (int)(cmd_end - cmd_start + 1); if (cmd_len > (CMDBUFFSIZE - 5)) { cmd_len = CMDBUFFSIZE - 5; } @@ -1162,10 +1157,8 @@ void do_tags(exarg_T *eap) // Make sure case is folded to uppercase in comparison (like for 'sort -f') static int tag_strnicmp(char *s1, char *s2, size_t len) { - int i; - while (len > 0) { - i = TOUPPER_ASC((uint8_t)(*s1)) - TOUPPER_ASC((uint8_t)(*s2)); + int i = TOUPPER_ASC((uint8_t)(*s1)) - TOUPPER_ASC((uint8_t)(*s2)); if (i != 0) { return i; // this character different } @@ -1733,14 +1726,13 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta tagsearch_info_T *sinfo_p) { int status; - int i; - int cmplen; - int tagcmp; // Figure out where the different strings are in this line. // For "normal" tags: Do a quick check if the tag matches. // This speeds up tag searching a lot! if (st->orgpat->headlen) { + int i; + int tagcmp; CLEAR_FIELD(*tagpp); tagpp->tagname = st->lbuf; tagpp->tagname_end = vim_strchr(st->lbuf, TAB); @@ -1751,7 +1743,7 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta // Skip this line if the length of the tag is different and // there is no regexp, or the tag is too short. - cmplen = (int)(tagpp->tagname_end - tagpp->tagname); + int cmplen = (int)(tagpp->tagname_end - tagpp->tagname); if (p_tl != 0 && cmplen > p_tl) { // adjust for 'taglength' cmplen = (int)p_tl; } @@ -2719,7 +2711,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) { int retval; char *p; - char *pc, *pt; + char *pt; tagp->tag_fname = lbuf + 1; lbuf += strlen(tagp->tag_fname) + 2; @@ -2739,6 +2731,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) // Try to find a kind field: "kind:" or just "" p = tagp->command; if (find_extra(&p) == OK) { + char *pc; tagp->command_end = p; if (p > tagp->command && p[-1] == '|') { tagp->command_end = p - 1; // drop trailing bar @@ -2995,7 +2988,6 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) retval = OK; } else { int found = 1; - char cc; // try again, ignore case now p_ic = true; @@ -3004,7 +2996,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) // Failed to find pattern, take a guess: "^func (" found = 2; (void)test_for_static(&tagp); - cc = *tagp.tagname_end; + char cc = *tagp.tagname_end; *tagp.tagname_end = NUL; snprintf(pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname); if (!do_search(NULL, '/', '/', pbuf, (long)1, search_options, NULL)) { @@ -3155,10 +3147,10 @@ static char *expand_tag_fname(char *fname, char *const tag_fname, const bool exp /// file. static int test_for_current(char *fname, char *fname_end, char *tag_fname, char *buf_ffname) { - char c; int retval = false; if (buf_ffname != NULL) { // if the buffer has a name + char c; { c = *fname_end; *fname_end = NUL; @@ -3225,7 +3217,6 @@ static void tagstack_clear_entry(taggy_T *item) /// @param tagnames expand tag names int expand_tags(int tagnames, char *pat, int *num_file, char ***file) { - int i; int extra_flag; char *name_buf; size_t name_buf_size = 100; @@ -3251,7 +3242,7 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file) if (ret == OK && !tagnames) { // Reorganize the tags for display and matching as strings of: // "\0\0\0" - for (i = 0; i < *num_file; i++) { + for (int i = 0; i < *num_file; i++) { size_t len; parse_match((*file)[i], &t_p); @@ -3327,7 +3318,6 @@ int get_tags(list_T *list, char *pat, char *buf_fname) char *full_fname; dict_T *dict; tagptrs_T tp; - bool is_static; ret = find_tags(pat, &num_matches, &matches, TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname); @@ -3342,7 +3332,7 @@ int get_tags(list_T *list, char *pat, char *buf_fname) (void)parse_result; assert(parse_result == OK); - is_static = test_for_static(&tp); + bool is_static = test_for_static(&tp); // Skip pseudo-tag lines. if (strncmp(tp.tagname, "!_TAG_", 6) == 0) { @@ -3377,7 +3367,7 @@ int get_tags(list_T *list, char *pat, char *buf_fname) // skip "file:" (static tag) p += 4; } else if (!ascii_iswhite(*p)) { - char *s, *n; + char *n; int len; // Add extra field as a dict entry. Fields are @@ -3388,7 +3378,7 @@ int get_tags(list_T *list, char *pat, char *buf_fname) } len = (int)(p - n); if (*p == ':' && len > 0) { - s = ++p; + char *s = ++p; while (*p != NUL && (uint8_t)(*p) >= ' ') { p++; } @@ -3447,7 +3437,6 @@ 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); @@ -3455,7 +3444,7 @@ void get_tagstack(win_T *wp, dict_T *retdict) tv_dict_add_list(retdict, S_LEN("items"), l); for (i = 0; i < wp->w_tagstacklen; i++) { - d = tv_dict_alloc(); + dict_T *d = tv_dict_alloc(); tv_list_append_dict(l, d); get_tag_details(&wp->w_tagstack[i], d); } -- cgit From 5f72ab77bff1f1224be5cbbf9423bdddbc25635c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:48:49 +0100 Subject: refactor: reduce scope of locals as per the style guide 3 (#22221) refactor: reduce scope of locals as per the style guide --- src/nvim/tag.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 4fecbeebc3..774157831d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -795,7 +795,6 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char { taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; - int i; char *p; char *command_end; tagptrs_T tagp; @@ -821,7 +820,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char taglen_advance(taglen); msg_puts_attr(_("file\n"), HL_ATTR(HLF_T)); - for (i = 0; i < num_matches && !got_int; i++) { + for (int i = 0; i < num_matches && !got_int; i++) { parse_match(matches[i], &tagp); if (!new_tag && ( (g_do_tagpreview != 0 @@ -980,7 +979,6 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char static int add_llist_tags(char *tag, int num_matches, char **matches) { char tag_name[128 + 1]; - int i; char *p; tagptrs_T tagp; @@ -988,7 +986,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) char *cmd = xmalloc(CMDBUFFSIZE + 1); list_T *list = tv_list_alloc(0); - for (i = 0; i < num_matches; i++) { + for (int i = 0; i < num_matches; i++) { dict_T *dict; parse_match(matches[i], &tagp); @@ -1119,7 +1117,6 @@ static void taglen_advance(int l) // Print the tag stack void do_tags(exarg_T *eap) { - int i; char *name; taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; @@ -1127,7 +1124,7 @@ void do_tags(exarg_T *eap) // Highlight title msg_puts_title(_("\n # TO tag FROM line in file/text")); - for (i = 0; i < tagstacklen; i++) { + for (int i = 0; i < tagstacklen; i++) { if (tagstack[i].tagname != NULL) { name = fm_getname(&(tagstack[i].fmark), 30); if (name == NULL) { // file name not available @@ -1731,8 +1728,6 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta // For "normal" tags: Do a quick check if the tag matches. // This speeds up tag searching a lot! if (st->orgpat->headlen) { - int i; - int tagcmp; CLEAR_FIELD(*tagpp); tagpp->tagname = st->lbuf; tagpp->tagname_end = vim_strchr(st->lbuf, TAB); @@ -1754,8 +1749,9 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta } if (st->state == TS_BINARY) { + int tagcmp; // Simplistic check for unsorted tags file. - i = (int)tagpp->tagname[0]; + int i = (int)tagpp->tagname[0]; if (margs->sortic) { i = TOUPPER_ASC(tagpp->tagname[0]); } @@ -2245,7 +2241,6 @@ static int findtags_copy_matches(findtags_state_T *st, char ***matchesp) const bool name_only = (st->flags & TAG_NAMES); char **matches; int mtt; - int i; char *mfp; char *p; @@ -2256,7 +2251,7 @@ static int findtags_copy_matches(findtags_state_T *st, char ***matchesp) } st->match_count = 0; for (mtt = 0; mtt < MT_COUNT; mtt++) { - for (i = 0; i < st->ga_match[mtt].ga_len; i++) { + for (int i = 0; i < st->ga_match[mtt].ga_len; i++) { mfp = ((char **)(st->ga_match[mtt].ga_data))[i]; if (matches == NULL) { xfree(mfp); @@ -2731,7 +2726,6 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) // Try to find a kind field: "kind:" or just "" p = tagp->command; if (find_extra(&p) == OK) { - char *pc; tagp->command_end = p; if (p > tagp->command && p[-1] == '|') { tagp->command_end = p - 1; // drop trailing bar @@ -2752,7 +2746,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) break; } - pc = vim_strchr(p, ':'); + char *pc = vim_strchr(p, ':'); pt = vim_strchr(p, '\t'); if (pc == NULL || (pt != NULL && pc > pt)) { tagp->tagkind = p; @@ -3435,15 +3429,12 @@ static void get_tag_details(taggy_T *tag, dict_T *retdict) // 'retdict'. void get_tagstack(win_T *wp, dict_T *retdict) { - list_T *l; - int i; - 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); + list_T *l = tv_list_alloc(2); tv_dict_add_list(retdict, S_LEN("items"), l); - for (i = 0; i < wp->w_tagstacklen; i++) { + for (int i = 0; i < wp->w_tagstacklen; i++) { dict_T *d = tv_dict_alloc(); tv_list_append_dict(l, d); get_tag_details(&wp->w_tagstack[i], d); -- cgit From 84027f7515b8ee6f818462f105882fc0052783c4 Mon Sep 17 00:00:00 2001 From: koeleck <779769+koeleck@users.noreply.github.com> Date: Sun, 19 Mar 2023 22:32:37 +0100 Subject: fix: invalid buffer size argument to snprintf #22729 Problem: Crash in findtags_add_match with FORTIFY_SOURCE=3. Note: Fedora 38 packages are now built with -D_FORTIFY_SOURCE=3 by default. 1. Compile with overflow protection. 2. nvim --clean 3. :h 4. `*** overflow detected ***: terminated` The additional checks for the stated buffer size and the actual bounds of the buffer do not match. See `___snprintf_chk` in the glibc sources: https://sourceware.org/git/?p=glibc.git;a=blob;f=debug/snprintf_chk.c;h=59577de076c570b81307dd31c8c73e265808cf4c;hb=HEAD#l28 Solution: Fix arithmetic error: The length of the previously written data is now subtracted from the total size of the buffer, instead of added on top. close #22718 --- src/nvim/tag.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 774157831d..852e7e6e7c 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1947,6 +1947,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ const bool name_only = (st->flags & TAG_NAMES); int mtt; size_t len = 0; + size_t mfp_size = 0; bool is_current; // file name matches bool is_static; // current tag line is static char *mfp; @@ -1990,13 +1991,14 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ // The format is {tagname}@{lang}NUL{heuristic}NUL *tagpp->tagname_end = NUL; len = (size_t)(tagpp->tagname_end - tagpp->tagname); - mfp = xmalloc(sizeof(char) + len + 10 + ML_EXTRA + 1); + mfp_size = sizeof(char) + len + 10 + ML_EXTRA + 1; + mfp = xmalloc(mfp_size); p = mfp; STRCPY(p, tagpp->tagname); p[len] = '@'; STRCPY(p + len + 1, st->help_lang); - snprintf(p + len + 1 + ML_EXTRA, strlen(p) + len + 1 + ML_EXTRA, "%06d", + snprintf(p + len + 1 + ML_EXTRA, mfp_size - (len + 1 + ML_EXTRA), "%06d", help_heuristic(tagpp->tagname, margs->match_re ? margs->matchoff : 0, !margs->match_no_ic) + st->help_pri); -- cgit From d5f6176e6dc4b4e12fc5061ca6e87f4af533e46a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Sat, 1 Apr 2023 02:49:51 +0200 Subject: refactor: add const and remove unnecessary casts (#22841) --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 852e7e6e7c..2d9d0de951 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -726,7 +726,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if ((num_matches > prev_num_matches || new_tag) && num_matches > 1) { if (ic) { - msg_attr((const char *)IObuff, HL_ATTR(HLF_W)); + msg_attr(IObuff, HL_ATTR(HLF_W)); } else { msg(IObuff); } -- cgit From 371823d407d7d7519735131bcad4670c62a731a7 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 5 Apr 2023 21:13:53 +0200 Subject: refactor: make error message definitions const message.c functions now take const char * as a format. Error message definitions can be made const. --- src/nvim/tag.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 2d9d0de951..a9ef884214 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -188,11 +188,11 @@ typedef struct { # include "tag.c.generated.h" #endif -static char *bottommsg = N_("E555: at bottom of tag stack"); -static char *topmsg = N_("E556: at top of tag stack"); -static char *recurmsg = N_("E986: cannot modify the tag stack within tagfunc"); -static char *tfu_inv_ret_msg = N_("E987: invalid return value from tagfunc"); -static char e_window_unexpectedly_close_while_searching_for_tags[] +static const char *bottommsg = N_("E555: at bottom of tag stack"); +static const char *topmsg = N_("E556: at top of tag stack"); +static const char *recurmsg = N_("E986: cannot modify the tag stack within tagfunc"); +static const char *tfu_inv_ret_msg = N_("E987: invalid return value from tagfunc"); +static const char e_window_unexpectedly_close_while_searching_for_tags[] = N_("E1299: Window unexpectedly closed while searching for tags"); static char *tagmatchname = NULL; // name of last used tag @@ -210,7 +210,7 @@ static Callback tfu_cb; // 'tagfunc' callback function /// Reads the 'tagfunc' option value and convert that to a callback value. /// Invoked when the 'tagfunc' option is set. The option value can be a name of /// a function (string), or function() or funcref() or a lambda. -void set_tagfunc_option(char **errmsg) +void set_tagfunc_option(const char **errmsg) { callback_free(&tfu_cb); callback_free(&curbuf->b_tfu_cb); -- cgit From 1d2a29f75ba7d094c8e7444c9b249a4a7211c93c Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:39:04 +0200 Subject: refactor: make char * parameters const in message.c Add const to char * parameters in message.c functions and remove some redundant casts. --- src/nvim/tag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a9ef884214..a00112c126 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -795,8 +795,8 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char { taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; - char *p; - char *command_end; + const char *p; + const char *command_end; tagptrs_T tagp; int taglen; int attr; -- cgit From 9408f2dcf7cade2631688300e9b58eed6bc5219a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:40:57 +0200 Subject: refactor: remove redundant const char * casts --- src/nvim/tag.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a00112c126..06532f47c1 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1081,7 +1081,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) tv_list_append_dict(list, dict); tv_dict_add_str(dict, S_LEN("text"), tag_name); - tv_dict_add_str(dict, S_LEN("filename"), (const char *)fname); + tv_dict_add_str(dict, S_LEN("filename"), fname); tv_dict_add_nr(dict, S_LEN("lnum"), lnum); if (lnum == 0) { tv_dict_add_str(dict, S_LEN("pattern"), cmd); @@ -1246,10 +1246,10 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag // create 'info' dict argument dict_T *const d = tv_dict_alloc_lock(VAR_FIXED); if (tag != NULL && tag->user_data != NULL) { - tv_dict_add_str(d, S_LEN("user_data"), (const char *)tag->user_data); + tv_dict_add_str(d, S_LEN("user_data"), tag->user_data); } if (buf_ffname != NULL) { - tv_dict_add_str(d, S_LEN("buf_ffname"), (const char *)buf_ffname); + tv_dict_add_str(d, S_LEN("buf_ffname"), buf_ffname); } d->dv_refcount++; @@ -2067,7 +2067,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ // follow after it. E.g. help tags store the priority // after the NUL. *hash = hash_hash(mfp); - hi = hash_lookup(&st->ht_match[mtt], (const char *)mfp, strlen(mfp), *hash); + hi = hash_lookup(&st->ht_match[mtt], mfp, strlen(mfp), *hash); if (HASHITEM_EMPTY(hi)) { hash_add_item(&st->ht_match[mtt], hi, mfp, *hash); GA_APPEND(char *, &st->ga_match[mtt], mfp); @@ -3408,11 +3408,11 @@ 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_str(retdict, S_LEN("tagname"), 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 (tag->user_data) { - tv_dict_add_str(retdict, S_LEN("user_data"), (const char *)tag->user_data); + tv_dict_add_str(retdict, S_LEN("user_data"), tag->user_data); } pos = tv_list_alloc(4); -- cgit From 04933b1ea968f958d2541dd65fd33ebb503caac3 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:08:16 +0200 Subject: refactor: remove redundant casts --- src/nvim/tag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 06532f47c1..401b43204e 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1303,7 +1303,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag res_kind = NULL; TV_DICT_ITER(TV_LIST_ITEM_TV(li)->vval.v_dict, di, { - const char *dict_key = (char *)di->di_key; + const char *dict_key = di->di_key; typval_T *tv = &di->di_tv; if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) { @@ -1372,7 +1372,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag } TV_DICT_ITER(TV_LIST_ITEM_TV(li)->vval.v_dict, di, { - const char *dict_key = (char *)di->di_key; + const char *dict_key = di->di_key; typval_T *tv = &di->di_tv; if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) { continue; @@ -2530,7 +2530,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf) } tnp->tn_hf_idx++; STRCPY(buf, p_hf); - STRCPY(path_tail((char *)buf), "tags"); + STRCPY(path_tail(buf), "tags"); #ifdef BACKSLASH_IN_FILENAME slash_adjust(buf); #endif -- cgit From 99c1010aa740b76df341a756231e99d0116fc3be Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 13 Apr 2023 13:27:50 +0800 Subject: vim-patch:partial:9.0.0364: clang static analyzer gives warnings (#23059) Problem: Clang static analyzer gives warnings. Solution: Avoid the warnings. (Yegappan Lakshmanan, closes vim/vim#11043) https://github.com/vim/vim/commit/c99e182e1fb54e39540d25d0ccd8dcdde25bb96c Co-authored-by: Yegappan Lakshmanan --- src/nvim/tag.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 401b43204e..cebc7d5d89 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -3322,11 +3322,10 @@ int get_tags(list_T *list, char *pat, char *buf_fname) } for (i = 0; i < num_matches; i++) { - int parse_result = parse_match(matches[i], &tp); - - // Avoid an unused variable warning in release builds. - (void)parse_result; - assert(parse_result == OK); + if (parse_match(matches[i], &tp) == FAIL) { + xfree(matches[i]); + continue; + } bool is_static = test_for_static(&tp); -- cgit From 3b0df1780e2c8526bda5dead18ee7cc45925caba Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:23:44 +0200 Subject: refactor: uncrustify Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`. --- src/nvim/tag.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index cebc7d5d89..19c62e2b0e 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -538,7 +538,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) } // Repeat searching for tags, when a file has not been found. - for (;;) { + while (true) { int other_name; char *name; @@ -1260,9 +1260,9 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag vim_snprintf(flagString, sizeof(flagString), "%s%s%s", - g_tag_at_cursor ? "c": "", - flags & TAG_INS_COMP ? "i": "", - flags & TAG_REGEXP ? "r": ""); + g_tag_at_cursor ? "c" : "", + flags & TAG_INS_COMP ? "i" : "", + flags & TAG_REGEXP ? "r" : ""); save_pos = curwin->w_cursor; result = callback_call(&curbuf->b_tfu_cb, 3, args, &rettv); @@ -2094,7 +2094,7 @@ static void findtags_get_all_tags(findtags_state_T *st, findtags_match_args_T *m CLEAR_FIELD(search_info); // Read and parse the lines in the file one by one - for (;;) { + while (true) { // check for CTRL-C typed, more often when jumping around if (st->state == TS_BINARY || st->state == TS_SKIP_BACK) { line_breakcheck(); @@ -2558,7 +2558,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf) // There are two states: // tnp->tn_did_filefind_init == false: setup for next part in 'tags'. // tnp->tn_did_filefind_init == true: find next file in this part. - for (;;) { + while (true) { if (tnp->tn_did_filefind_init) { fname = vim_findfile(tnp->tn_search_ctx); if (fname != NULL) { @@ -3168,7 +3168,7 @@ static int find_extra(char **pp) char first_char = **pp; // Repeat for addresses separated with ';' - for (;;) { + while (true) { if (ascii_isdigit(*str)) { str = skipdigits(str + 1); } else if (*str == '/' || *str == '?') { -- cgit From ff34c91194f9ab9d02808f2880029c38a4655eb5 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 17 Apr 2023 17:23:47 +0100 Subject: vim-patch:9.0.1330: handling new value of an option has a long "else if" chain Problem: Handling new value of an option has a long "else if" chain. Solution: Use a function pointer. (Yegappan Lakshmanan, closes vim/vim#12015) https://github.com/vim/vim/commit/af93691b53f38784efce0b93fe7644c44a7e382e --- src/nvim/tag.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 19c62e2b0e..2ee1a0335b 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -210,20 +210,23 @@ static Callback tfu_cb; // 'tagfunc' callback function /// Reads the 'tagfunc' option value and convert that to a callback value. /// Invoked when the 'tagfunc' option is set. The option value can be a name of /// a function (string), or function() or funcref() or a lambda. -void set_tagfunc_option(const char **errmsg) +const char *did_set_tagfunc(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; + callback_free(&tfu_cb); - callback_free(&curbuf->b_tfu_cb); + callback_free(&buf->b_tfu_cb); - if (*curbuf->b_p_tfu == NUL) { - return; + if (*buf->b_p_tfu == NUL) { + return NULL; } - if (option_set_callback_func(curbuf->b_p_tfu, &tfu_cb) == FAIL) { - *errmsg = e_invarg; + if (option_set_callback_func(buf->b_p_tfu, &tfu_cb) == FAIL) { + return e_invarg; } - callback_copy(&curbuf->b_tfu_cb, &tfu_cb); + callback_copy(&buf->b_tfu_cb, &tfu_cb); + return NULL; } #if defined(EXITFREE) -- cgit From 88cfb49bee3c9102082c7010acb92244e4ad1348 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 May 2023 07:14:39 +0800 Subject: vim-patch:8.2.4890: inconsistent capitalization in error messages Problem: Inconsistent capitalization in error messages. Solution: Make capitalization consistent. (Doug Kearns) https://github.com/vim/vim/commit/cf030578b26460643dca4a40e7f2e3bc19c749aa Co-authored-by: Bram Moolenaar --- src/nvim/tag.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 2ee1a0335b..ff16a10d8e 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -188,10 +188,18 @@ typedef struct { # include "tag.c.generated.h" #endif -static const char *bottommsg = N_("E555: at bottom of tag stack"); -static const char *topmsg = N_("E556: at top of tag stack"); -static const char *recurmsg = N_("E986: cannot modify the tag stack within tagfunc"); -static const char *tfu_inv_ret_msg = N_("E987: invalid return value from tagfunc"); +static const char e_tag_stack_empty[] + = N_("E73: Tag stack empty"); +static const char e_tag_not_found_str[] + = N_("E426: Tag not found: %s"); +static const char e_at_bottom_of_tag_stack[] + = N_("E555: At bottom of tag stack"); +static const char e_at_top_of_tag_stack[] + = N_("E556: At top of tag stack"); +static const char e_cannot_modify_tag_stack_within_tagfunc[] + = N_("E986: Cannot modify the tag stack within tagfunc"); +static const char e_invalid_return_value_from_tagfunc[] + = N_("E987: Invalid return value from tagfunc"); static const char e_window_unexpectedly_close_while_searching_for_tags[] = N_("E1299: Window unexpectedly closed while searching for tags"); @@ -304,7 +312,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) static int flags; if (tfu_in_use) { - emsg(_(recurmsg)); + emsg(_(e_cannot_modify_tag_stack_within_tagfunc)); return; } @@ -391,14 +399,14 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if (g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : tagstacklen == 0) { // empty stack - emsg(_(e_tagstack)); + emsg(_(e_tag_stack_empty)); goto end_do_tag; } if (type == DT_POP) { // go to older position const bool old_KeyTyped = KeyTyped; if ((tagstackidx -= count) < 0) { - emsg(_(bottommsg)); + emsg(_(e_at_bottom_of_tag_stack)); if (tagstackidx + count == 0) { // We did [num]^T from the bottom of the stack tagstackidx = 0; @@ -408,7 +416,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // way to the bottom now. tagstackidx = 0; } else if (tagstackidx >= tagstacklen) { // count == 0? - emsg(_(topmsg)); + emsg(_(e_at_top_of_tag_stack)); goto end_do_tag; } @@ -457,10 +465,10 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // go to the last one. Don't store the cursor // position. tagstackidx = tagstacklen - 1; - emsg(_(topmsg)); + emsg(_(e_at_top_of_tag_stack)); save_pos = false; } else if (tagstackidx < 0) { // must have been count == 0 - emsg(_(bottommsg)); + emsg(_(e_at_bottom_of_tag_stack)); tagstackidx = 0; goto end_do_tag; } @@ -638,7 +646,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if (num_matches <= 0) { if (verbose) { - semsg(_("E426: tag not found: %s"), name); + semsg(_(e_tag_not_found_str), name); } g_do_tagpreview = 0; } else { @@ -1281,7 +1289,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag } if (rettv.v_type != VAR_LIST || !rettv.vval.v_list) { tv_clear(&rettv); - emsg(_(tfu_inv_ret_msg)); + emsg(_(e_invalid_return_value_from_tagfunc)); return FAIL; } taglist = rettv.vval.v_list; @@ -1295,7 +1303,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag int name_only = flags & TAG_NAMES; if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT) { - emsg(_(tfu_inv_ret_msg)); + emsg(_(e_invalid_return_value_from_tagfunc)); break; } @@ -1341,7 +1349,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag } if (!res_name || !res_fname || !res_cmd) { - emsg(_(tfu_inv_ret_msg)); + emsg(_(e_invalid_return_value_from_tagfunc)); break; } @@ -3560,7 +3568,7 @@ int set_tagstack(win_T *wp, const dict_T *d, int action) // not allowed to alter the tag stack entries from inside tagfunc if (tfu_in_use) { - emsg(_(recurmsg)); + emsg(_(e_cannot_modify_tag_stack_within_tagfunc)); return FAIL; } -- cgit From 189e21ae50efe14d8446db11aee6b50f8022d99f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 May 2023 08:13:33 +0800 Subject: vim-patch:9.0.1554: code for handling 'switchbuf' is repeated (#23632) Problem: Code for handling 'switchbuf' is repeated. Solution: Add a function to handle 'switchbuf'. (Yegappan Lakshmanan, closes vim/vim#12397) https://github.com/vim/vim/commit/e42c27d9e8a18e3786f13f17663914cdd0f63f9e Co-authored-by: Yegappan Lakshmanan --- src/nvim/tag.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index ff16a10d8e..81bca67cf7 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2901,21 +2901,10 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) buf_T *const existing_buf = buflist_findname_exp(fname); if (existing_buf != NULL) { - const win_T *wp = NULL; - - if (swb_flags & SWB_USEOPEN) { - wp = buf_jump_open_win(existing_buf); - } - - // If 'switchbuf' contains "usetab": jump to first window in any tab - // page containing "existing_buf" if one exists - if (wp == NULL && (swb_flags & SWB_USETAB)) { - wp = buf_jump_open_tab(existing_buf); - } - - // We've switched to the buffer, the usual loading of the file must - // be skipped. - if (wp != NULL) { + // If 'switchbuf' is set jump to the window containing "buf". + if (swbuf_goto_win_with_buf(existing_buf) != NULL) { + // We've switched to the buffer, the usual loading of the file + // must be skipped. getfile_result = GETFILE_SAME_FILE; } } -- cgit From d36dd2bae8e899b40cc21603e600a5046213bc36 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Tue, 16 May 2023 05:33:03 +0200 Subject: refactor: use xstrl{cpy,cat} on IObuff (#23648) Replace usage of STR{CPY,CAT} with xstrl{cpy,cat} when using on IObuff Co-authored-by: ii14 --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 81bca67cf7..18331cc95d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -732,7 +732,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) num_matches, max_num_matches != MAXCOL ? _(" or more") : ""); if (ic) { - STRCAT(IObuff, _(" Using tag with different case!")); + xstrlcat(IObuff, _(" Using tag with different case!"), IOSIZE); } if ((num_matches > prev_num_matches || new_tag) && num_matches > 1) { -- cgit From 4229bbe514b7a1bc5b9f888a294cc8a323a7d869 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jun 2023 12:23:11 +0800 Subject: fix(helptags): make multibyte help tags work properly (#23975) --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 18331cc95d..4fe669631f 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1762,7 +1762,7 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta if (st->state == TS_BINARY) { int tagcmp; // Simplistic check for unsorted tags file. - int i = (int)tagpp->tagname[0]; + int i = (uint8_t)tagpp->tagname[0]; if (margs->sortic) { i = TOUPPER_ASC(tagpp->tagname[0]); } -- cgit From fcf3519c65a2d6736de437f686e788684a6c8564 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 17 Apr 2023 22:18:58 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/tag.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 4fe669631f..d1f4903294 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1020,10 +1020,10 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) // Get the line number or the search pattern used to locate // the tag. - long lnum = 0; + linenr_T lnum = 0; if (isdigit((uint8_t)(*tagp.command))) { // Line number is used to locate the tag - lnum = atol(tagp.command); + lnum = atoi(tagp.command); } else { char *cmd_start, *cmd_end; @@ -2979,15 +2979,14 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) // start search before first line curwin->w_cursor.lnum = 0; } - if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, - search_options, NULL)) { + if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, 1, search_options, NULL)) { retval = OK; } else { int found = 1; // try again, ignore case now p_ic = true; - if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, + if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, 1, search_options, NULL)) { // Failed to find pattern, take a guess: "^func (" found = 2; @@ -2995,11 +2994,11 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) char cc = *tagp.tagname_end; *tagp.tagname_end = NUL; snprintf(pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname); - if (!do_search(NULL, '/', '/', pbuf, (long)1, search_options, NULL)) { + if (!do_search(NULL, '/', '/', pbuf, 1, search_options, NULL)) { // Guess again: "^char * \ Date: Thu, 13 Jul 2023 10:17:19 +0100 Subject: perf(rtp): reduce rtp scans (#24191) * perf(rtp): reduce rtp scans Problem: Scanning the filesystem is expensive and particularly affects startuptime. Solution: Reduce the amount of redundant directory scans by relying less on glob patterns and handle vim and lua sourcing lower down. --- src/nvim/tag.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index d1f4903294..8bbfb663bd 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2482,15 +2482,23 @@ static garray_T tag_fnames = GA_EMPTY_INIT_VALUE; // Callback function for finding all "tags" and "tags-??" files in // 'runtimepath' doc directories. -static void found_tagfile_cb(char *fname, void *cookie) +static bool found_tagfile_cb(int num_fnames, char **fnames, bool all, void *cookie) { - char *const tag_fname = xstrdup(fname); + for (int i = 0; i < num_fnames; i++) { + char *const tag_fname = xstrdup(fnames[i]); #ifdef BACKSLASH_IN_FILENAME - slash_adjust(tag_fname); + slash_adjust(tag_fname); #endif - simplify_filename(tag_fname); - GA_APPEND(char *, &tag_fnames, tag_fname); + simplify_filename(tag_fname); + GA_APPEND(char *, &tag_fnames, tag_fname); + + if (!all) { + break; + } + } + + return num_fnames > 0; } #if defined(EXITFREE) -- cgit From f91cd31d7d9d70006e0000592637d5d997eab52c Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 21:46:39 +0200 Subject: refactor(messages): fold msg_outtrans_attr into msg_outtrans problem: there are too many different functions in message.c solution: fold some of the functions into themselves --- src/nvim/tag.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 8bbfb663bd..f74556d45b 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -847,13 +847,10 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char mt_names[matches[i][0] & MT_MASK]); msg_puts(IObuff); if (tagp.tagkind != NULL) { - msg_outtrans_len(tagp.tagkind, - (int)(tagp.tagkind_end - tagp.tagkind)); + msg_outtrans_len(tagp.tagkind, (int)(tagp.tagkind_end - tagp.tagkind), 0); } msg_advance(13); - msg_outtrans_len_attr(tagp.tagname, - (int)(tagp.tagname_end - tagp.tagname), - HL_ATTR(HLF_T)); + msg_outtrans_len(tagp.tagname, (int)(tagp.tagname_end - tagp.tagname), HL_ATTR(HLF_T)); msg_putchar(' '); taglen_advance(taglen); @@ -861,7 +858,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char // it and put "..." in the middle p = tag_full_fname(&tagp); if (p != NULL) { - msg_outtrans_attr(p, HL_ATTR(HLF_D)); + msg_outtrans(p, HL_ATTR(HLF_D)); XFREE_CLEAR(p); } if (msg_col > 0) { @@ -1149,9 +1146,8 @@ void do_tags(exarg_T *eap) tagstack[i].cur_match + 1, tagstack[i].tagname, tagstack[i].fmark.mark.lnum); - msg_outtrans(IObuff); - msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum - ? HL_ATTR(HLF_D) : 0); + msg_outtrans(IObuff, 0); + msg_outtrans(name, tagstack[i].fmark.fnum == curbuf->b_fnum ? HL_ATTR(HLF_D) : 0); xfree(name); } } -- cgit From b85f1dafc7c0a19704135617454f1c66f41202c1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 27 Sep 2023 22:21:17 +0200 Subject: refactor(messages): fold msg_attr into msg problem: there are too many different functions in message.c solution: fold some of the functions into themselves --- src/nvim/tag.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index f74556d45b..c21b3a850b 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -736,11 +736,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) } if ((num_matches > prev_num_matches || new_tag) && num_matches > 1) { - if (ic) { - msg_attr(IObuff, HL_ATTR(HLF_W)); - } else { - msg(IObuff); - } + msg(IObuff, ic ? HL_ATTR(HLF_W) : 0); msg_scroll = true; // Don't overwrite this message. } else { give_warning(IObuff, ic); @@ -3015,7 +3011,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) // Only give a message when really guessed, not when 'ic' // is set and match found while ignoring case. if (found == 2 || !save_p_ic) { - msg(_("E435: Couldn't find tag, just guessing!")); + msg(_("E435: Couldn't find tag, just guessing!"), 0); if (!msg_scrolled && msg_silent == 0) { ui_flush(); os_delay(1010L, true); -- cgit From bc13bc154aa574e0bb58a50f2e0ca4570efa57c3 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 29 Sep 2023 16:10:54 +0200 Subject: refactor(message): smsg_attr -> smsg --- src/nvim/tag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index c21b3a850b..a95b104027 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -719,7 +719,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // Only when going to try the next match, report that the previous // file didn't exist. Otherwise an emsg() is given below. if (nofile_fname != NULL && error_cur_match != cur_match) { - smsg(_("File \"%s\" does not exist"), nofile_fname); + smsg(0, _("File \"%s\" does not exist"), nofile_fname); } ic = (matches[cur_match][0] & MT_IC_OFF); @@ -2211,7 +2211,7 @@ static void findtags_in_file(findtags_state_T *st, int flags, char *buf_ffname) if (p_verbose >= 5) { verbose_enter(); - smsg(_("Searching tags file %s"), st->tag_fname); + smsg(0, _("Searching tags file %s"), st->tag_fname); verbose_leave(); } st->did_open = true; // remember that we found at least one file @@ -3279,7 +3279,7 @@ static int add_tag_field(dict_T *dict, const char *field_name, const char *start if (tv_dict_find(dict, field_name, -1) != NULL) { if (p_verbose > 0) { verbose_enter(); - smsg(_("Duplicate field name: %s"), field_name); + smsg(0, _("Duplicate field name: %s"), field_name); verbose_leave(); } return FAIL; -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/tag.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a95b104027..d3778a343a 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -20,7 +20,6 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- src/nvim/tag.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index d3778a343a..636d16d4e6 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -41,6 +41,8 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_defs.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" -- cgit From 09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 2 Oct 2023 10:45:33 +0800 Subject: refactor: move cmdline completion types to cmdexpand_defs.h (#25465) --- src/nvim/tag.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 636d16d4e6..674d22ba44 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -56,7 +56,6 @@ #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/tag.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/tag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 674d22ba44..1d4c85de49 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -743,7 +743,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) } if (ic && !msg_scrolled && msg_silent == 0) { ui_flush(); - os_delay(1007L, true); + os_delay(1007, true); } } @@ -3014,7 +3014,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) msg(_("E435: Couldn't find tag, just guessing!"), 0); if (!msg_scrolled && msg_silent == 0) { ui_flush(); - os_delay(1010L, true); + os_delay(1010, true); } } retval = OK; -- cgit From cd63a9addd6e1114c3524fa041ece560550cfe7b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 10 Nov 2023 08:39:21 +0800 Subject: refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959) When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer. --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 1d4c85de49..7a175926d2 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -707,7 +707,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) && tagp2.user_data) { XFREE_CLEAR(tagstack[tagstackidx].user_data); tagstack[tagstackidx].user_data = - xstrnsave(tagp2.user_data, (size_t)(tagp2.user_data_end - tagp2.user_data)); + xmemdupz(tagp2.user_data, (size_t)(tagp2.user_data_end - tagp2.user_data)); } tagstackidx++; -- cgit From 8e58d37f2e15ac8540377148e55ed08a039aadb6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 11 Nov 2023 11:20:08 +0100 Subject: refactor: remove redundant casts --- src/nvim/tag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 7a175926d2..a916313982 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1903,13 +1903,13 @@ static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_ if (!match && st->orgpat->regmatch.regprog != NULL) { char cc = *tagpp->tagname_end; *tagpp->tagname_end = NUL; - match = vim_regexec(&st->orgpat->regmatch, tagpp->tagname, (colnr_T)0); + match = vim_regexec(&st->orgpat->regmatch, tagpp->tagname, 0); if (match) { margs->matchoff = (int)(st->orgpat->regmatch.startp[0] - tagpp->tagname); if (st->orgpat->regmatch.rm_ic) { st->orgpat->regmatch.rm_ic = false; margs->match_no_ic = vim_regexec(&st->orgpat->regmatch, - tagpp->tagname, (colnr_T)0); + tagpp->tagname, 0); st->orgpat->regmatch.rm_ic = true; } } @@ -2932,7 +2932,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) if (getfile_result == GETFILE_UNUSED) { // Careful: getfile() may trigger autocommands and call jumpto_tag() // recursively. - getfile_result = getfile(0, fname, NULL, true, (linenr_T)0, forceit); + getfile_result = getfile(0, fname, NULL, true, 0, forceit); } keep_help_flag = false; -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/tag.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a916313982..198a4c51a1 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Code to handle tags and the tag stack #include @@ -340,7 +337,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // Don't add a tag to the tagstack if 'tagstack' has been reset. assert(tag != NULL); - if (!p_tgst && *tag != NUL) { // -V522 + if (!p_tgst && *tag != NUL) { use_tagstack = false; new_tag = true; if (g_do_tagpreview != 0) { @@ -3021,7 +3018,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) } } p_ws = save_p_ws; - p_ic = save_p_ic; // -V519 + p_ic = save_p_ic; p_scs = save_p_scs; // A search command may have positioned the cursor beyond the end -- cgit From ac1113ded5f8f09dd99a9894d7a7e795626fb728 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Nov 2023 23:40:37 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment --- src/nvim/tag.c | 159 ++++++++++++++++++++------------------------------------- 1 file changed, 54 insertions(+), 105 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 198a4c51a1..a3ef7f31b6 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -286,10 +286,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) int cur_fnum = curbuf->b_fnum; int oldtagstackidx = tagstackidx; int prevtagstackidx = tagstackidx; - int prev_num_matches; int new_tag = false; - int i; - int ic; int no_regexp = false; int error_cur_match = 0; int save_pos = false; @@ -328,7 +325,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) use_tfu = 0; } - prev_num_matches = num_matches; + int prev_num_matches = num_matches; free_string_option(nofile_fname); nofile_fname = NULL; @@ -377,7 +374,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if (++tagstacklen > TAGSTACKSIZE) { tagstacklen = TAGSTACKSIZE; tagstack_clear_entry(&tagstack[0]); - for (i = 1; i < tagstacklen; i++) { + for (int i = 1; i < tagstacklen; i++) { tagstack[i - 1] = tagstack[i]; } tagstackidx--; @@ -615,19 +612,18 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // to the start. Avoids that the order changes when using // ":tnext" and jumping to another file. if (!new_tag && !other_name) { - int j, k; int idx = 0; tagptrs_T tagp, tagp2; // Find the position of each old match in the new list. Need // to use parse_match() to find the tag line. - for (j = 0; j < num_matches; j++) { + for (int j = 0; j < num_matches; j++) { parse_match(matches[j], &tagp); - for (i = idx; i < new_num_matches; i++) { + for (int i = idx; i < new_num_matches; i++) { parse_match(new_matches[i], &tagp2); if (strcmp(tagp.tagname, tagp2.tagname) == 0) { char *p = new_matches[i]; - for (k = i; k > idx; k--) { + for (int k = i; k > idx; k--) { new_matches[k] = new_matches[k - 1]; } new_matches[idx++] = p; @@ -666,7 +662,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) if (ask_for_selection) { // Ask to select a tag from the list. - i = prompt_for_number(NULL); + int i = prompt_for_number(NULL); if (i <= 0 || i > num_matches || got_int) { // no valid choice: don't change anything if (use_tagstack) { @@ -719,7 +715,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) smsg(0, _("File \"%s\" does not exist"), nofile_fname); } - ic = (matches[cur_match][0] & MT_IC_OFF); + int ic = (matches[cur_match][0] & MT_IC_OFF); if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP && (num_matches > 1 || ic) && !skip_msg) { @@ -749,7 +745,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1); // Jump to the desired match. - i = jumpto_tag(matches[cur_match], forceit, true); + int i = jumpto_tag(matches[cur_match], forceit, true); set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); @@ -799,16 +795,12 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char { taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; - const char *p; - const char *command_end; tagptrs_T tagp; - int taglen; - int attr; // 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); + int taglen = (int)(tagp.tagname_end - tagp.tagname + 2); if (taglen < 18) { taglen = 18; } @@ -849,7 +841,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char // Find out the actual file name. If it is long, truncate // it and put "..." in the middle - p = tag_full_fname(&tagp); + const char *p = tag_full_fname(&tagp); if (p != NULL) { msg_outtrans(p, HL_ATTR(HLF_D)); XFREE_CLEAR(p); @@ -863,7 +855,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char msg_advance(15); // print any extra fields - command_end = tagp.command_end; + const char *command_end = tagp.command_end; if (command_end != NULL) { p = command_end + 3; while (*p && *p != '\r' && *p != '\n') { @@ -884,7 +876,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char continue; } // print all other extra fields - attr = HL_ATTR(HLF_CM); + int attr = HL_ATTR(HLF_CM); while (*p && *p != '\r' && *p != '\n') { if (msg_col + ptr2cells(p) >= Columns) { msg_putchar('\n'); @@ -980,7 +972,6 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char static int add_llist_tags(char *tag, int num_matches, char **matches) { char tag_name[128 + 1]; - char *p; tagptrs_T tagp; char *fname = xmalloc(MAXPATHL + 1); @@ -1001,7 +992,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) tag_name[len] = NUL; // Save the tag file name - p = tag_full_fname(&tagp); + char *p = tag_full_fname(&tagp); if (p == NULL) { continue; } @@ -1015,13 +1006,11 @@ static int add_llist_tags(char *tag, int num_matches, char **matches) // Line number is used to locate the tag lnum = atoi(tagp.command); } else { - char *cmd_start, *cmd_end; - // Search pattern is used to locate the tag // Locate the end of the command - cmd_start = tagp.command; - cmd_end = tagp.command_end; + char *cmd_start = tagp.command; + char *cmd_end = tagp.command_end; if (cmd_end == NULL) { for (p = tagp.command; *p && *p != '\r' && *p != '\n'; p++) {} @@ -1118,7 +1107,6 @@ static void taglen_advance(int l) // Print the tag stack void do_tags(exarg_T *eap) { - char *name; taggy_T *tagstack = curwin->w_tagstack; int tagstackidx = curwin->w_tagstackidx; int tagstacklen = curwin->w_tagstacklen; @@ -1127,7 +1115,7 @@ void do_tags(exarg_T *eap) msg_puts_title(_("\n # TO tag FROM line in file/text")); for (int i = 0; i < tagstacklen; i++) { if (tagstack[i].tagname != NULL) { - name = fm_getname(&(tagstack[i].fmark), 30); + char *name = fm_getname(&(tagstack[i].fmark), 30); if (name == NULL) { // file name not available continue; } @@ -1217,10 +1205,7 @@ static void prepare_pats(pat_T *pats, int has_re) /// @param buf_ffname name of buffer for priority static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flags, char *buf_ffname) { - pos_T save_pos; - list_T *taglist; int ntags = 0; - int result = FAIL; typval_T args[4]; typval_T rettv; char flagString[4]; @@ -1264,8 +1249,8 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag flags & TAG_INS_COMP ? "i" : "", flags & TAG_REGEXP ? "r" : ""); - save_pos = curwin->w_cursor; - result = callback_call(&curbuf->b_tfu_cb, 3, args, &rettv); + pos_T save_pos = curwin->w_cursor; + int result = callback_call(&curbuf->b_tfu_cb, 3, args, &rettv); curwin->w_cursor = save_pos; // restore the cursor position d->dv_refcount--; @@ -1281,7 +1266,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag emsg(_(e_invalid_return_value_from_tagfunc)); return FAIL; } - taglist = rettv.vval.v_list; + list_T *taglist = rettv.vval.v_list; TV_LIST_ITER_CONST(taglist, li, { char *res_name; @@ -1544,11 +1529,10 @@ static int findtags_apply_tfu(findtags_state_T *st, char *pat, char *buf_ffname) static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch_info_T *sinfo_p) { int eof; - off_T offset; // For binary search: compute the next offset to use. if (st->state == TS_BINARY) { - offset = sinfo_p->low_offset + ((sinfo_p->high_offset - sinfo_p->low_offset) / 2); + off_T offset = sinfo_p->low_offset + ((sinfo_p->high_offset - sinfo_p->low_offset) / 2); if (offset == sinfo_p->curr_offset) { return TAGS_READ_EOF; // End the binary search without a match. } else { @@ -1951,8 +1935,6 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ bool is_current; // file name matches bool is_static; // current tag line is static char *mfp; - char *p; - char *s; // Decide in which array to store this match. is_current = test_for_current(tagpp->fname, tagpp->fname_end, @@ -1994,7 +1976,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ mfp_size = sizeof(char) + len + 10 + ML_EXTRA + 1; mfp = xmalloc(mfp_size); - p = mfp; + char *p = mfp; STRCPY(p, tagpp->tagname); p[len] = '@'; STRCPY(p + len + 1, st->help_lang); @@ -2045,7 +2027,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ // Here is the "mtt" value plus 1 to avoid NUL. len = tag_fname_len + strlen(st->lbuf) + 3; mfp = xmalloc(sizeof(char) + len + 1); - p = mfp; + char *p = mfp; p[0] = (char)(mtt + 1); STRCPY(p + 1, st->tag_fname); #ifdef BACKSLASH_IN_FILENAME @@ -2054,7 +2036,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_ slash_adjust(p + 1); #endif p[tag_fname_len + 1] = TAG_SEP; - s = p + 1 + tag_fname_len + 1; + char *s = p + 1 + tag_fname_len + 1; STRCPY(s, st->lbuf); } @@ -2086,7 +2068,6 @@ static void findtags_get_all_tags(findtags_state_T *st, findtags_match_args_T *m { tagptrs_T tagp; tagsearch_info_T search_info; - int retval; hash_T hash = 0; // This is only to avoid a compiler warning for using search_info @@ -2118,7 +2099,7 @@ static void findtags_get_all_tags(findtags_state_T *st, findtags_match_args_T *m goto line_read_in; } - retval = (int)findtags_get_next_line(st, &search_info); + int retval = (int)findtags_get_next_line(st, &search_info); if (retval == TAGS_READ_IGNORE) { continue; } @@ -2242,9 +2223,6 @@ static int findtags_copy_matches(findtags_state_T *st, char ***matchesp) { const bool name_only = (st->flags & TAG_NAMES); char **matches; - int mtt; - char *mfp; - char *p; if (st->match_count > 0) { matches = xmalloc((size_t)st->match_count * sizeof(char *)); @@ -2252,9 +2230,9 @@ static int findtags_copy_matches(findtags_state_T *st, char ***matchesp) matches = NULL; } st->match_count = 0; - for (mtt = 0; mtt < MT_COUNT; mtt++) { + for (int mtt = 0; mtt < MT_COUNT; mtt++) { for (int i = 0; i < st->ga_match[mtt].ga_len; i++) { - mfp = ((char **)(st->ga_match[mtt].ga_data))[i]; + char *mfp = ((char **)(st->ga_match[mtt].ga_data))[i]; if (matches == NULL) { xfree(mfp); } else { @@ -2263,7 +2241,7 @@ static int findtags_copy_matches(findtags_state_T *st, char ***matchesp) *mfp = (char)(*mfp - 1); // change the TAG_SEP back to NUL - for (p = mfp + 1; *p != NUL; p++) { + for (char *p = mfp + 1; *p != NUL; p++) { if (*p == TAG_SEP) { *p = NUL; } @@ -2319,11 +2297,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc tagname_T tn; // info for get_tagfname() int first_file; // trying first tag file int retval = FAIL; // return value - int round; - - int save_emsg_off; - int help_save; int i; char *saved_pat = NULL; // copy of pat[] @@ -2354,7 +2328,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc abort(); } - help_save = curbuf->b_help; + int help_save = curbuf->b_help; findtags_state_init(&st, pat, flags, mincount); @@ -2379,7 +2353,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc st.orgpat->len = (int)p_tl; } - save_emsg_off = emsg_off; + int save_emsg_off = emsg_off; emsg_off = true; // don't want error for invalid RE here prepare_pats(st.orgpat, has_re); emsg_off = save_emsg_off; @@ -2414,7 +2388,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc // Only ignore case when TAG_NOIC not used or 'ignorecase' set. st.orgpat->regmatch.rm_ic = ((p_ic || !noic) && (findall || st.orgpat->headlen == 0 || !p_tbs)); - for (round = 1; round <= 2; round++) { + for (int round = 1; round <= 2; round++) { st.linear = (st.orgpat->headlen == 0 || !p_tbs || round == 2); // Try tag file names from tags option one by one. @@ -2513,7 +2487,6 @@ void free_tag_stuff(void) int get_tagfname(tagname_T *tnp, int first, char *buf) { char *fname = NULL; - char *r_ptr; if (first) { CLEAR_POINTER(tnp); @@ -2588,7 +2561,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf) buf[0] = NUL; (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,"); - r_ptr = vim_findfile_stopdir(buf); + char *r_ptr = vim_findfile_stopdir(buf); // move the filename one char forward and truncate the // filepath with a NUL filename = path_tail(buf); @@ -2630,11 +2603,9 @@ void tagname_free(tagname_T *tnp) /// @return FAIL if there is a format error in this line, OK otherwise. static int parse_tag_line(char *lbuf, tagptrs_T *tagp) { - char *p; - // Isolate the tagname, from lbuf up to the first white tagp->tagname = lbuf; - p = vim_strchr(lbuf, TAB); + char *p = vim_strchr(lbuf, TAB); if (p == NULL) { return FAIL; } @@ -2677,10 +2648,8 @@ static int parse_tag_line(char *lbuf, tagptrs_T *tagp) // Return false if it is not a static tag. static bool test_for_static(tagptrs_T *tagp) { - char *p; - // Check for new style static tag ":...file:[...]" - p = tagp->command; + char *p = tagp->command; while ((p = vim_strchr(p, '\t')) != NULL) { p++; if (strncmp(p, "file:", 5) == 0) { @@ -2714,15 +2683,11 @@ static size_t matching_line_len(const char *const lbuf) /// @return OK or FAIL. static int parse_match(char *lbuf, tagptrs_T *tagp) { - int retval; - char *p; - char *pt; - tagp->tag_fname = lbuf + 1; lbuf += strlen(tagp->tag_fname) + 2; // Find search pattern and the file name for non-etags. - retval = parse_tag_line(lbuf, tagp); + int retval = parse_tag_line(lbuf, tagp); tagp->tagkind = NULL; tagp->user_data = NULL; @@ -2734,7 +2699,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) } // Try to find a kind field: "kind:" or just "" - p = tagp->command; + char *p = tagp->command; if (find_extra(&p) == OK) { tagp->command_end = p; if (p > tagp->command && p[-1] == '|') { @@ -2757,7 +2722,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) } char *pc = vim_strchr(p, ':'); - pt = vim_strchr(p, '\t'); + char *pt = vim_strchr(p, '\t'); if (pc == NULL || (pt != NULL && pc > pt)) { tagp->tagkind = p; } @@ -2806,14 +2771,8 @@ static char *tag_full_fname(tagptrs_T *tagp) /// @return OK for success, NOTAGFILE when file not found, FAIL otherwise. static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) { - bool save_p_ws; - int save_p_scs, save_p_ic; - linenr_T save_lnum; - char *str; - char *pbuf; // search pattern buffer char *pbuf_end; char *tofree_fname = NULL; - char *fname; tagptrs_T tagp; int retval = FAIL; int getfile_result = GETFILE_UNUSED; @@ -2826,7 +2785,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) char *lbuf = xmalloc(len); memmove(lbuf, lbuf_arg, len); - pbuf = xmalloc(LSIZE); + char *pbuf = xmalloc(LSIZE); // search pattern buffer // parse the match line into the tagp structure if (parse_match(lbuf, &tagp) == FAIL) { @@ -2836,10 +2795,10 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) // truncate the file name, so it can be used as a string *tagp.fname_end = NUL; - fname = tagp.fname; + char *fname = tagp.fname; // copy the command to pbuf[], remove trailing CR/NL - str = tagp.command; + char *str = tagp.command; for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r';) { *pbuf_end++ = *str++; if (pbuf_end - pbuf + 1 >= LSIZE) { @@ -2962,13 +2921,13 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) str = skip_regexp(pbuf + 1, pbuf[0], false) + 1; } if (str > pbuf_end - 1) { // search command with nothing following - save_p_ws = p_ws; - save_p_ic = p_ic; - save_p_scs = p_scs; + bool save_p_ws = p_ws; + int save_p_ic = p_ic; + int save_p_scs = p_scs; p_ws = true; // need 'wrapscan' for backward searches p_ic = false; // don't ignore case now p_scs = false; - save_lnum = curwin->w_cursor.lnum; + linenr_T save_lnum = curwin->w_cursor.lnum; if (tagp.tagline > 0) { // start search before line from "line:" field curwin->w_cursor.lnum = tagp.tagline - 1; @@ -3210,12 +3169,11 @@ static void tagstack_clear_entry(taggy_T *item) int expand_tags(int tagnames, char *pat, int *num_file, char ***file) { int extra_flag; - char *name_buf; size_t name_buf_size = 100; tagptrs_T t_p; int ret; - name_buf = xmalloc(name_buf_size); + char *name_buf = xmalloc(name_buf_size); if (tagnames) { extra_flag = TAG_NAMES; @@ -3270,7 +3228,6 @@ static int add_tag_field(dict_T *dict, const char *field_name, const char *start FUNC_ATTR_NONNULL_ARG(1, 2) { int len = 0; - int retval; // Check that the field name doesn't exist yet. if (tv_dict_find(dict, field_name, -1) != NULL) { @@ -3296,7 +3253,7 @@ static int add_tag_field(dict_T *dict, const char *field_name, const char *start xstrlcpy(buf, start, (size_t)len + 1); } buf[len] = NUL; - retval = tv_dict_add_str(dict, field_name, strlen(field_name), buf); + int retval = tv_dict_add_str(dict, field_name, strlen(field_name), buf); xfree(buf); return retval; } @@ -3305,19 +3262,16 @@ static int add_tag_field(dict_T *dict, const char *field_name, const char *start /// as a dictionary. Use "buf_fname" for priority, unless NULL. int get_tags(list_T *list, char *pat, char *buf_fname) { - int num_matches, i, ret; + int num_matches; char **matches; - char *full_fname; - dict_T *dict; tagptrs_T tp; - ret = find_tags(pat, &num_matches, &matches, - TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname); + int ret = find_tags(pat, &num_matches, &matches, TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname); if (ret != OK || num_matches <= 0) { return ret; } - for (i = 0; i < num_matches; i++) { + for (int i = 0; i < num_matches; i++) { if (parse_match(matches[i], &tp) == FAIL) { xfree(matches[i]); continue; @@ -3331,10 +3285,10 @@ int get_tags(list_T *list, char *pat, char *buf_fname) continue; } - dict = tv_dict_alloc(); + dict_T *dict = tv_dict_alloc(); tv_list_append_dict(list, dict); - full_fname = tag_full_fname(&tp); + char *full_fname = tag_full_fname(&tp); if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL || add_tag_field(dict, "filename", full_fname, NULL) == FAIL || add_tag_field(dict, "cmd", tp.command, tp.command_end) == FAIL @@ -3400,9 +3354,6 @@ int get_tags(list_T *list, char *pat, char *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"), 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); @@ -3410,10 +3361,10 @@ static void get_tag_details(taggy_T *tag, dict_T *retdict) tv_dict_add_str(retdict, S_LEN("user_data"), tag->user_data); } - pos = tv_list_alloc(4); + list_T *pos = tv_list_alloc(4); tv_dict_add_list(retdict, S_LEN("from"), pos); - fmark = &tag->fmark; + fmark_T *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); @@ -3489,20 +3440,18 @@ static void tagstack_push_item(win_T *wp, char *tagname, int cur_fnum, int cur_m /// 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 *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)) { + for (listitem_T *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; + dict_T *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) { -- cgit From a6e3d93421ba13c407a96fac9cc01fa41ec7ad98 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 16 Nov 2023 10:59:11 +0100 Subject: refactor: enable formatting for ternaries This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators. --- src/nvim/tag.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a3ef7f31b6..23443996b0 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -390,8 +390,8 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) new_tag = true; } else { - if (g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : - tagstacklen == 0) { + if (g_do_tagpreview != 0 ? ptag_entry.tagname == NULL + : tagstacklen == 0) { // empty stack emsg(_(e_tag_stack_empty)); goto end_do_tag; @@ -2307,11 +2307,12 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc int verbose = (flags & TAG_VERBOSE); int save_p_ic = p_ic; + // uncrustify:off + // Change the value of 'ignorecase' according to 'tagcase' for the // duration of this function. switch (curbuf->b_tc_flags ? curbuf->b_tc_flags : tc_flags) { - case TC_FOLLOWIC: - break; + case TC_FOLLOWIC: break; case TC_IGNORE: p_ic = true; break; @@ -2328,6 +2329,8 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc abort(); } + // uncrustify:on + int help_save = curbuf->b_help; findtags_state_init(&st, pat, flags, mincount); @@ -3208,7 +3211,7 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file) memmove(name_buf, t_p.tagname, len); name_buf[len++] = 0; name_buf[len++] = (t_p.tagkind != NULL && *t_p.tagkind) - ? *t_p.tagkind : 'f'; + ? *t_p.tagkind : 'f'; name_buf[len++] = 0; memmove((*file)[i] + len, t_p.fname, (size_t)(t_p.fname_end - t_p.fname)); (*file)[i][len + (size_t)(t_p.fname_end - t_p.fname)] = 0; -- cgit From 488038580934f301c1528a14548ec0cabd16c2cd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 14:06:04 +0100 Subject: build: adjust clang-tidy warning exclusion logic Enable all clang-tidy warnings by default instead of disabling them. This ensures that we don't miss useful warnings on each clang-tidy version upgrade. A drawback of this is that it will force us to either fix or adjust the warnings as soon as possible. --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 23443996b0..d750e24898 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1543,7 +1543,7 @@ static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch sinfo_p->curr_offset -= st->lbuf_size * 2; if (sinfo_p->curr_offset < 0) { sinfo_p->curr_offset = 0; - rewind(st->fp); + (void)fseek(st->fp, 0, SEEK_SET); st->state = TS_STEP_FORWARD; } } -- cgit From 38a20dd89f91c45ec8589bf1c50d50732882d38a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 20:58:37 +0800 Subject: build(IWYU): replace most private mappings with pragmas (#26247) --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index d750e24898..90bd2f8fad 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -41,8 +41,8 @@ #include "nvim/option_defs.h" #include "nvim/option_vars.h" #include "nvim/optionstr.h" +#include "nvim/os/fs.h" #include "nvim/os/input.h" -#include "nvim/os/os.h" #include "nvim/os/os_defs.h" #include "nvim/os/time.h" #include "nvim/path.h" -- cgit From 8b428ca8b79ebb7b36c3e403ff3bcb6924a635a6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 16:00:21 +0100 Subject: build(IWYU): fix includes for func_attr.h --- src/nvim/tag.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 90bd2f8fad..67453b40eb 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -23,6 +23,7 @@ #include "nvim/file_search.h" #include "nvim/fileio.h" #include "nvim/fold.h" +#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 67453b40eb..b936ca618f 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -47,7 +47,7 @@ #include "nvim/os/os_defs.h" #include "nvim/os/time.h" #include "nvim/path.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/quickfix.h" #include "nvim/regexp.h" #include "nvim/runtime.h" -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/tag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index b936ca618f..3b6a1bfe85 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -8,7 +8,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" @@ -32,7 +32,7 @@ #include "nvim/highlight_defs.h" #include "nvim/input.h" #include "nvim/insexpand.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -55,7 +55,7 @@ #include "nvim/strings.h" #include "nvim/tag.h" #include "nvim/ui.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" // Structure to hold pointers to various items in a tag line. -- cgit From 64b53b71ba5d804b2c8cf186be68931b2621f53c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 12:10:42 +0800 Subject: refactor(IWYU): create normal_defs.h (#26293) --- src/nvim/tag.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 3b6a1bfe85..f99f0dc612 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -44,7 +44,6 @@ #include "nvim/optionstr.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" -#include "nvim/os/os_defs.h" #include "nvim/os/time.h" #include "nvim/path.h" #include "nvim/pos_defs.h" -- cgit From a6cba103cebce535279db197f9efeb34e9d1171f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 20:32:40 +0800 Subject: refactor: move some constants out of vim_defs.h (#26298) --- src/nvim/tag.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/tag.c') diff --git a/src/nvim/tag.c b/src/nvim/tag.c index f99f0dc612..c6a1a13606 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -29,7 +29,7 @@ #include "nvim/globals.h" #include "nvim/hashtab.h" #include "nvim/help.h" -#include "nvim/highlight_defs.h" +#include "nvim/highlight.h" #include "nvim/input.h" #include "nvim/insexpand.h" #include "nvim/macros_defs.h" @@ -51,6 +51,7 @@ #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/search.h" +#include "nvim/state_defs.h" #include "nvim/strings.h" #include "nvim/tag.h" #include "nvim/ui.h" -- cgit