aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tag.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/tag.c')
-rw-r--r--src/nvim/tag.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index c6a1a13606..ab5bfc6773 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -10,9 +10,12 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/autocmd_defs.h"
#include "nvim/buffer.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
+#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
@@ -23,18 +26,22 @@
#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/garray_defs.h"
+#include "nvim/gettext_defs.h"
#include "nvim/globals.h"
#include "nvim/hashtab.h"
+#include "nvim/hashtab_defs.h"
#include "nvim/help.h"
#include "nvim/highlight.h"
+#include "nvim/highlight_defs.h"
#include "nvim/input.h"
#include "nvim/insexpand.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
+#include "nvim/mark_defs.h"
#include "nvim/mbyte.h"
+#include "nvim/mbyte_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
@@ -44,22 +51,25 @@
#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"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
+#include "nvim/regexp_defs.h"
#include "nvim/runtime.h"
#include "nvim/search.h"
#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
// Structure to hold pointers to various items in a tag line.
-typedef struct tag_pointers {
+typedef struct {
// filled in by parse_tag_line():
char *tagname; // start of tag name (skip "file:")
char *tagname_end; // char after tag name
@@ -207,8 +217,8 @@ static char *tagmatchname = NULL; // name of last used tag
// normal tagstack.
static taggy_T ptag_entry = { NULL, INIT_FMARK, 0, 0, NULL };
-static int tfu_in_use = false; // disallow recursive call of tagfunc
-static Callback tfu_cb; // 'tagfunc' callback function
+static bool tfu_in_use = false; // disallow recursive call of tagfunc
+static Callback tfu_cb; // 'tagfunc' callback function
// Used instead of NUL to separate tag fields in the growarrays.
#define TAG_SEP 0x02
@@ -278,7 +288,7 @@ void set_buflocal_tfu_callback(buf_T *buf)
/// @param tag tag (pattern) to jump to
/// @param forceit :ta with !
/// @param verbose print "tag not found" message
-void do_tag(char *tag, int type, int count, int forceit, int verbose)
+void do_tag(char *tag, int type, int count, int forceit, bool verbose)
{
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
@@ -287,17 +297,17 @@ 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 new_tag = false;
- int no_regexp = false;
+ bool new_tag = false;
+ bool no_regexp = false;
int error_cur_match = 0;
- int save_pos = false;
+ bool save_pos = false;
fmark_T saved_fmark;
int new_num_matches;
char **new_matches;
- int use_tagstack;
- int skip_msg = false;
+ bool use_tagstack;
+ bool skip_msg = false;
char *buf_ffname = curbuf->b_ffname; // name for priority computation
- int use_tfu = 1;
+ bool use_tfu = true;
char *tofree = NULL;
// remember the matches for the last used tag
@@ -323,7 +333,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
if (type == DT_HELP) {
type = DT_TAG;
no_regexp = true;
- use_tfu = 0;
+ use_tfu = false;
}
int prev_num_matches = num_matches;
@@ -378,7 +388,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
for (int i = 1; i < tagstacklen; i++) {
tagstack[i - 1] = tagstack[i];
}
- tagstackidx--;
+ tagstack[--tagstackidx].user_data = NULL;
}
// put the tag name in the tag stack
@@ -545,7 +555,6 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
// Repeat searching for tags, when a file has not been found.
while (true) {
- int other_name;
char *name;
// When desired match not found yet, try to find it (and others).
@@ -559,7 +568,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
} else {
name = tag;
}
- other_name = (tagmatchname == NULL || strcmp(tagmatchname, name) != 0);
+ bool other_name = (tagmatchname == NULL || strcmp(tagmatchname, name) != 0);
if (new_tag
|| (cur_match >= num_matches && max_num_matches != MAXCOL)
|| other_name) {
@@ -716,7 +725,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
smsg(0, _("File \"%s\" does not exist"), nofile_fname);
}
- int ic = (matches[cur_match][0] & MT_IC_OFF);
+ bool ic = (matches[cur_match][0] & MT_IC_OFF);
if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP
&& (num_matches > 1 || ic)
&& !skip_msg) {
@@ -792,7 +801,7 @@ end_do_tag:
}
// List all the matching tags.
-static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char **matches)
+static void print_tag_list(bool new_tag, bool use_tagstack, int num_matches, char **matches)
{
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
@@ -1159,7 +1168,7 @@ static int tag_strnicmp(char *s1, char *s2, size_t len)
}
// Extract info from the tag search pattern "pats->pat".
-static void prepare_pats(pat_T *pats, int has_re)
+static void prepare_pats(pat_T *pats, bool has_re)
{
pats->head = pats->pat;
pats->headlen = pats->len;
@@ -1274,7 +1283,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag
char *res_fname;
char *res_cmd;
char *res_kind;
- int has_extra = 0;
+ bool has_extra = false;
int name_only = flags & TAG_NAMES;
if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT) {
@@ -1309,7 +1318,7 @@ static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flag
res_cmd = tv->vval.v_string;
continue;
}
- has_extra = 1;
+ has_extra = true;
if (!strcmp(dict_key, "kind")) {
res_kind = tv->vval.v_string;
continue;
@@ -1529,7 +1538,7 @@ static int findtags_apply_tfu(findtags_state_T *st, char *pat, char *buf_ffname)
/// reached end of a emacs included tags file)
static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch_info_T *sinfo_p)
{
- int eof;
+ bool eof;
// For binary search: compute the next offset to use.
if (st->state == TS_BINARY) {
@@ -1544,7 +1553,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;
- (void)fseek(st->fp, 0, SEEK_SET);
+ fseek(st->fp, 0, SEEK_SET);
st->state = TS_STEP_FORWARD;
}
}
@@ -2303,7 +2312,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
char *saved_pat = NULL; // copy of pat[]
int findall = (mincount == MAXCOL || mincount == TAG_MANY); // find all matching tags
- int has_re = (flags & TAG_REGEXP); // regexp used
+ bool has_re = (flags & TAG_REGEXP); // regexp used
int noic = (flags & TAG_NOIC);
int verbose = (flags & TAG_VERBOSE);
int save_p_ic = p_ic;
@@ -2563,7 +2572,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
// Copy next file name into buf.
buf[0] = NUL;
- (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
+ copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
char *r_ptr = vim_findfile_stopdir(buf);
// move the filename one char forward and truncate the
@@ -2773,7 +2782,7 @@ static char *tag_full_fname(tagptrs_T *tagp)
/// @param keep_help keep help flag
///
/// @return OK for success, NOTAGFILE when file not found, FAIL otherwise.
-static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
+static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help)
{
char *pbuf_end;
char *tofree_fname = NULL;
@@ -2946,11 +2955,10 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
// try again, ignore case now
p_ic = true;
- if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, 1,
- search_options, NULL)) {
+ if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, 1, search_options, NULL)) {
// Failed to find pattern, take a guess: "^func ("
found = 2;
- (void)test_for_static(&tagp);
+ test_for_static(&tagp);
char cc = *tagp.tagname_end;
*tagp.tagname_end = NUL;
snprintf(pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname);
@@ -3170,7 +3178,7 @@ 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 expand_tags(bool tagnames, char *pat, int *num_file, char ***file)
{
int extra_flag;
size_t name_buf_size = 100;
@@ -3202,10 +3210,8 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
parse_match((*file)[i], &t_p);
len = (size_t)(t_p.tagname_end - t_p.tagname);
if (len > name_buf_size - 3) {
- char *buf;
-
name_buf_size = len + 3;
- buf = xrealloc(name_buf, name_buf_size);
+ char *buf = xrealloc(name_buf, name_buf_size);
name_buf = buf;
}
@@ -3316,12 +3322,11 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
// skip "file:" (static tag)
p += 4;
} else if (!ascii_iswhite(*p)) {
- char *n;
int len;
// Add extra field as a dict entry. Fields are
// separated by Tabs.
- n = p;
+ char *n = p;
while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') {
p++;
}