Mercurial > vim
annotate src/tag.c @ 26877:06a137af96f8 v8.2.3967
patch 8.2.3967: error messages are spread out
Commit: https://github.com/vim/vim/commit/460ae5dfca31fa627531c263184849976755cf6b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 1 14:19:49 2022 +0000
patch 8.2.3967: error messages are spread out
Problem: Error messages are spread out.
Solution: Move more errors to errors.h.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jan 2022 15:30:05 +0100 |
parents | 13ba00ef7687 |
children | d4e61d61afd9 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9949
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle tags and the tag stack | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 /* | |
17 * Structure to hold pointers to various items in a tag line. | |
18 */ | |
19 typedef struct tag_pointers | |
20 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
21 // filled in by parse_tag_line(): |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
22 char_u *tagname; // start of tag name (skip "file:") |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
23 char_u *tagname_end; // char after tag name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
24 char_u *fname; // first char of file name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
25 char_u *fname_end; // char after file name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
26 char_u *command; // first char of command |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
27 // filled in by parse_match(): |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
28 char_u *command_end; // first char after command |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
29 char_u *tag_fname; // file name of the tags file. This is used |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
30 // when 'tr' is set. |
7 | 31 #ifdef FEAT_EMACS_TAGS |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
32 int is_etag; // TRUE for emacs tag |
7 | 33 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
34 char_u *tagkind; // "kind:" value |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
35 char_u *tagkind_end; // end of tagkind |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
36 char_u *user_data; // user_data string |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
37 char_u *user_data_end; // end of user_data |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
38 linenr_T tagline; // "line:" value |
7 | 39 } tagptrs_T; |
40 | |
41 /* | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
42 * The matching tags are first stored in one of the hash tables. In |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
43 * which one depends on the priority of the match. |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
44 * ht_match[] is used to find duplicates, ga_match[] to keep them in sequence. |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
45 * At the end, all the matches from ga_match[] are concatenated, to make a list |
7 | 46 * sorted on priority. |
47 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
48 #define MT_ST_CUR 0 // static match in current file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
49 #define MT_GL_CUR 1 // global match in current file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
50 #define MT_GL_OTH 2 // global match in other file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
51 #define MT_ST_OTH 3 // static match in other file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
52 #define MT_IC_OFF 4 // add for icase match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
53 #define MT_RE_OFF 8 // add for regexp match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
54 #define MT_MASK 7 // mask for printing priority |
7 | 55 #define MT_COUNT 16 |
56 | |
57 static char *mt_names[MT_COUNT/2] = | |
58 {"FSC", "F C", "F ", "FS ", " SC", " C", " ", " S "}; | |
59 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
60 #define NOTAGFILE 99 // return value for jumpto_tag |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
61 static char_u *nofile_fname = NULL; // fname for NOTAGFILE error |
7 | 62 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
63 static void taglen_advance(int l); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
64 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
65 static int jumpto_tag(char_u *lbuf, int forceit, int keep_help); |
7 | 66 #ifdef FEAT_EMACS_TAGS |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
67 static int parse_tag_line(char_u *lbuf, int is_etag, tagptrs_T *tagp); |
7 | 68 #else |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
69 static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp); |
7 | 70 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
71 static int test_for_static(tagptrs_T *); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
72 static int parse_match(char_u *lbuf, tagptrs_T *tagp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
73 static char_u *tag_full_fname(tagptrs_T *tagp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
74 static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand); |
7 | 75 #ifdef FEAT_EMACS_TAGS |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
76 static int test_for_current(int, char_u *, char_u *, char_u *, char_u *); |
7 | 77 #else |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
78 static int test_for_current(char_u *, char_u *, char_u *, char_u *); |
7 | 79 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
80 static int find_extra(char_u **pp); |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
81 static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char_u **matches); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
82 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
83 static int add_llist_tags(char_u *tag, int num_matches, char_u **matches); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
84 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
85 static void tagstack_clear_entry(taggy_T *item); |
7 | 86 |
87 static char_u *bottommsg = (char_u *)N_("E555: at bottom of tag stack"); | |
88 static char_u *topmsg = (char_u *)N_("E556: at top of tag stack"); | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
89 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
90 static char_u *recurmsg = (char_u *)N_("E986: cannot modify the tag stack within tagfunc"); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
91 static char_u *tfu_inv_ret_msg = (char_u *)N_("E987: invalid return value from tagfunc"); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
92 #endif |
7 | 93 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
94 static char_u *tagmatchname = NULL; // name of last used tag |
7 | 95 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
96 #if defined(FEAT_QUICKFIX) |
7 | 97 /* |
98 * Tag for preview window is remembered separately, to avoid messing up the | |
99 * normal tagstack. | |
100 */ | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
101 static taggy_T ptag_entry = {NULL, {{0, 0, 0}, 0}, 0, 0, NULL}; |
7 | 102 #endif |
103 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
104 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
105 static int tfu_in_use = FALSE; // disallow recursive call of tagfunc |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
106 static callback_T tfu_cb; // 'tagfunc' callback function |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
107 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
108 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
109 // Used instead of NUL to separate tag fields in the growarrays. |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
110 #define TAG_SEP 0x02 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
111 |
7 | 112 /* |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
113 * Reads the 'tagfunc' option value and convert that to a callback value. |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
114 * Invoked when the 'tagfunc' option is set. The option value can be a name of |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
115 * a function (string), or function(<name>) or funcref(<name>) or a lambda. |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
116 */ |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
117 int |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
118 set_tagfunc_option(void) |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
119 { |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
120 #ifdef FEAT_EVAL |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
121 free_callback(&tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
122 free_callback(&curbuf->b_tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
123 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
124 if (*curbuf->b_p_tfu == NUL) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
125 return OK; |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
126 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
127 if (option_set_callback_func(curbuf->b_p_tfu, &tfu_cb) == FAIL) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
128 return FAIL; |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
129 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
130 copy_callback(&curbuf->b_tfu_cb, &tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
131 #endif |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
132 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
133 return OK; |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
134 } |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
135 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
136 #if defined(EXITFREE) || defined(PROTO) |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
137 void |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
138 free_tagfunc_option(void) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
139 { |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
140 # ifdef FEAT_EVAL |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
141 free_callback(&tfu_cb); |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
142 # endif |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
143 } |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
144 #endif |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
145 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
146 /* |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
147 * Mark the global 'tagfunc' callback with 'copyID' so that it is not garbage |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
148 * collected. |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
149 */ |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
150 int |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
151 set_ref_in_tagfunc(int copyID UNUSED) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
152 { |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
153 int abort = FALSE; |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
154 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
155 #ifdef FEAT_EVAL |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
156 abort = set_ref_in_callback(&tfu_cb, copyID); |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
157 #endif |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
158 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
159 return abort; |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
160 } |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
161 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
162 /* |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
163 * Copy the global 'tagfunc' callback function to the buffer-local 'tagfunc' |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
164 * callback for 'buf'. |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
165 */ |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
166 void |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
167 set_buflocal_tfu_callback(buf_T *buf UNUSED) |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
168 { |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
169 #ifdef FEAT_EVAL |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
170 free_callback(&buf->b_tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
171 if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
172 copy_callback(&buf->b_tfu_cb, &tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
173 #endif |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
174 } |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
175 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
176 /* |
7 | 177 * Jump to tag; handling of tag commands and tag stack |
178 * | |
179 * *tag != NUL: ":tag {tag}", jump to new tag, add to tag stack | |
180 * | |
181 * type == DT_TAG: ":tag [tag]", jump to newer position or same tag again | |
182 * type == DT_HELP: like DT_TAG, but don't use regexp. | |
183 * type == DT_POP: ":pop" or CTRL-T, jump to old position | |
184 * type == DT_NEXT: jump to next match of same tag | |
185 * type == DT_PREV: jump to previous match of same tag | |
186 * type == DT_FIRST: jump to first match of same tag | |
187 * type == DT_LAST: jump to last match of same tag | |
188 * type == DT_SELECT: ":tselect [tag]", select tag from a list of all matches | |
189 * type == DT_JUMP: ":tjump [tag]", jump to tag or select tag from a list | |
359 | 190 * type == DT_CSCOPE: use cscope to find the tag |
649 | 191 * type == DT_LTAG: use location list for displaying tag matches |
359 | 192 * type == DT_FREE: free cached matches |
7 | 193 * |
194 * for cscope, returns TRUE if we jumped to tag or aborted, FALSE otherwise | |
195 */ | |
196 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
197 do_tag( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
198 char_u *tag, // tag (pattern) to jump to |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
199 int type, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
200 int count, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
201 int forceit, // :ta with ! |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
202 int verbose) // print "tag not found" message |
7 | 203 { |
204 taggy_T *tagstack = curwin->w_tagstack; | |
205 int tagstackidx = curwin->w_tagstackidx; | |
206 int tagstacklen = curwin->w_tagstacklen; | |
207 int cur_match = 0; | |
208 int cur_fnum = curbuf->b_fnum; | |
209 int oldtagstackidx = tagstackidx; | |
210 int prevtagstackidx = tagstackidx; | |
211 int prev_num_matches; | |
212 int new_tag = FALSE; | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
213 int i; |
7 | 214 int ic; |
215 int no_regexp = FALSE; | |
216 int error_cur_match = 0; | |
217 int save_pos = FALSE; | |
218 fmark_T saved_fmark; | |
219 #ifdef FEAT_CSCOPE | |
220 int jumped_to_tag = FALSE; | |
221 #endif | |
222 int new_num_matches; | |
223 char_u **new_matches; | |
224 int use_tagstack; | |
225 int skip_msg = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
226 char_u *buf_ffname = curbuf->b_ffname; // name to use for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
227 // priority computation |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
228 int use_tfu = 1; |
7 | 229 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
230 // remember the matches for the last used tag |
7 | 231 static int num_matches = 0; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
232 static int max_num_matches = 0; // limit used for match search |
7 | 233 static char_u **matches = NULL; |
234 static int flags; | |
235 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
236 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
237 if (tfu_in_use) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
238 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
239 emsg(_(recurmsg)); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
240 return FALSE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
241 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
242 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
243 |
359 | 244 #ifdef EXITFREE |
245 if (type == DT_FREE) | |
246 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
247 // remove the list of matches |
359 | 248 FreeWild(num_matches, matches); |
249 # ifdef FEAT_CSCOPE | |
250 cs_free_tags(); | |
251 # endif | |
252 num_matches = 0; | |
253 return FALSE; | |
254 } | |
255 #endif | |
256 | |
7 | 257 if (type == DT_HELP) |
258 { | |
259 type = DT_TAG; | |
260 no_regexp = TRUE; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
261 use_tfu = 0; |
7 | 262 } |
263 | |
264 prev_num_matches = num_matches; | |
265 free_string_option(nofile_fname); | |
266 nofile_fname = NULL; | |
267 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
268 CLEAR_POS(&saved_fmark.mark); // shutup gcc 4.0 |
698 | 269 saved_fmark.fnum = 0; |
270 | |
7 | 271 /* |
272 * Don't add a tag to the tagstack if 'tagstack' has been reset. | |
273 */ | |
274 if ((!p_tgst && *tag != NUL)) | |
275 { | |
276 use_tagstack = FALSE; | |
277 new_tag = TRUE; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
278 #if defined(FEAT_QUICKFIX) |
8930
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
279 if (g_do_tagpreview != 0) |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
280 { |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
281 tagstack_clear_entry(&ptag_entry); |
8930
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
282 if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
283 goto end_do_tag; |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
284 } |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
285 #endif |
7 | 286 } |
287 else | |
288 { | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
289 #if defined(FEAT_QUICKFIX) |
2713 | 290 if (g_do_tagpreview != 0) |
7 | 291 use_tagstack = FALSE; |
292 else | |
293 #endif | |
294 use_tagstack = TRUE; | |
295 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
296 // new pattern, add to the tag stack |
845 | 297 if (*tag != NUL |
298 && (type == DT_TAG || type == DT_SELECT || type == DT_JUMP | |
649 | 299 #ifdef FEAT_QUICKFIX |
300 || type == DT_LTAG | |
301 #endif | |
7 | 302 #ifdef FEAT_CSCOPE |
303 || type == DT_CSCOPE | |
304 #endif | |
305 )) | |
306 { | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
307 #if defined(FEAT_QUICKFIX) |
2713 | 308 if (g_do_tagpreview != 0) |
7 | 309 { |
310 if (ptag_entry.tagname != NULL | |
311 && STRCMP(ptag_entry.tagname, tag) == 0) | |
312 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
313 // Jumping to same tag: keep the current match, so that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
314 // the CursorHold autocommand example works. |
7 | 315 cur_match = ptag_entry.cur_match; |
316 cur_fnum = ptag_entry.cur_fnum; | |
317 } | |
318 else | |
319 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
320 tagstack_clear_entry(&ptag_entry); |
7 | 321 if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) |
322 goto end_do_tag; | |
323 } | |
324 } | |
325 else | |
326 #endif | |
327 { | |
328 /* | |
329 * If the last used entry is not at the top, delete all tag | |
330 * stack entries above it. | |
331 */ | |
332 while (tagstackidx < tagstacklen) | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
333 tagstack_clear_entry(&tagstack[--tagstacklen]); |
7 | 334 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
335 // if the tagstack is full: remove oldest entry |
7 | 336 if (++tagstacklen > TAGSTACKSIZE) |
337 { | |
338 tagstacklen = TAGSTACKSIZE; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
339 tagstack_clear_entry(&tagstack[0]); |
7 | 340 for (i = 1; i < tagstacklen; ++i) |
341 tagstack[i - 1] = tagstack[i]; | |
342 --tagstackidx; | |
343 } | |
344 | |
345 /* | |
346 * put the tag name in the tag stack | |
347 */ | |
348 if ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL) | |
349 { | |
350 curwin->w_tagstacklen = tagstacklen - 1; | |
351 goto end_do_tag; | |
352 } | |
353 curwin->w_tagstacklen = tagstacklen; | |
354 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
355 save_pos = TRUE; // save the cursor position below |
7 | 356 } |
357 | |
358 new_tag = TRUE; | |
359 } | |
360 else | |
361 { | |
362 if ( | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
363 #if defined(FEAT_QUICKFIX) |
2713 | 364 g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : |
7 | 365 #endif |
366 tagstacklen == 0) | |
367 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
368 // empty stack |
26436
ef0c07cbf53f
patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
369 emsg(_(e_tag_stack_empty)); |
7 | 370 goto end_do_tag; |
371 } | |
372 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
373 if (type == DT_POP) // go to older position |
7 | 374 { |
375 #ifdef FEAT_FOLDING | |
376 int old_KeyTyped = KeyTyped; | |
377 #endif | |
378 if ((tagstackidx -= count) < 0) | |
379 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
380 emsg(_(bottommsg)); |
7 | 381 if (tagstackidx + count == 0) |
382 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
383 // We did [num]^T from the bottom of the stack |
7 | 384 tagstackidx = 0; |
385 goto end_do_tag; | |
386 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
387 // We weren't at the bottom of the stack, so jump all the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
388 // way to the bottom now. |
7 | 389 tagstackidx = 0; |
390 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
391 else if (tagstackidx >= tagstacklen) // count == 0? |
7 | 392 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
393 emsg(_(topmsg)); |
7 | 394 goto end_do_tag; |
395 } | |
396 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
397 // Make a copy of the fmark, autocommands may invalidate the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
398 // tagstack before it's used. |
7 | 399 saved_fmark = tagstack[tagstackidx].fmark; |
400 if (saved_fmark.fnum != curbuf->b_fnum) | |
401 { | |
402 /* | |
403 * Jump to other file. If this fails (e.g. because the | |
404 * file was changed) keep original position in tag stack. | |
405 */ | |
406 if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum, | |
407 GETF_SETMARK, forceit) == FAIL) | |
408 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
409 tagstackidx = oldtagstackidx; // back to old posn |
7 | 410 goto end_do_tag; |
411 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
412 // An BufReadPost autocommand may jump to the '" mark, but |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
413 // we don't what that here. |
7 | 414 curwin->w_cursor.lnum = saved_fmark.mark.lnum; |
415 } | |
416 else | |
417 { | |
418 setpcmark(); | |
419 curwin->w_cursor.lnum = saved_fmark.mark.lnum; | |
420 } | |
421 curwin->w_cursor.col = saved_fmark.mark.col; | |
422 curwin->w_set_curswant = TRUE; | |
423 check_cursor(); | |
424 #ifdef FEAT_FOLDING | |
425 if ((fdo_flags & FDO_TAG) && old_KeyTyped) | |
426 foldOpenCursor(); | |
427 #endif | |
428 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
429 // remove the old list of matches |
7 | 430 FreeWild(num_matches, matches); |
431 #ifdef FEAT_CSCOPE | |
432 cs_free_tags(); | |
433 #endif | |
434 num_matches = 0; | |
845 | 435 tag_freematch(); |
7 | 436 goto end_do_tag; |
437 } | |
438 | |
692 | 439 if (type == DT_TAG |
440 #if defined(FEAT_QUICKFIX) | |
845 | 441 || type == DT_LTAG |
692 | 442 #endif |
845 | 443 ) |
7 | 444 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
445 #if defined(FEAT_QUICKFIX) |
2713 | 446 if (g_do_tagpreview != 0) |
7 | 447 { |
448 cur_match = ptag_entry.cur_match; | |
449 cur_fnum = ptag_entry.cur_fnum; | |
450 } | |
451 else | |
452 #endif | |
453 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
454 // ":tag" (no argument): go to newer pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
455 save_pos = TRUE; // save the cursor position below |
7 | 456 if ((tagstackidx += count - 1) >= tagstacklen) |
457 { | |
458 /* | |
459 * Beyond the last one, just give an error message and | |
460 * go to the last one. Don't store the cursor | |
1204 | 461 * position. |
7 | 462 */ |
463 tagstackidx = tagstacklen - 1; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
464 emsg(_(topmsg)); |
7 | 465 save_pos = FALSE; |
466 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
467 else if (tagstackidx < 0) // must have been count == 0 |
7 | 468 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
469 emsg(_(bottommsg)); |
7 | 470 tagstackidx = 0; |
471 goto end_do_tag; | |
472 } | |
473 cur_match = tagstack[tagstackidx].cur_match; | |
474 cur_fnum = tagstack[tagstackidx].cur_fnum; | |
475 } | |
476 new_tag = TRUE; | |
477 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
478 else // go to other matching tag |
7 | 479 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
480 // Save index for when selection is cancelled. |
7 | 481 prevtagstackidx = tagstackidx; |
482 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
483 #if defined(FEAT_QUICKFIX) |
2713 | 484 if (g_do_tagpreview != 0) |
7 | 485 { |
486 cur_match = ptag_entry.cur_match; | |
487 cur_fnum = ptag_entry.cur_fnum; | |
488 } | |
489 else | |
490 #endif | |
491 { | |
492 if (--tagstackidx < 0) | |
493 tagstackidx = 0; | |
494 cur_match = tagstack[tagstackidx].cur_match; | |
495 cur_fnum = tagstack[tagstackidx].cur_fnum; | |
496 } | |
497 switch (type) | |
498 { | |
499 case DT_FIRST: cur_match = count - 1; break; | |
500 case DT_SELECT: | |
501 case DT_JUMP: | |
502 #ifdef FEAT_CSCOPE | |
503 case DT_CSCOPE: | |
504 #endif | |
505 case DT_LAST: cur_match = MAXCOL - 1; break; | |
506 case DT_NEXT: cur_match += count; break; | |
507 case DT_PREV: cur_match -= count; break; | |
508 } | |
509 if (cur_match >= MAXCOL) | |
510 cur_match = MAXCOL - 1; | |
511 else if (cur_match < 0) | |
512 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
513 emsg(_("E425: Cannot go before first matching tag")); |
7 | 514 skip_msg = TRUE; |
515 cur_match = 0; | |
516 cur_fnum = curbuf->b_fnum; | |
517 } | |
518 } | |
519 } | |
520 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
521 #if defined(FEAT_QUICKFIX) |
2713 | 522 if (g_do_tagpreview != 0) |
7 | 523 { |
524 if (type != DT_SELECT && type != DT_JUMP) | |
525 { | |
526 ptag_entry.cur_match = cur_match; | |
527 ptag_entry.cur_fnum = cur_fnum; | |
528 } | |
529 } | |
530 else | |
531 #endif | |
532 { | |
533 /* | |
534 * For ":tag [arg]" or ":tselect" remember position before the jump. | |
535 */ | |
536 saved_fmark = tagstack[tagstackidx].fmark; | |
537 if (save_pos) | |
538 { | |
539 tagstack[tagstackidx].fmark.mark = curwin->w_cursor; | |
540 tagstack[tagstackidx].fmark.fnum = curbuf->b_fnum; | |
541 } | |
542 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
543 // Curwin will change in the call to jumpto_tag() if ":stag" was |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
544 // used or an autocommand jumps to another window; store value of |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
545 // tagstackidx now. |
7 | 546 curwin->w_tagstackidx = tagstackidx; |
547 if (type != DT_SELECT && type != DT_JUMP) | |
548 { | |
549 curwin->w_tagstack[tagstackidx].cur_match = cur_match; | |
550 curwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum; | |
551 } | |
552 } | |
553 } | |
554 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
555 // When not using the current buffer get the name of buffer "cur_fnum". |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
556 // Makes sure that the tag order doesn't change when using a remembered |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
557 // position for "cur_match". |
7 | 558 if (cur_fnum != curbuf->b_fnum) |
559 { | |
560 buf_T *buf = buflist_findnr(cur_fnum); | |
561 | |
562 if (buf != NULL) | |
563 buf_ffname = buf->b_ffname; | |
564 } | |
565 | |
566 /* | |
567 * Repeat searching for tags, when a file has not been found. | |
568 */ | |
569 for (;;) | |
570 { | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
571 int other_name; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
572 char_u *name; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
573 |
7 | 574 /* |
575 * When desired match not found yet, try to find it (and others). | |
576 */ | |
577 if (use_tagstack) | |
578 name = tagstack[tagstackidx].tagname; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
579 #if defined(FEAT_QUICKFIX) |
2713 | 580 else if (g_do_tagpreview != 0) |
7 | 581 name = ptag_entry.tagname; |
582 #endif | |
583 else | |
584 name = tag; | |
585 other_name = (tagmatchname == NULL || STRCMP(tagmatchname, name) != 0); | |
586 if (new_tag | |
587 || (cur_match >= num_matches && max_num_matches != MAXCOL) | |
588 || other_name) | |
589 { | |
590 if (other_name) | |
591 { | |
592 vim_free(tagmatchname); | |
593 tagmatchname = vim_strsave(name); | |
594 } | |
595 | |
16164
213b88f89597
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Bram Moolenaar <Bram@vim.org>
parents:
16142
diff
changeset
|
596 if (type == DT_SELECT || type == DT_JUMP |
692 | 597 #if defined(FEAT_QUICKFIX) |
598 || type == DT_LTAG | |
599 #endif | |
600 ) | |
7 | 601 cur_match = MAXCOL - 1; |
16164
213b88f89597
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Bram Moolenaar <Bram@vim.org>
parents:
16142
diff
changeset
|
602 if (type == DT_TAG) |
213b88f89597
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Bram Moolenaar <Bram@vim.org>
parents:
16142
diff
changeset
|
603 max_num_matches = MAXCOL; |
213b88f89597
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Bram Moolenaar <Bram@vim.org>
parents:
16142
diff
changeset
|
604 else |
213b88f89597
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Bram Moolenaar <Bram@vim.org>
parents:
16142
diff
changeset
|
605 max_num_matches = cur_match + 1; |
7 | 606 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
607 // when the argument starts with '/', use it as a regexp |
7 | 608 if (!no_regexp && *name == '/') |
609 { | |
610 flags = TAG_REGEXP; | |
611 ++name; | |
612 } | |
613 else | |
614 flags = TAG_NOIC; | |
615 | |
616 #ifdef FEAT_CSCOPE | |
617 if (type == DT_CSCOPE) | |
618 flags = TAG_CSCOPE; | |
619 #endif | |
620 if (verbose) | |
621 flags |= TAG_VERBOSE; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
622 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
623 if (!use_tfu) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
624 flags |= TAG_NO_TAGFUNC; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
625 |
7 | 626 if (find_tags(name, &new_num_matches, &new_matches, flags, |
627 max_num_matches, buf_ffname) == OK | |
628 && new_num_matches < max_num_matches) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
629 max_num_matches = MAXCOL; // If less than max_num_matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
630 // found: all matches found. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
631 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
632 // If there already were some matches for the same name, move them |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
633 // to the start. Avoids that the order changes when using |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
634 // ":tnext" and jumping to another file. |
7 | 635 if (!new_tag && !other_name) |
636 { | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
637 int j, k; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
638 int idx = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
639 tagptrs_T tagp, tagp2; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
640 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
641 // Find the position of each old match in the new list. Need |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
642 // to use parse_match() to find the tag line. |
7 | 643 for (j = 0; j < num_matches; ++j) |
644 { | |
645 parse_match(matches[j], &tagp); | |
646 for (i = idx; i < new_num_matches; ++i) | |
647 { | |
648 parse_match(new_matches[i], &tagp2); | |
649 if (STRCMP(tagp.tagname, tagp2.tagname) == 0) | |
650 { | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
651 char_u *p = new_matches[i]; |
7 | 652 for (k = i; k > idx; --k) |
653 new_matches[k] = new_matches[k - 1]; | |
654 new_matches[idx++] = p; | |
655 break; | |
656 } | |
657 } | |
658 } | |
659 } | |
660 FreeWild(num_matches, matches); | |
661 num_matches = new_num_matches; | |
662 matches = new_matches; | |
663 } | |
664 | |
665 if (num_matches <= 0) | |
666 { | |
667 if (verbose) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
668 semsg(_("E426: tag not found: %s"), name); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
669 #if defined(FEAT_QUICKFIX) |
7 | 670 g_do_tagpreview = 0; |
671 #endif | |
672 } | |
673 else | |
674 { | |
675 int ask_for_selection = FALSE; | |
676 | |
677 #ifdef FEAT_CSCOPE | |
678 if (type == DT_CSCOPE && num_matches > 1) | |
679 { | |
680 cs_print_tags(); | |
681 ask_for_selection = TRUE; | |
682 } | |
683 else | |
684 #endif | |
16164
213b88f89597
patch 8.1.1087: tag stack is incorrect after CTRL-T and then :tag
Bram Moolenaar <Bram@vim.org>
parents:
16142
diff
changeset
|
685 if (type == DT_TAG && *tag != NUL) |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
686 // If a count is supplied to the ":tag <name>" command, then |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
687 // jump to count'th matching tag. |
6851 | 688 cur_match = count > 0 ? count - 1 : 0; |
689 else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1)) | |
7 | 690 { |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
691 print_tag_list(new_tag, use_tagstack, num_matches, matches); |
7 | 692 ask_for_selection = TRUE; |
693 } | |
649 | 694 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
692 | 695 else if (type == DT_LTAG) |
649 | 696 { |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
697 if (add_llist_tags(tag, num_matches, matches) == FAIL) |
649 | 698 goto end_do_tag; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
699 cur_match = 0; // Jump to the first tag |
649 | 700 } |
701 #endif | |
7 | 702 |
703 if (ask_for_selection == TRUE) | |
704 { | |
705 /* | |
706 * Ask to select a tag from the list. | |
707 */ | |
373 | 708 i = prompt_for_number(NULL); |
7 | 709 if (i <= 0 || i > num_matches || got_int) |
710 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
711 // no valid choice: don't change anything |
7 | 712 if (use_tagstack) |
713 { | |
714 tagstack[tagstackidx].fmark = saved_fmark; | |
715 tagstackidx = prevtagstackidx; | |
716 } | |
717 #ifdef FEAT_CSCOPE | |
718 cs_free_tags(); | |
719 jumped_to_tag = TRUE; | |
720 #endif | |
721 break; | |
722 } | |
723 cur_match = i - 1; | |
724 } | |
725 | |
726 if (cur_match >= num_matches) | |
727 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
728 // Avoid giving this error when a file wasn't found and we're |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
729 // looking for a match in another file, which wasn't found. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
730 // There will be an emsg("file doesn't exist") below then. |
7 | 731 if ((type == DT_NEXT || type == DT_FIRST) |
732 && nofile_fname == NULL) | |
733 { | |
734 if (num_matches == 1) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
735 emsg(_("E427: There is only one matching tag")); |
7 | 736 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
737 emsg(_("E428: Cannot go beyond last matching tag")); |
7 | 738 skip_msg = TRUE; |
739 } | |
740 cur_match = num_matches - 1; | |
741 } | |
742 if (use_tagstack) | |
743 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
744 tagptrs_T tagp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
745 |
7 | 746 tagstack[tagstackidx].cur_match = cur_match; |
747 tagstack[tagstackidx].cur_fnum = cur_fnum; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
748 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
749 // store user-provided data originating from tagfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
750 if (use_tfu && parse_match(matches[cur_match], &tagp) == OK |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
751 && tagp.user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
752 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
753 VIM_CLEAR(tagstack[tagstackidx].user_data); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
754 tagstack[tagstackidx].user_data = vim_strnsave( |
21996
808edde1e97d
patch 8.2.1547: various comment problems
Bram Moolenaar <Bram@vim.org>
parents:
20384
diff
changeset
|
755 tagp.user_data, tagp.user_data_end - tagp.user_data); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
756 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
757 |
7 | 758 ++tagstackidx; |
759 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
760 #if defined(FEAT_QUICKFIX) |
2713 | 761 else if (g_do_tagpreview != 0) |
7 | 762 { |
763 ptag_entry.cur_match = cur_match; | |
764 ptag_entry.cur_fnum = cur_fnum; | |
765 } | |
766 #endif | |
767 | |
768 /* | |
769 * Only when going to try the next match, report that the previous | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
770 * file didn't exist. Otherwise an emsg() is given below. |
7 | 771 */ |
772 if (nofile_fname != NULL && error_cur_match != cur_match) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
773 smsg(_("File \"%s\" does not exist"), nofile_fname); |
7 | 774 |
775 | |
776 ic = (matches[cur_match][0] & MT_IC_OFF); | |
6851 | 777 if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP |
7 | 778 #ifdef FEAT_CSCOPE |
779 && type != DT_CSCOPE | |
780 #endif | |
781 && (num_matches > 1 || ic) | |
782 && !skip_msg) | |
783 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
784 // Give an indication of the number of matching tags |
7 | 785 sprintf((char *)IObuff, _("tag %d of %d%s"), |
786 cur_match + 1, | |
787 num_matches, | |
788 max_num_matches != MAXCOL ? _(" or more") : ""); | |
789 if (ic) | |
790 STRCAT(IObuff, _(" Using tag with different case!")); | |
791 if ((num_matches > prev_num_matches || new_tag) | |
792 && num_matches > 1) | |
793 { | |
794 if (ic) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
795 msg_attr((char *)IObuff, HL_ATTR(HLF_W)); |
7 | 796 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
797 msg((char *)IObuff); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
798 msg_scroll = TRUE; // don't overwrite this message |
7 | 799 } |
800 else | |
801 give_warning(IObuff, ic); | |
802 if (ic && !msg_scrolled && msg_silent == 0) | |
803 { | |
804 out_flush(); | |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18640
diff
changeset
|
805 ui_delay(1007L, TRUE); |
7 | 806 } |
807 } | |
808 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
809 #if defined(FEAT_EVAL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
810 // Let the SwapExists event know what tag we are jumping to. |
589 | 811 vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name); |
812 set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1); | |
813 #endif | |
814 | |
7 | 815 /* |
816 * Jump to the desired match. | |
817 */ | |
589 | 818 i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE); |
819 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
820 #if defined(FEAT_EVAL) |
589 | 821 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); |
822 #endif | |
823 | |
824 if (i == NOTAGFILE) | |
7 | 825 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
826 // File not found: try again with another matching tag |
7 | 827 if ((type == DT_PREV && cur_match > 0) |
828 || ((type == DT_TAG || type == DT_NEXT | |
829 || type == DT_FIRST) | |
830 && (max_num_matches != MAXCOL | |
831 || cur_match < num_matches - 1))) | |
832 { | |
833 error_cur_match = cur_match; | |
834 if (use_tagstack) | |
835 --tagstackidx; | |
836 if (type == DT_PREV) | |
837 --cur_match; | |
838 else | |
839 { | |
840 type = DT_NEXT; | |
841 ++cur_match; | |
842 } | |
843 continue; | |
844 } | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
845 semsg(_("E429: File \"%s\" does not exist"), nofile_fname); |
7 | 846 } |
847 else | |
848 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
849 // We may have jumped to another window, check that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
850 // tagstackidx is still valid. |
7 | 851 if (use_tagstack && tagstackidx > curwin->w_tagstacklen) |
852 tagstackidx = curwin->w_tagstackidx; | |
853 #ifdef FEAT_CSCOPE | |
854 jumped_to_tag = TRUE; | |
855 #endif | |
856 } | |
857 } | |
858 break; | |
859 } | |
860 | |
861 end_do_tag: | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
862 // Only store the new index when using the tagstack and it's valid. |
7 | 863 if (use_tagstack && tagstackidx <= curwin->w_tagstacklen) |
864 curwin->w_tagstackidx = tagstackidx; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
865 postponed_split = 0; // don't split next time |
9949
30be4b26a37e
commit https://github.com/vim/vim/commit/358308dd99abdd56c6540339e505585d8db7bdfe
Christian Brabandt <cb@256bit.org>
parents:
9913
diff
changeset
|
866 # ifdef FEAT_QUICKFIX |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
867 g_do_tagpreview = 0; // don't do tag preview next time |
9949
30be4b26a37e
commit https://github.com/vim/vim/commit/358308dd99abdd56c6540339e505585d8db7bdfe
Christian Brabandt <cb@256bit.org>
parents:
9913
diff
changeset
|
868 # endif |
7 | 869 |
870 #ifdef FEAT_CSCOPE | |
871 return jumped_to_tag; | |
872 #else | |
873 return FALSE; | |
874 #endif | |
875 } | |
876 | |
877 /* | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
878 * List all the matching tags. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
879 */ |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
880 static void |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
881 print_tag_list( |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
882 int new_tag, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
883 int use_tagstack, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
884 int num_matches, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
885 char_u **matches) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
886 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
887 taggy_T *tagstack = curwin->w_tagstack; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
888 int tagstackidx = curwin->w_tagstackidx; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
889 int i; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
890 char_u *p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
891 char_u *command_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
892 tagptrs_T tagp; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
893 int taglen; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
894 int attr; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
895 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
896 /* |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
897 * Assume that the first match indicates how long the tags can |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
898 * be, and align the file names to that. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
899 */ |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
900 parse_match(matches[0], &tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
901 taglen = (int)(tagp.tagname_end - tagp.tagname + 2); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
902 if (taglen < 18) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
903 taglen = 18; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
904 if (taglen > Columns - 25) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
905 taglen = MAXCOL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
906 if (msg_col == 0) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
907 msg_didout = FALSE; // overwrite previous message |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
908 msg_start(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
909 msg_puts_attr(_(" # pri kind tag"), HL_ATTR(HLF_T)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
910 msg_clr_eos(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
911 taglen_advance(taglen); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
912 msg_puts_attr(_("file\n"), HL_ATTR(HLF_T)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
913 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
914 for (i = 0; i < num_matches && !got_int; ++i) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
915 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
916 parse_match(matches[i], &tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
917 if (!new_tag && ( |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
918 #if defined(FEAT_QUICKFIX) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
919 (g_do_tagpreview != 0 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
920 && i == ptag_entry.cur_match) || |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
921 #endif |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
922 (use_tagstack |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
923 && i == tagstack[tagstackidx].cur_match))) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
924 *IObuff = '>'; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
925 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
926 *IObuff = ' '; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
927 vim_snprintf((char *)IObuff + 1, IOSIZE - 1, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
928 "%2d %s ", i + 1, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
929 mt_names[matches[i][0] & MT_MASK]); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
930 msg_puts((char *)IObuff); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
931 if (tagp.tagkind != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
932 msg_outtrans_len(tagp.tagkind, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
933 (int)(tagp.tagkind_end - tagp.tagkind)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
934 msg_advance(13); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
935 msg_outtrans_len_attr(tagp.tagname, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
936 (int)(tagp.tagname_end - tagp.tagname), |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
937 HL_ATTR(HLF_T)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
938 msg_putchar(' '); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
939 taglen_advance(taglen); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
940 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
941 // Find out the actual file name. If it is long, truncate |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
942 // it and put "..." in the middle |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
943 p = tag_full_fname(&tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
944 if (p != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
945 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
946 msg_outtrans_long_attr(p, HL_ATTR(HLF_D)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
947 vim_free(p); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
948 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
949 if (msg_col > 0) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
950 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
951 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
952 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
953 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
954 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
955 // print any extra fields |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
956 command_end = tagp.command_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
957 if (command_end != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
958 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
959 p = command_end + 3; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
960 while (*p && *p != '\r' && *p != '\n') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
961 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
962 while (*p == TAB) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
963 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
964 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
965 // skip "file:" without a value (static tag) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
966 if (STRNCMP(p, "file:", 5) == 0 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
967 && vim_isspace(p[5])) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
968 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
969 p += 5; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
970 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
971 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
972 // skip "kind:<kind>" and "<kind>" |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
973 if (p == tagp.tagkind |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
974 || (p + 5 == tagp.tagkind |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
975 && STRNCMP(p, "kind:", 5) == 0)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
976 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
977 p = tagp.tagkind_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
978 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
979 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
980 // print all other extra fields |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
981 attr = HL_ATTR(HLF_CM); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
982 while (*p && *p != '\r' && *p != '\n') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
983 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
984 if (msg_col + ptr2cells(p) >= Columns) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
985 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
986 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
987 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
988 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
989 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
990 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
991 p = msg_outtrans_one(p, attr); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
992 if (*p == TAB) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
993 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
994 msg_puts_attr(" ", attr); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
995 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
996 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
997 if (*p == ':') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
998 attr = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
999 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1000 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1001 if (msg_col > 15) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1002 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1003 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1004 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1005 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1006 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1007 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1008 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1009 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1010 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1011 for (p = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1012 *p && *p != '\r' && *p != '\n'; ++p) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1013 ; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1014 command_end = p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1015 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1016 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1017 // Put the info (in several lines) at column 15. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1018 // Don't display "/^" and "?^". |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1019 p = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1020 if (*p == '/' || *p == '?') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1021 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1022 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1023 if (*p == '^') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1024 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1025 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1026 // Remove leading whitespace from pattern |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1027 while (p != command_end && vim_isspace(*p)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1028 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1029 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1030 while (p != command_end) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1031 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1032 if (msg_col + (*p == TAB ? 1 : ptr2cells(p)) > Columns) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1033 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1034 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1035 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1036 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1037 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1038 // skip backslash used for escaping a command char or |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1039 // a backslash |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1040 if (*p == '\\' && (*(p + 1) == *tagp.command |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1041 || *(p + 1) == '\\')) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1042 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1043 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1044 if (*p == TAB) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1045 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1046 msg_putchar(' '); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1047 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1048 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1049 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1050 p = msg_outtrans_one(p, 0); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1051 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1052 // don't display the "$/;\"" and "$?;\"" |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1053 if (p == command_end - 2 && *p == '$' |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1054 && *(p + 1) == *tagp.command) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1055 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1056 // don't display matching '/' or '?' |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1057 if (p == command_end - 1 && *p == *tagp.command |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1058 && (*p == '/' || *p == '?')) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1059 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1060 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1061 if (msg_col) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1062 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1063 ui_breakcheck(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1064 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1065 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1066 got_int = FALSE; // only stop the listing |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1067 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1068 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1069 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1070 /* |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1071 * Add the matching tags to the location list for the current |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1072 * window. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1073 */ |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1074 static int |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1075 add_llist_tags( |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1076 char_u *tag, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1077 int num_matches, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1078 char_u **matches) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1079 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1080 list_T *list; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1081 char_u tag_name[128 + 1]; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1082 char_u *fname; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1083 char_u *cmd; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1084 int i; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1085 char_u *p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1086 tagptrs_T tagp; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1087 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1088 fname = alloc(MAXPATHL + 1); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1089 cmd = alloc(CMDBUFFSIZE + 1); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1090 list = list_alloc(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1091 if (list == NULL || fname == NULL || cmd == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1092 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1093 vim_free(cmd); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1094 vim_free(fname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1095 if (list != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1096 list_free(list); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1097 return FAIL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1098 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1099 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1100 for (i = 0; i < num_matches; ++i) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1101 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1102 int len, cmd_len; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1103 long lnum; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1104 dict_T *dict; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1105 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1106 parse_match(matches[i], &tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1107 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1108 // Save the tag name |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1109 len = (int)(tagp.tagname_end - tagp.tagname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1110 if (len > 128) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1111 len = 128; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1112 vim_strncpy(tag_name, tagp.tagname, len); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1113 tag_name[len] = NUL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1114 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1115 // Save the tag file name |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1116 p = tag_full_fname(&tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1117 if (p == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1118 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1119 vim_strncpy(fname, p, MAXPATHL); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1120 vim_free(p); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1121 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1122 // Get the line number or the search pattern used to locate |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1123 // the tag. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1124 lnum = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1125 if (isdigit(*tagp.command)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1126 // Line number is used to locate the tag |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1127 lnum = atol((char *)tagp.command); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1128 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1129 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1130 char_u *cmd_start, *cmd_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1131 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1132 // Search pattern is used to locate the tag |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1133 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1134 // Locate the end of the command |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1135 cmd_start = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1136 cmd_end = tagp.command_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1137 if (cmd_end == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1138 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1139 for (p = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1140 *p && *p != '\r' && *p != '\n'; ++p) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1141 ; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1142 cmd_end = p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1143 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1144 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1145 // Now, cmd_end points to the character after the |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1146 // command. Adjust it to point to the last |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1147 // character of the command. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1148 cmd_end--; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1149 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1150 // Skip the '/' and '?' characters at the |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1151 // beginning and end of the search pattern. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1152 if (*cmd_start == '/' || *cmd_start == '?') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1153 cmd_start++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1154 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1155 if (*cmd_end == '/' || *cmd_end == '?') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1156 cmd_end--; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1157 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1158 len = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1159 cmd[0] = NUL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1160 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1161 // If "^" is present in the tag search pattern, then |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1162 // copy it first. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1163 if (*cmd_start == '^') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1164 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1165 STRCPY(cmd, "^"); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1166 cmd_start++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1167 len++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1168 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1169 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1170 // Precede the tag pattern with \V to make it very |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1171 // nomagic. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1172 STRCAT(cmd, "\\V"); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1173 len += 2; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1174 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1175 cmd_len = (int)(cmd_end - cmd_start + 1); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1176 if (cmd_len > (CMDBUFFSIZE - 5)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1177 cmd_len = CMDBUFFSIZE - 5; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1178 STRNCAT(cmd, cmd_start, cmd_len); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1179 len += cmd_len; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1180 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1181 if (cmd[len - 1] == '$') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1182 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1183 // Replace '$' at the end of the search pattern |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1184 // with '\$' |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1185 cmd[len - 1] = '\\'; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1186 cmd[len] = '$'; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1187 len++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1188 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1189 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1190 cmd[len] = NUL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1191 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1192 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1193 if ((dict = dict_alloc()) == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1194 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1195 if (list_append_dict(list, dict) == FAIL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1196 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1197 vim_free(dict); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1198 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1199 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1200 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1201 dict_add_string(dict, "text", tag_name); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1202 dict_add_string(dict, "filename", fname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1203 dict_add_number(dict, "lnum", lnum); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1204 if (lnum == 0) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1205 dict_add_string(dict, "pattern", cmd); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1206 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1207 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1208 vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1209 set_errorlist(curwin, list, ' ', IObuff, NULL); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1210 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1211 list_free(list); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1212 vim_free(fname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1213 vim_free(cmd); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1214 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1215 return OK; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1216 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1217 #endif |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1218 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1219 /* |
7 | 1220 * Free cached tags. |
1221 */ | |
1222 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1223 tag_freematch(void) |
7 | 1224 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13227
diff
changeset
|
1225 VIM_CLEAR(tagmatchname); |
7 | 1226 } |
1227 | |
1228 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1229 taglen_advance(int l) |
7 | 1230 { |
1231 if (l == MAXCOL) | |
1232 { | |
1233 msg_putchar('\n'); | |
1234 msg_advance(24); | |
1235 } | |
1236 else | |
1237 msg_advance(13 + l); | |
1238 } | |
1239 | |
1240 /* | |
1241 * Print the tag stack | |
1242 */ | |
1243 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1244 do_tags(exarg_T *eap UNUSED) |
7 | 1245 { |
1246 int i; | |
1247 char_u *name; | |
1248 taggy_T *tagstack = curwin->w_tagstack; | |
1249 int tagstackidx = curwin->w_tagstackidx; | |
1250 int tagstacklen = curwin->w_tagstacklen; | |
1251 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1252 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1253 msg_puts_title(_("\n # TO tag FROM line in file/text")); |
7 | 1254 for (i = 0; i < tagstacklen; ++i) |
1255 { | |
1256 if (tagstack[i].tagname != NULL) | |
1257 { | |
1258 name = fm_getname(&(tagstack[i].fmark), 30); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1259 if (name == NULL) // file name not available |
7 | 1260 continue; |
1261 | |
1262 msg_putchar('\n'); | |
13068
63fdea6e9c6c
patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents:
12680
diff
changeset
|
1263 vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5ld ", |
7 | 1264 i == tagstackidx ? '>' : ' ', |
1265 i + 1, | |
1266 tagstack[i].cur_match + 1, | |
1267 tagstack[i].tagname, | |
1268 tagstack[i].fmark.mark.lnum); | |
1269 msg_outtrans(IObuff); | |
1270 msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1271 ? HL_ATTR(HLF_D) : 0); |
7 | 1272 vim_free(name); |
1273 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1274 out_flush(); // show one line at a time |
7 | 1275 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1276 if (tagstackidx == tagstacklen) // idx at top of stack |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1277 msg_puts("\n>"); |
7 | 1278 } |
1279 | |
1280 #ifdef FEAT_TAG_BINS | |
1281 /* | |
1282 * Compare two strings, for length "len", ignoring case the ASCII way. | |
1283 * return 0 for match, < 0 for smaller, > 0 for bigger | |
1284 * Make sure case is folded to uppercase in comparison (like for 'sort -f') | |
1285 */ | |
1286 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1287 tag_strnicmp(char_u *s1, char_u *s2, size_t len) |
7 | 1288 { |
1289 int i; | |
1290 | |
1291 while (len > 0) | |
1292 { | |
1293 i = (int)TOUPPER_ASC(*s1) - (int)TOUPPER_ASC(*s2); | |
1294 if (i != 0) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1295 return i; // this character different |
7 | 1296 if (*s1 == NUL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1297 break; // strings match until NUL |
7 | 1298 ++s1; |
1299 ++s2; | |
1300 --len; | |
1301 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1302 return 0; // strings match |
7 | 1303 } |
1304 #endif | |
1305 | |
1306 /* | |
1307 * Structure to hold info about the tag pattern being used. | |
1308 */ | |
1309 typedef struct | |
1310 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1311 char_u *pat; // the pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1312 int len; // length of pat[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1313 char_u *head; // start of pattern head |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1314 int headlen; // length of head[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1315 regmatch_T regmatch; // regexp program, may be NULL |
7 | 1316 } pat_T; |
1317 | |
1318 /* | |
1319 * Extract info from the tag search pattern "pats->pat". | |
1320 */ | |
1321 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1322 prepare_pats(pat_T *pats, int has_re) |
7 | 1323 { |
1324 pats->head = pats->pat; | |
1325 pats->headlen = pats->len; | |
1326 if (has_re) | |
1327 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1328 // When the pattern starts with '^' or "\\<", binary searching can be |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1329 // used (much faster). |
7 | 1330 if (pats->pat[0] == '^') |
1331 pats->head = pats->pat + 1; | |
1332 else if (pats->pat[0] == '\\' && pats->pat[1] == '<') | |
1333 pats->head = pats->pat + 2; | |
1334 if (pats->head == pats->pat) | |
1335 pats->headlen = 0; | |
1336 else | |
1337 for (pats->headlen = 0; pats->head[pats->headlen] != NUL; | |
1338 ++pats->headlen) | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1339 if (vim_strchr((char_u *)(magic_isset() ? ".[~*\\$" : "\\$"), |
7 | 1340 pats->head[pats->headlen]) != NULL) |
1341 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1342 if (p_tl != 0 && pats->headlen > p_tl) // adjust for 'taglength' |
7 | 1343 pats->headlen = p_tl; |
1344 } | |
1345 | |
1346 if (has_re) | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1347 pats->regmatch.regprog = vim_regcomp(pats->pat, |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1348 magic_isset() ? RE_MAGIC : 0); |
7 | 1349 else |
1350 pats->regmatch.regprog = NULL; | |
1351 } | |
1352 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1353 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1354 /* |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1355 * Call the user-defined function to generate a list of tags used by |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1356 * find_tags(). |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1357 * |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1358 * Return OK if at least 1 tag has been successfully found, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1359 * NOTDONE if the function returns v:null, and FAIL otherwise. |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1360 */ |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1361 static int |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1362 find_tagfunc_tags( |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1363 char_u *pat, // pattern supplied to the user-defined function |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1364 garray_T *ga, // the tags will be placed here |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1365 int *match_count, // here the number of tags found will be placed |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1366 int flags, // flags from find_tags (TAG_*) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1367 char_u *buf_ffname) // name of buffer for priority |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1368 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1369 pos_T save_pos; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1370 list_T *taglist; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1371 listitem_T *item; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1372 int ntags = 0; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1373 int result = FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1374 typval_T args[4]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1375 typval_T rettv; |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1376 char_u flagString[4]; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1377 dict_T *d; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1378 taggy_T *tag = &curwin->w_tagstack[curwin->w_tagstackidx]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1379 |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26436
diff
changeset
|
1380 if (*curbuf->b_p_tfu == NUL || curbuf->b_tfu_cb.cb_name == NULL |
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26436
diff
changeset
|
1381 || *curbuf->b_tfu_cb.cb_name == NUL) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1382 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1383 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1384 args[0].v_type = VAR_STRING; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1385 args[0].vval.v_string = pat; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1386 args[1].v_type = VAR_STRING; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1387 args[1].vval.v_string = flagString; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1388 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1389 // create 'info' dict argument |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1390 if ((d = dict_alloc_lock(VAR_FIXED)) == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1391 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1392 if (tag->user_data != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1393 dict_add_string(d, "user_data", tag->user_data); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1394 if (buf_ffname != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1395 dict_add_string(d, "buf_ffname", buf_ffname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1396 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1397 ++d->dv_refcount; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1398 args[2].v_type = VAR_DICT; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1399 args[2].vval.v_dict = d; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1400 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1401 args[3].v_type = VAR_UNKNOWN; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1402 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1403 vim_snprintf((char *)flagString, sizeof(flagString), |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1404 "%s%s%s", |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1405 g_tag_at_cursor ? "c": "", |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1406 flags & TAG_INS_COMP ? "i": "", |
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1407 flags & TAG_REGEXP ? "r": ""); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1408 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1409 save_pos = curwin->w_cursor; |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
1410 result = call_callback(&curbuf->b_tfu_cb, 0, &rettv, 3, args); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1411 curwin->w_cursor = save_pos; // restore the cursor position |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1412 --d->dv_refcount; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1413 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1414 if (result == FAIL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1415 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1416 if (rettv.v_type == VAR_SPECIAL && rettv.vval.v_number == VVAL_NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1417 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1418 clear_tv(&rettv); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1419 return NOTDONE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1420 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1421 if (rettv.v_type != VAR_LIST || !rettv.vval.v_list) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1422 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1423 clear_tv(&rettv); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1424 emsg(_(tfu_inv_ret_msg)); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1425 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1426 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1427 taglist = rettv.vval.v_list; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1428 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19617
diff
changeset
|
1429 FOR_ALL_LIST_ITEMS(taglist, item) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1430 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1431 char_u *mfp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1432 char_u *res_name, *res_fname, *res_cmd, *res_kind; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1433 int len; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1434 dict_iterator_T iter; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1435 char_u *dict_key; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1436 typval_T *tv; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1437 int has_extra = 0; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1438 int name_only = flags & TAG_NAMES; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1439 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1440 if (item->li_tv.v_type != VAR_DICT) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1441 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1442 emsg(_(tfu_inv_ret_msg)); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1443 break; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1444 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1445 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1446 #ifdef FEAT_EMACS_TAGS |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1447 len = 3; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1448 #else |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1449 len = 2; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1450 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1451 res_name = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1452 res_fname = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1453 res_cmd = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1454 res_kind = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1455 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1456 dict_iterate_start(&item->li_tv, &iter); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1457 while (NULL != (dict_key = dict_iterate_next(&iter, &tv))) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1458 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1459 if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1460 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1461 |
16461
826ad48af5e3
patch 8.1.1235: compiler warnings for using STRLEN() value
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
1462 len += (int)STRLEN(tv->vval.v_string) + 1; // Space for "\tVALUE" |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1463 if (!STRCMP(dict_key, "name")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1464 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1465 res_name = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1466 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1467 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1468 if (!STRCMP(dict_key, "filename")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1469 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1470 res_fname = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1471 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1472 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1473 if (!STRCMP(dict_key, "cmd")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1474 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1475 res_cmd = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1476 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1477 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1478 has_extra = 1; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1479 if (!STRCMP(dict_key, "kind")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1480 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1481 res_kind = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1482 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1483 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1484 // Other elements will be stored as "\tKEY:VALUE" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1485 // Allocate space for the key and the colon |
16461
826ad48af5e3
patch 8.1.1235: compiler warnings for using STRLEN() value
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
1486 len += (int)STRLEN(dict_key) + 1; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1487 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1488 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1489 if (has_extra) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1490 len += 2; // need space for ;" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1491 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1492 if (!res_name || !res_fname || !res_cmd) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1493 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1494 emsg(_(tfu_inv_ret_msg)); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1495 break; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1496 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1497 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1498 if (name_only) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1499 mfp = vim_strsave(res_name); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1500 else |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
1501 mfp = alloc(sizeof(char_u) + len + 1); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1502 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1503 if (mfp == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1504 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1505 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1506 if (!name_only) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1507 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1508 char_u *p = mfp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1509 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1510 *p++ = MT_GL_OTH + 1; // mtt |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1511 *p++ = TAG_SEP; // no tag file name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1512 #ifdef FEAT_EMACS_TAGS |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1513 *p++ = TAG_SEP; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1514 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1515 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1516 STRCPY(p, res_name); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1517 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1518 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1519 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1520 STRCPY(p, res_fname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1521 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1522 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1523 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1524 STRCPY(p, res_cmd); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1525 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1526 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1527 if (has_extra) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1528 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1529 STRCPY(p, ";\""); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1530 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1531 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1532 if (res_kind) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1533 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1534 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1535 STRCPY(p, res_kind); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1536 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1537 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1538 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1539 dict_iterate_start(&item->li_tv, &iter); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1540 while (NULL != (dict_key = dict_iterate_next(&iter, &tv))) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1541 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1542 if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1543 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1544 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1545 if (!STRCMP(dict_key, "name")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1546 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1547 if (!STRCMP(dict_key, "filename")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1548 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1549 if (!STRCMP(dict_key, "cmd")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1550 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1551 if (!STRCMP(dict_key, "kind")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1552 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1553 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1554 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1555 STRCPY(p, dict_key); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1556 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1557 STRCPY(p, ":"); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1558 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1559 STRCPY(p, tv->vval.v_string); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1560 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1561 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1562 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1563 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1564 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1565 // Add all matches because tagfunc should do filtering. |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1566 if (ga_grow(ga, 1) == OK) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1567 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1568 ((char_u **)(ga->ga_data))[ga->ga_len++] = mfp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1569 ++ntags; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1570 result = OK; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1571 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1572 else |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1573 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1574 vim_free(mfp); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1575 break; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1576 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1577 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1578 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1579 clear_tv(&rettv); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1580 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1581 *match_count = ntags; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1582 return result; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1583 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1584 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1585 |
7 | 1586 /* |
1587 * find_tags() - search for tags in tags files | |
1588 * | |
1589 * Return FAIL if search completely failed (*num_matches will be 0, *matchesp | |
1590 * will be NULL), OK otherwise. | |
1591 * | |
1592 * There is a priority in which type of tag is recognized. | |
1593 * | |
1594 * 6. A static or global tag with a full matching tag for the current file. | |
1595 * 5. A global tag with a full matching tag for another file. | |
1596 * 4. A static tag with a full matching tag for another file. | |
1597 * 3. A static or global tag with an ignore-case matching tag for the | |
1598 * current file. | |
1599 * 2. A global tag with an ignore-case matching tag for another file. | |
1600 * 1. A static tag with an ignore-case matching tag for another file. | |
1601 * | |
1602 * Tags in an emacs-style tags file are always global. | |
1603 * | |
1604 * flags: | |
1605 * TAG_HELP only search for help tags | |
1606 * TAG_NAMES only return name of tag | |
1607 * TAG_REGEXP use "pat" as a regexp | |
1608 * TAG_NOIC don't always ignore case | |
1609 * TAG_KEEP_LANG keep language | |
10666
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1610 * TAG_CSCOPE use cscope results for tags |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1611 * TAG_NO_TAGFUNC do not call the 'tagfunc' function |
7 | 1612 */ |
1613 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1614 find_tags( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1615 char_u *pat, // pattern to search for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1616 int *num_matches, // return: number of matches found |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1617 char_u ***matchesp, // return: array of matches found |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1618 int flags, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1619 int mincount, // MAXCOL: find all matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1620 // other: minimal number of matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1621 char_u *buf_ffname) // name of buffer for priority |
7 | 1622 { |
1623 FILE *fp; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1624 char_u *lbuf; // line buffer |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1625 int lbuf_size = LSIZE; // length of lbuf |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1626 char_u *tag_fname; // name of tag file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1627 tagname_T tn; // info for get_tagfname() |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1628 int first_file; // trying first tag file |
7 | 1629 tagptrs_T tagp; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1630 int did_open = FALSE; // did open a tag file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1631 int stop_searching = FALSE; // stop when match found or error |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1632 int retval = FAIL; // return value |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1633 int is_static; // current tag line is static |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1634 int is_current; // file name matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1635 int eof = FALSE; // found end-of-file |
7 | 1636 char_u *p; |
1637 char_u *s; | |
1638 int i; | |
1639 #ifdef FEAT_TAG_BINS | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1640 int tag_file_sorted = NUL; // !_TAG_FILE_SORTED value |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1641 struct tag_search_info // Binary search file offsets |
7 | 1642 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1643 off_T low_offset; // offset for first char of first line that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1644 // could match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1645 off_T high_offset; // offset of char after last line that could |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1646 // match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1647 off_T curr_offset; // Current file offset in search range |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1648 off_T curr_offset_used; // curr_offset used when skipping back |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1649 off_T match_offset; // Where the binary search found a tag |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1650 int low_char; // first char at low_offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1651 int high_char; // first char at high_offset |
7 | 1652 } search_info; |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
1653 off_T filesize; |
7 | 1654 int tagcmp; |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
1655 off_T offset; |
7 | 1656 int round; |
1657 #endif | |
1658 enum | |
1659 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1660 TS_START, // at start of file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1661 TS_LINEAR // linear searching forward, till EOF |
7 | 1662 #ifdef FEAT_TAG_BINS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1663 , TS_BINARY, // binary searching |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1664 TS_SKIP_BACK, // skipping backwards |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1665 TS_STEP_FORWARD // stepping forwards |
7 | 1666 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1667 } state; // Current search state |
7 | 1668 |
1669 int cmplen; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1670 int match; // matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1671 int match_no_ic = 0;// matches with rm_ic == FALSE |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1672 int match_re; // match with regexp |
7 | 1673 int matchoff = 0; |
5513 | 1674 int save_emsg_off; |
7 | 1675 |
1676 #ifdef FEAT_EMACS_TAGS | |
1677 /* | |
1678 * Stack for included emacs-tags file. | |
1679 * It has a fixed size, to truncate cyclic includes. jw | |
1680 */ | |
1681 # define INCSTACK_SIZE 42 | |
1682 struct | |
1683 { | |
1684 FILE *fp; | |
1685 char_u *etag_fname; | |
1686 } incstack[INCSTACK_SIZE]; | |
1687 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1688 int incstack_idx = 0; // index in incstack |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1689 char_u *ebuf; // additional buffer for etag fname |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1690 int is_etag; // current file is emaces style |
7 | 1691 #endif |
1692 | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
1693 char_u *mfp; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1694 garray_T ga_match[MT_COUNT]; // stores matches in sequence |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1695 hashtab_T ht_match[MT_COUNT]; // stores matches by key |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
1696 hash_T hash = 0; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1697 int match_count = 0; // number of matches found |
7 | 1698 char_u **matches; |
1699 int mtt; | |
1700 int help_save; | |
1701 #ifdef FEAT_MULTI_LANG | |
1702 int help_pri = 0; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1703 char_u *help_lang_find = NULL; // lang to be found |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1704 char_u help_lang[3]; // lang of current tags file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1705 char_u *saved_pat = NULL; // copy of pat[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1706 int is_txt = FALSE; // flag of file extension |
7 | 1707 #endif |
1708 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1709 pat_T orgpat; // holds unconverted pattern info |
7 | 1710 vimconv_T vimconv; |
1711 | |
1712 #ifdef FEAT_TAG_BINS | |
1713 int findall = (mincount == MAXCOL || mincount == TAG_MANY); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1714 // find all matching tags |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1715 int sort_error = FALSE; // tags file not sorted |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1716 int linear; // do a linear search |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1717 int sortic = FALSE; // tag file sorted in nocase |
7 | 1718 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1719 int line_error = FALSE; // syntax error |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1720 int has_re = (flags & TAG_REGEXP); // regexp used |
7 | 1721 int help_only = (flags & TAG_HELP); |
1722 int name_only = (flags & TAG_NAMES); | |
1723 int noic = (flags & TAG_NOIC); | |
1724 int get_it_again = FALSE; | |
1725 #ifdef FEAT_CSCOPE | |
1726 int use_cscope = (flags & TAG_CSCOPE); | |
1727 #endif | |
1728 int verbose = (flags & TAG_VERBOSE); | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1729 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1730 int use_tfu = ((flags & TAG_NO_TAGFUNC) == 0); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1731 #endif |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1732 int save_p_ic = p_ic; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1733 |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1734 /* |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1735 * Change the value of 'ignorecase' according to 'tagcase' for the |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1736 * duration of this function. |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1737 */ |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1738 switch (curbuf->b_tc_flags ? curbuf->b_tc_flags : tc_flags) |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1739 { |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1740 case TC_FOLLOWIC: break; |
9913
bb00c661b3a4
commit https://github.com/vim/vim/commit/66e29d7112e437b2b50efe1f82c7e892736d23e4
Christian Brabandt <cb@256bit.org>
parents:
9850
diff
changeset
|
1741 case TC_IGNORE: p_ic = TRUE; break; |
bb00c661b3a4
commit https://github.com/vim/vim/commit/66e29d7112e437b2b50efe1f82c7e892736d23e4
Christian Brabandt <cb@256bit.org>
parents:
9850
diff
changeset
|
1742 case TC_MATCH: p_ic = FALSE; break; |
bb00c661b3a4
commit https://github.com/vim/vim/commit/66e29d7112e437b2b50efe1f82c7e892736d23e4
Christian Brabandt <cb@256bit.org>
parents:
9850
diff
changeset
|
1743 case TC_FOLLOWSCS: p_ic = ignorecase(pat); break; |
bb00c661b3a4
commit https://github.com/vim/vim/commit/66e29d7112e437b2b50efe1f82c7e892736d23e4
Christian Brabandt <cb@256bit.org>
parents:
9850
diff
changeset
|
1744 case TC_SMART: p_ic = ignorecase_opt(pat, TRUE, TRUE); break; |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
1745 } |
7 | 1746 |
1747 help_save = curbuf->b_help; | |
1748 orgpat.pat = pat; | |
25587
35562f3207d1
patch 8.2.3330: Coverity reports using uninitialized field
Bram Moolenaar <Bram@vim.org>
parents:
25262
diff
changeset
|
1749 orgpat.regmatch.regprog = NULL; |
7 | 1750 vimconv.vc_type = CONV_NONE; |
1751 | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
1752 /* |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
1753 * Allocate memory for the buffers that are used |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
1754 */ |
3131 | 1755 lbuf = alloc(lbuf_size); |
7 | 1756 tag_fname = alloc(MAXPATHL + 1); |
1757 #ifdef FEAT_EMACS_TAGS | |
1758 ebuf = alloc(LSIZE); | |
1759 #endif | |
1760 for (mtt = 0; mtt < MT_COUNT; ++mtt) | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
1761 { |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
1762 ga_init2(&ga_match[mtt], (int)sizeof(char_u *), 100); |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
1763 hash_init(&ht_match[mtt]); |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
1764 } |
7 | 1765 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1766 // check for out of memory situation |
7 | 1767 if (lbuf == NULL || tag_fname == NULL |
1768 #ifdef FEAT_EMACS_TAGS | |
1769 || ebuf == NULL | |
1770 #endif | |
1771 ) | |
1772 goto findtag_end; | |
1773 | |
1774 #ifdef FEAT_CSCOPE | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1775 STRCPY(tag_fname, "from cscope"); // for error messages |
7 | 1776 #endif |
1777 | |
1778 /* | |
1779 * Initialize a few variables | |
1780 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1781 if (help_only) // want tags from help file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1782 curbuf->b_help = TRUE; // will be restored later |
10666
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1783 #ifdef FEAT_CSCOPE |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1784 else if (use_cscope) |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1785 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1786 // Make sure we don't mix help and cscope, confuses Coverity. |
10666
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1787 help_only = FALSE; |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1788 curbuf->b_help = FALSE; |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1789 } |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
1790 #endif |
7 | 1791 |
3131 | 1792 orgpat.len = (int)STRLEN(pat); |
7 | 1793 #ifdef FEAT_MULTI_LANG |
1794 if (curbuf->b_help) | |
1795 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1796 // When "@ab" is specified use only the "ab" language, otherwise |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1797 // search all languages. |
3131 | 1798 if (orgpat.len > 3 && pat[orgpat.len - 3] == '@' |
1799 && ASCII_ISALPHA(pat[orgpat.len - 2]) | |
1800 && ASCII_ISALPHA(pat[orgpat.len - 1])) | |
7 | 1801 { |
3131 | 1802 saved_pat = vim_strnsave(pat, orgpat.len - 3); |
7 | 1803 if (saved_pat != NULL) |
1804 { | |
3131 | 1805 help_lang_find = &pat[orgpat.len - 2]; |
1806 orgpat.pat = saved_pat; | |
1807 orgpat.len -= 3; | |
7 | 1808 } |
1809 } | |
1810 } | |
1811 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1812 if (p_tl != 0 && orgpat.len > p_tl) // adjust for 'taglength' |
3131 | 1813 orgpat.len = p_tl; |
1814 | |
5513 | 1815 save_emsg_off = emsg_off; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1816 emsg_off = TRUE; // don't want error for invalid RE here |
3131 | 1817 prepare_pats(&orgpat, has_re); |
5513 | 1818 emsg_off = save_emsg_off; |
3784 | 1819 if (has_re && orgpat.regmatch.regprog == NULL) |
1820 goto findtag_end; | |
7 | 1821 |
1822 #ifdef FEAT_TAG_BINS | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1823 // This is only to avoid a compiler warning for using search_info |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1824 // uninitialised. |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1825 CLEAR_FIELD(search_info); |
7 | 1826 #endif |
1827 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1828 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1829 if (*curbuf->b_p_tfu != NUL && use_tfu && !tfu_in_use) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1830 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1831 tfu_in_use = TRUE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1832 retval = find_tagfunc_tags(pat, &ga_match[0], &match_count, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1833 flags, buf_ffname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1834 tfu_in_use = FALSE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1835 if (retval != NOTDONE) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1836 goto findtag_end; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1837 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1838 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1839 |
413 | 1840 /* |
1841 * When finding a specified number of matches, first try with matching | |
1842 * case, so binary search can be used, and try ignore-case matches in a | |
1843 * second loop. | |
1844 * When finding all matches, 'tagbsearch' is off, or there is no fixed | |
1845 * string to look for, ignore case right away to avoid going though the | |
1846 * tags files twice. | |
1847 * When the tag file is case-fold sorted, it is either one or the other. | |
1848 * Only ignore case when TAG_NOIC not used or 'ignorecase' set. | |
1849 */ | |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1850 #ifdef FEAT_MULTI_LANG |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1851 // Set a flag if the file extension is .txt |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1852 if ((flags & TAG_KEEP_LANG) |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1853 && help_lang_find == NULL |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1854 && curbuf->b_fname != NULL |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1855 && (i = (int)STRLEN(curbuf->b_fname)) > 4 |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1856 && STRICMP(curbuf->b_fname + i - 4, ".txt") == 0) |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1857 is_txt = TRUE; |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1858 #endif |
7 | 1859 #ifdef FEAT_TAG_BINS |
3131 | 1860 orgpat.regmatch.rm_ic = ((p_ic || !noic) |
1861 && (findall || orgpat.headlen == 0 || !p_tbs)); | |
7 | 1862 for (round = 1; round <= 2; ++round) |
1863 { | |
3131 | 1864 linear = (orgpat.headlen == 0 || !p_tbs || round == 2); |
7 | 1865 #else |
3131 | 1866 orgpat.regmatch.rm_ic = (p_ic || !noic); |
7 | 1867 #endif |
1868 | |
1869 /* | |
1870 * Try tag file names from tags option one by one. | |
1871 */ | |
1872 for (first_file = TRUE; | |
1873 #ifdef FEAT_CSCOPE | |
1874 use_cscope || | |
1875 #endif | |
692 | 1876 get_tagfname(&tn, first_file, tag_fname) == OK; |
1877 first_file = FALSE) | |
7 | 1878 { |
1879 /* | |
1880 * A file that doesn't exist is silently ignored. Only when not a | |
1881 * single file is found, an error message is given (further on). | |
1882 */ | |
1883 #ifdef FEAT_CSCOPE | |
1884 if (use_cscope) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1885 fp = NULL; // avoid GCC warning |
7 | 1886 else |
1887 #endif | |
1888 { | |
1889 #ifdef FEAT_MULTI_LANG | |
1890 if (curbuf->b_help) | |
1891 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1892 // Keep en if the file extension is .txt |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1893 if (is_txt) |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1894 STRCPY(help_lang, "en"); |
7 | 1895 else |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1896 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1897 // Prefer help tags according to 'helplang'. Put the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1898 // two-letter language name in help_lang[]. |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1899 i = (int)STRLEN(tag_fname); |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1900 if (i > 3 && tag_fname[i - 3] == '-') |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1901 STRCPY(help_lang, tag_fname + i - 2); |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1902 else |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1903 STRCPY(help_lang, "en"); |
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
1904 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1905 // When searching for a specific language skip tags files |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1906 // for other languages. |
7 | 1907 if (help_lang_find != NULL |
1908 && STRICMP(help_lang, help_lang_find) != 0) | |
1909 continue; | |
1910 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1911 // For CTRL-] in a help file prefer a match with the same |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1912 // language. |
7 | 1913 if ((flags & TAG_KEEP_LANG) |
1914 && help_lang_find == NULL | |
1915 && curbuf->b_fname != NULL | |
835 | 1916 && (i = (int)STRLEN(curbuf->b_fname)) > 4 |
7 | 1917 && curbuf->b_fname[i - 1] == 'x' |
1918 && curbuf->b_fname[i - 4] == '.' | |
1919 && STRNICMP(curbuf->b_fname + i - 3, help_lang, 2) == 0) | |
1920 help_pri = 0; | |
1921 else | |
1922 { | |
1923 help_pri = 1; | |
1924 for (s = p_hlg; *s != NUL; ++s) | |
1925 { | |
1926 if (STRNICMP(s, help_lang, 2) == 0) | |
1927 break; | |
1928 ++help_pri; | |
1929 if ((s = vim_strchr(s, ',')) == NULL) | |
1930 break; | |
1931 } | |
1932 if (s == NULL || *s == NUL) | |
1933 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1934 // Language not in 'helplang': use last, prefer English, |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1935 // unless found already. |
7 | 1936 ++help_pri; |
1937 if (STRICMP(help_lang, "en") != 0) | |
1938 ++help_pri; | |
1939 } | |
1940 } | |
1941 } | |
1942 #endif | |
1943 | |
1944 if ((fp = mch_fopen((char *)tag_fname, "r")) == NULL) | |
1945 continue; | |
1946 | |
1947 if (p_verbose >= 5) | |
292 | 1948 { |
1949 verbose_enter(); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1950 smsg(_("Searching tags file %s"), tag_fname); |
292 | 1951 verbose_leave(); |
1952 } | |
7 | 1953 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1954 did_open = TRUE; // remember that we found at least one file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1955 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1956 state = TS_START; // we're at the start of the file |
7 | 1957 #ifdef FEAT_EMACS_TAGS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1958 is_etag = 0; // default is: not emacs style |
7 | 1959 #endif |
1960 | |
1961 /* | |
1962 * Read and parse the lines in the file one by one | |
1963 */ | |
1964 for (;;) | |
1965 { | |
10134
95e9be4bc490
commit https://github.com/vim/vim/commit/7947312871e7d01cdba058199904c212ec32f1c0
Christian Brabandt <cb@256bit.org>
parents:
10132
diff
changeset
|
1966 #ifdef FEAT_TAG_BINS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1967 // check for CTRL-C typed, more often when jumping around |
10128
98ddc760e8d5
commit https://github.com/vim/vim/commit/72b4b870fcc445c14faf282e0595b5f9406b101d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1968 if (state == TS_BINARY || state == TS_SKIP_BACK) |
98ddc760e8d5
commit https://github.com/vim/vim/commit/72b4b870fcc445c14faf282e0595b5f9406b101d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1969 line_breakcheck(); |
98ddc760e8d5
commit https://github.com/vim/vim/commit/72b4b870fcc445c14faf282e0595b5f9406b101d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1970 else |
10134
95e9be4bc490
commit https://github.com/vim/vim/commit/7947312871e7d01cdba058199904c212ec32f1c0
Christian Brabandt <cb@256bit.org>
parents:
10132
diff
changeset
|
1971 #endif |
10128
98ddc760e8d5
commit https://github.com/vim/vim/commit/72b4b870fcc445c14faf282e0595b5f9406b101d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1972 fast_breakcheck(); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1973 if ((flags & TAG_INS_COMP)) // Double brackets for gcc |
10277
154d5a2e7395
commit https://github.com/vim/vim/commit/472e85970ee3a80abd824bef510df12e9cfe9e96
Christian Brabandt <cb@256bit.org>
parents:
10134
diff
changeset
|
1974 ins_compl_check_keys(30, FALSE); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
16070
diff
changeset
|
1975 if (got_int || ins_compl_interrupted()) |
7 | 1976 { |
1977 stop_searching = TRUE; | |
1978 break; | |
1979 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1980 // When mincount is TAG_MANY, stop when enough matches have been |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1981 // found (for completion). |
7 | 1982 if (mincount == TAG_MANY && match_count >= TAG_MANY) |
1983 { | |
1984 stop_searching = TRUE; | |
1985 retval = OK; | |
1986 break; | |
1987 } | |
1988 if (get_it_again) | |
1989 goto line_read_in; | |
1990 #ifdef FEAT_TAG_BINS | |
1991 /* | |
1992 * For binary search: compute the next offset to use. | |
1993 */ | |
1994 if (state == TS_BINARY) | |
1995 { | |
1996 offset = search_info.low_offset + ((search_info.high_offset | |
1997 - search_info.low_offset) / 2); | |
1998 if (offset == search_info.curr_offset) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1999 break; // End the binary search without a match. |
7 | 2000 else |
2001 search_info.curr_offset = offset; | |
2002 } | |
2003 | |
2004 /* | |
2005 * Skipping back (after a match during binary search). | |
2006 */ | |
2007 else if (state == TS_SKIP_BACK) | |
2008 { | |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2009 search_info.curr_offset -= lbuf_size * 2; |
7 | 2010 if (search_info.curr_offset < 0) |
2011 { | |
2012 search_info.curr_offset = 0; | |
2013 rewind(fp); | |
2014 state = TS_STEP_FORWARD; | |
2015 } | |
2016 } | |
2017 | |
2018 /* | |
2019 * When jumping around in the file, first read a line to find the | |
2020 * start of the next line. | |
2021 */ | |
2022 if (state == TS_BINARY || state == TS_SKIP_BACK) | |
2023 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2024 // Adjust the search file offset to the correct position |
7 | 2025 search_info.curr_offset_used = search_info.curr_offset; |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2026 vim_fseek(fp, search_info.curr_offset, SEEK_SET); |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2027 eof = vim_fgets(lbuf, lbuf_size, fp); |
7 | 2028 if (!eof && search_info.curr_offset != 0) |
2029 { | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2030 search_info.curr_offset = vim_ftell(fp); |
7 | 2031 if (search_info.curr_offset == search_info.high_offset) |
2032 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2033 // oops, gone a bit too far; try from low offset |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2034 vim_fseek(fp, search_info.low_offset, SEEK_SET); |
7 | 2035 search_info.curr_offset = search_info.low_offset; |
2036 } | |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2037 eof = vim_fgets(lbuf, lbuf_size, fp); |
7 | 2038 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2039 // skip empty and blank lines |
7 | 2040 while (!eof && vim_isblankline(lbuf)) |
2041 { | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2042 search_info.curr_offset = vim_ftell(fp); |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2043 eof = vim_fgets(lbuf, lbuf_size, fp); |
7 | 2044 } |
2045 if (eof) | |
2046 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2047 // Hit end of file. Skip backwards. |
7 | 2048 state = TS_SKIP_BACK; |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2049 search_info.match_offset = vim_ftell(fp); |
7 | 2050 search_info.curr_offset = search_info.curr_offset_used; |
2051 continue; | |
2052 } | |
2053 } | |
2054 | |
2055 /* | |
2056 * Not jumping around in the file: Read the next line. | |
2057 */ | |
2058 else | |
2059 #endif | |
2060 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2061 // skip empty and blank lines |
7 | 2062 do |
2063 { | |
2064 #ifdef FEAT_CSCOPE | |
2065 if (use_cscope) | |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2066 eof = cs_fgets(lbuf, lbuf_size); |
7 | 2067 else |
2068 #endif | |
26492
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2069 { |
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2070 search_info.curr_offset = vim_ftell(fp); |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2071 eof = vim_fgets(lbuf, lbuf_size, fp); |
26492
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2072 } |
7 | 2073 } while (!eof && vim_isblankline(lbuf)); |
2074 | |
2075 if (eof) | |
2076 { | |
2077 #ifdef FEAT_EMACS_TAGS | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2078 if (incstack_idx) // this was an included file |
7 | 2079 { |
2080 --incstack_idx; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2081 fclose(fp); // end of this file ... |
7 | 2082 fp = incstack[incstack_idx].fp; |
2083 STRCPY(tag_fname, incstack[incstack_idx].etag_fname); | |
2084 vim_free(incstack[incstack_idx].etag_fname); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2085 is_etag = 1; // (only etags can include) |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2086 continue; // ... continue with parent file |
7 | 2087 } |
2088 else | |
2089 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2090 break; // end of file |
7 | 2091 } |
2092 } | |
2093 line_read_in: | |
2094 | |
3131 | 2095 if (vimconv.vc_type != CONV_NONE) |
2096 { | |
2097 char_u *conv_line; | |
2098 int len; | |
2099 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2100 // Convert every line. Converting the pattern from 'enc' to |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2101 // the tags file encoding doesn't work, because characters are |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2102 // not recognized. |
3131 | 2103 conv_line = string_convert(&vimconv, lbuf, NULL); |
2104 if (conv_line != NULL) | |
2105 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2106 // Copy or swap lbuf and conv_line. |
3131 | 2107 len = (int)STRLEN(conv_line) + 1; |
2108 if (len > lbuf_size) | |
2109 { | |
2110 vim_free(lbuf); | |
2111 lbuf = conv_line; | |
2112 lbuf_size = len; | |
2113 } | |
2114 else | |
2115 { | |
2116 STRCPY(lbuf, conv_line); | |
2117 vim_free(conv_line); | |
2118 } | |
2119 } | |
2120 } | |
2121 | |
2122 | |
7 | 2123 #ifdef FEAT_EMACS_TAGS |
2124 /* | |
2125 * Emacs tags line with CTRL-L: New file name on next line. | |
2126 * The file name is followed by a ','. | |
10650
5ca7e3ec1263
patch 8.0.0215: NULL pointer use if cscope line looks like emacs tag
Christian Brabandt <cb@256bit.org>
parents:
10611
diff
changeset
|
2127 * Remember etag file name in ebuf. |
7 | 2128 */ |
10654
f0df81ef971a
patch 8.0.0217: build fails without cscope feature
Christian Brabandt <cb@256bit.org>
parents:
10650
diff
changeset
|
2129 if (*lbuf == Ctrl_L |
f0df81ef971a
patch 8.0.0217: build fails without cscope feature
Christian Brabandt <cb@256bit.org>
parents:
10650
diff
changeset
|
2130 # ifdef FEAT_CSCOPE |
f0df81ef971a
patch 8.0.0217: build fails without cscope feature
Christian Brabandt <cb@256bit.org>
parents:
10650
diff
changeset
|
2131 && !use_cscope |
f0df81ef971a
patch 8.0.0217: build fails without cscope feature
Christian Brabandt <cb@256bit.org>
parents:
10650
diff
changeset
|
2132 # endif |
f0df81ef971a
patch 8.0.0217: build fails without cscope feature
Christian Brabandt <cb@256bit.org>
parents:
10650
diff
changeset
|
2133 ) |
7 | 2134 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2135 is_etag = 1; // in case at the start |
7 | 2136 state = TS_LINEAR; |
15840
734b1928a5aa
patch 8.1.0927: USE_CR is never defined
Bram Moolenaar <Bram@vim.org>
parents:
15808
diff
changeset
|
2137 if (!vim_fgets(ebuf, LSIZE, fp)) |
7 | 2138 { |
2139 for (p = ebuf; *p && *p != ','; p++) | |
2140 ; | |
2141 *p = NUL; | |
2142 | |
2143 /* | |
2144 * atoi(p+1) is the number of bytes before the next ^L | |
2145 * unless it is an include statement. | |
2146 */ | |
2147 if (STRNCMP(p + 1, "include", 7) == 0 | |
2148 && incstack_idx < INCSTACK_SIZE) | |
2149 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2150 // Save current "fp" and "tag_fname" in the stack. |
7 | 2151 if ((incstack[incstack_idx].etag_fname = |
2152 vim_strsave(tag_fname)) != NULL) | |
2153 { | |
2154 char_u *fullpath_ebuf; | |
2155 | |
2156 incstack[incstack_idx].fp = fp; | |
2157 fp = NULL; | |
2158 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2159 // Figure out "tag_fname" and "fp" to use for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2160 // included file. |
7 | 2161 fullpath_ebuf = expand_tag_fname(ebuf, |
2162 tag_fname, FALSE); | |
2163 if (fullpath_ebuf != NULL) | |
2164 { | |
2165 fp = mch_fopen((char *)fullpath_ebuf, "r"); | |
2166 if (fp != NULL) | |
2167 { | |
2168 if (STRLEN(fullpath_ebuf) > LSIZE) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2169 semsg(_("E430: Tag file path truncated for %s\n"), ebuf); |
418 | 2170 vim_strncpy(tag_fname, fullpath_ebuf, |
2171 MAXPATHL); | |
7 | 2172 ++incstack_idx; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2173 is_etag = 0; // we can include anything |
7 | 2174 } |
2175 vim_free(fullpath_ebuf); | |
2176 } | |
2177 if (fp == NULL) | |
2178 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2179 // Can't open the included file, skip it and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2180 // restore old value of "fp". |
7 | 2181 fp = incstack[incstack_idx].fp; |
2182 vim_free(incstack[incstack_idx].etag_fname); | |
2183 } | |
2184 } | |
2185 } | |
2186 } | |
2187 continue; | |
2188 } | |
2189 #endif | |
2190 | |
2191 /* | |
2192 * When still at the start of the file, check for Emacs tags file | |
2193 * format, and for "not sorted" flag. | |
2194 */ | |
2195 if (state == TS_START) | |
2196 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2197 // The header ends when the line sorts below "!_TAG_". When |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2198 // case is folded lower case letters sort before "_". |
4914
1707ddb6f5ae
updated for version 7.3.1202
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2199 if (STRNCMP(lbuf, "!_TAG_", 6) <= 0 |
1707ddb6f5ae
updated for version 7.3.1202
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2200 || (lbuf[0] == '!' && ASCII_ISLOWER(lbuf[1]))) |
3131 | 2201 { |
5328 | 2202 if (STRNCMP(lbuf, "!_TAG_", 6) != 0) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2203 // Non-header item before the header, e.g. "!" itself. |
5328 | 2204 goto parse_line; |
2205 | |
3131 | 2206 /* |
2207 * Read header line. | |
2208 */ | |
2209 #ifdef FEAT_TAG_BINS | |
2210 if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0) | |
2211 tag_file_sorted = lbuf[18]; | |
2212 #endif | |
2213 if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) | |
2214 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2215 // Prepare to convert every line from the specified |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2216 // encoding to 'encoding'. |
3131 | 2217 for (p = lbuf + 20; *p > ' ' && *p < 127; ++p) |
2218 ; | |
2219 *p = NUL; | |
2220 convert_setup(&vimconv, lbuf + 20, p_enc); | |
2221 } | |
2222 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2223 // Read the next line. Unrecognized flags are ignored. |
3131 | 2224 continue; |
2225 } | |
2226 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2227 // Headers ends. |
3131 | 2228 |
7 | 2229 #ifdef FEAT_TAG_BINS |
2230 /* | |
2231 * When there is no tag head, or ignoring case, need to do a | |
2232 * linear search. | |
2233 * When no "!_TAG_" is found, default to binary search. If | |
2234 * the tag file isn't sorted, the second loop will find it. | |
2235 * When "!_TAG_FILE_SORTED" found: start binary search if | |
2236 * flag set. | |
2237 * For cscope, it's always linear. | |
2238 */ | |
2239 # ifdef FEAT_CSCOPE | |
2240 if (linear || use_cscope) | |
2241 # else | |
2242 if (linear) | |
2243 # endif | |
2244 state = TS_LINEAR; | |
3131 | 2245 else if (tag_file_sorted == NUL) |
7 | 2246 state = TS_BINARY; |
3131 | 2247 else if (tag_file_sorted == '1') |
7 | 2248 state = TS_BINARY; |
3131 | 2249 else if (tag_file_sorted == '2') |
2250 { | |
2251 state = TS_BINARY; | |
2252 sortic = TRUE; | |
2253 orgpat.regmatch.rm_ic = (p_ic || !noic); | |
7 | 2254 } |
3131 | 2255 else |
2256 state = TS_LINEAR; | |
2257 | |
2258 if (state == TS_BINARY && orgpat.regmatch.rm_ic && !sortic) | |
7 | 2259 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2260 // Binary search won't work for ignoring case, use linear |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2261 // search. |
7 | 2262 linear = TRUE; |
2263 state = TS_LINEAR; | |
2264 } | |
2265 #else | |
2266 state = TS_LINEAR; | |
2267 #endif | |
2268 | |
2269 #ifdef FEAT_TAG_BINS | |
18315
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2270 // When starting a binary search, get the size of the file and |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2271 // compute the first offset. |
7 | 2272 if (state == TS_BINARY) |
2273 { | |
18315
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2274 if (vim_fseek(fp, 0L, SEEK_END) != 0) |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2275 // can't seek, don't use binary search |
7 | 2276 state = TS_LINEAR; |
2277 else | |
2278 { | |
18315
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2279 // Get the tag file size (don't use mch_fstat(), it's |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2280 // not portable). Don't use lseek(), it doesn't work |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2281 // properly on MacOS Catalina. |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2282 filesize = vim_ftell(fp); |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2283 vim_fseek(fp, 0L, SEEK_SET); |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2284 |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2285 // Calculate the first read offset in the file. Start |
6e8b7c58c526
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2286 // the search in the middle of the file. |
7 | 2287 search_info.low_offset = 0; |
2288 search_info.low_char = 0; | |
2289 search_info.high_offset = filesize; | |
2290 search_info.curr_offset = 0; | |
2291 search_info.high_char = 0xff; | |
2292 } | |
2293 continue; | |
2294 } | |
2295 #endif | |
2296 } | |
2297 | |
5328 | 2298 parse_line: |
16190
d863beec391a
patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents:
16188
diff
changeset
|
2299 // When the line is too long the NUL will not be in the |
d863beec391a
patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents:
16188
diff
changeset
|
2300 // last-but-one byte (see vim_fgets()). |
d863beec391a
patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents:
16188
diff
changeset
|
2301 // Has been reported for Mozilla JS with extremely long names. |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2302 // In that case we need to increase lbuf_size. |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2303 if (lbuf[lbuf_size - 2] != NUL |
16178
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2304 #ifdef FEAT_CSCOPE |
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2305 && !use_cscope |
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2306 #endif |
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2307 ) |
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2308 { |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2309 lbuf_size *= 2; |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2310 vim_free(lbuf); |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2311 lbuf = alloc(lbuf_size); |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2312 if (lbuf == NULL) |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2313 goto findtag_end; |
26492
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2314 |
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2315 if (state == TS_STEP_FORWARD) |
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2316 // Seek to the same position to read the same line again |
08e3eee541ac
patch 8.2.3776: when a tags file line is long a tag may not be found
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
2317 vim_fseek(fp, search_info.curr_offset, SEEK_SET); |
18554
60c46cd053db
patch 8.1.2271: build error if FEAT_TAG_BINS is not defined
Bram Moolenaar <Bram@vim.org>
parents:
18550
diff
changeset
|
2318 #ifdef FEAT_TAG_BINS |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2319 // this will try the same thing again, make sure the offset is |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2320 // different |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2321 search_info.curr_offset = 0; |
18554
60c46cd053db
patch 8.1.2271: build error if FEAT_TAG_BINS is not defined
Bram Moolenaar <Bram@vim.org>
parents:
18550
diff
changeset
|
2322 #endif |
16178
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2323 continue; |
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2324 } |
a8689ea2e869
patch 8.1.1094: long line in tags file causes error
Bram Moolenaar <Bram@vim.org>
parents:
16176
diff
changeset
|
2325 |
7 | 2326 /* |
2327 * Figure out where the different strings are in this line. | |
2328 * For "normal" tags: Do a quick check if the tag matches. | |
2329 * This speeds up tag searching a lot! | |
2330 */ | |
3131 | 2331 if (orgpat.headlen |
7 | 2332 #ifdef FEAT_EMACS_TAGS |
2333 && !is_etag | |
2334 #endif | |
2335 ) | |
2336 { | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2337 CLEAR_FIELD(tagp); |
7 | 2338 tagp.tagname = lbuf; |
2339 tagp.tagname_end = vim_strchr(lbuf, TAB); | |
3192 | 2340 if (tagp.tagname_end == NULL) |
7 | 2341 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2342 // Corrupted tag line. |
7 | 2343 line_error = TRUE; |
2344 break; | |
2345 } | |
2346 | |
2347 /* | |
2348 * Skip this line if the length of the tag is different and | |
2349 * there is no regexp, or the tag is too short. | |
2350 */ | |
2351 cmplen = (int)(tagp.tagname_end - tagp.tagname); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2352 if (p_tl != 0 && cmplen > p_tl) // adjust for 'taglength' |
7 | 2353 cmplen = p_tl; |
3131 | 2354 if (has_re && orgpat.headlen < cmplen) |
2355 cmplen = orgpat.headlen; | |
2356 else if (state == TS_LINEAR && orgpat.headlen != cmplen) | |
7 | 2357 continue; |
2358 | |
2359 #ifdef FEAT_TAG_BINS | |
2360 if (state == TS_BINARY) | |
2361 { | |
2362 /* | |
2363 * Simplistic check for unsorted tags file. | |
2364 */ | |
2365 i = (int)tagp.tagname[0]; | |
2366 if (sortic) | |
2367 i = (int)TOUPPER_ASC(tagp.tagname[0]); | |
2368 if (i < search_info.low_char || i > search_info.high_char) | |
2369 sort_error = TRUE; | |
2370 | |
2371 /* | |
2372 * Compare the current tag with the searched tag. | |
2373 */ | |
2374 if (sortic) | |
3131 | 2375 tagcmp = tag_strnicmp(tagp.tagname, orgpat.head, |
7 | 2376 (size_t)cmplen); |
2377 else | |
3131 | 2378 tagcmp = STRNCMP(tagp.tagname, orgpat.head, cmplen); |
7 | 2379 |
2380 /* | |
2381 * A match with a shorter tag means to search forward. | |
2382 * A match with a longer tag means to search backward. | |
2383 */ | |
2384 if (tagcmp == 0) | |
2385 { | |
3131 | 2386 if (cmplen < orgpat.headlen) |
7 | 2387 tagcmp = -1; |
3131 | 2388 else if (cmplen > orgpat.headlen) |
7 | 2389 tagcmp = 1; |
2390 } | |
2391 | |
2392 if (tagcmp == 0) | |
2393 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2394 // We've located the tag, now skip back and search |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2395 // forward until the first matching tag is found. |
7 | 2396 state = TS_SKIP_BACK; |
2397 search_info.match_offset = search_info.curr_offset; | |
2398 continue; | |
2399 } | |
2400 if (tagcmp < 0) | |
2401 { | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2402 search_info.curr_offset = vim_ftell(fp); |
7 | 2403 if (search_info.curr_offset < search_info.high_offset) |
2404 { | |
2405 search_info.low_offset = search_info.curr_offset; | |
2406 if (sortic) | |
2407 search_info.low_char = | |
2408 TOUPPER_ASC(tagp.tagname[0]); | |
2409 else | |
2410 search_info.low_char = tagp.tagname[0]; | |
2411 continue; | |
2412 } | |
2413 } | |
2414 if (tagcmp > 0 | |
2415 && search_info.curr_offset != search_info.high_offset) | |
2416 { | |
2417 search_info.high_offset = search_info.curr_offset; | |
2418 if (sortic) | |
2419 search_info.high_char = | |
2420 TOUPPER_ASC(tagp.tagname[0]); | |
2421 else | |
2422 search_info.high_char = tagp.tagname[0]; | |
2423 continue; | |
2424 } | |
2425 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2426 // No match yet and are at the end of the binary search. |
7 | 2427 break; |
2428 } | |
2429 else if (state == TS_SKIP_BACK) | |
2430 { | |
3131 | 2431 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0) |
7 | 2432 state = TS_STEP_FORWARD; |
2433 else | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2434 // Have to skip back more. Restore the curr_offset |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2435 // used, otherwise we get stuck at a long line. |
7 | 2436 search_info.curr_offset = search_info.curr_offset_used; |
2437 continue; | |
2438 } | |
2439 else if (state == TS_STEP_FORWARD) | |
2440 { | |
3131 | 2441 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0) |
7 | 2442 { |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9068
diff
changeset
|
2443 if ((off_T)vim_ftell(fp) > search_info.match_offset) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2444 break; // past last match |
7 | 2445 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2446 continue; // before first match |
7 | 2447 } |
2448 } | |
2449 else | |
2450 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2451 // skip this match if it can't match |
3131 | 2452 if (MB_STRNICMP(tagp.tagname, orgpat.head, cmplen) != 0) |
7 | 2453 continue; |
2454 | |
2455 /* | |
2456 * Can be a matching tag, isolate the file name and command. | |
2457 */ | |
16176
4d7ee5609652
patch 8.1.1093: support for outdated tags format slows down tag parsing
Bram Moolenaar <Bram@vim.org>
parents:
16164
diff
changeset
|
2458 tagp.fname = tagp.tagname_end + 1; |
7 | 2459 tagp.fname_end = vim_strchr(tagp.fname, TAB); |
2460 tagp.command = tagp.fname_end + 1; | |
2461 if (tagp.fname_end == NULL) | |
2462 i = FAIL; | |
2463 else | |
2464 i = OK; | |
2465 } | |
2466 else | |
2467 i = parse_tag_line(lbuf, | |
2468 #ifdef FEAT_EMACS_TAGS | |
2469 is_etag, | |
2470 #endif | |
2471 &tagp); | |
2472 if (i == FAIL) | |
2473 { | |
2474 line_error = TRUE; | |
2475 break; | |
2476 } | |
2477 | |
2478 #ifdef FEAT_EMACS_TAGS | |
2479 if (is_etag) | |
2480 tagp.fname = ebuf; | |
2481 #endif | |
2482 /* | |
2483 * First try matching with the pattern literally (also when it is | |
2484 * a regexp). | |
2485 */ | |
2486 cmplen = (int)(tagp.tagname_end - tagp.tagname); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2487 if (p_tl != 0 && cmplen > p_tl) // adjust for 'taglength' |
7 | 2488 cmplen = p_tl; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2489 // if tag length does not match, don't try comparing |
3131 | 2490 if (orgpat.len != cmplen) |
7 | 2491 match = FALSE; |
2492 else | |
2493 { | |
3131 | 2494 if (orgpat.regmatch.rm_ic) |
7 | 2495 { |
3131 | 2496 match = (MB_STRNICMP(tagp.tagname, orgpat.pat, cmplen) == 0); |
7 | 2497 if (match) |
3131 | 2498 match_no_ic = (STRNCMP(tagp.tagname, orgpat.pat, |
7 | 2499 cmplen) == 0); |
2500 } | |
2501 else | |
3131 | 2502 match = (STRNCMP(tagp.tagname, orgpat.pat, cmplen) == 0); |
7 | 2503 } |
2504 | |
2505 /* | |
2506 * Has a regexp: Also find tags matching regexp. | |
2507 */ | |
2508 match_re = FALSE; | |
3131 | 2509 if (!match && orgpat.regmatch.regprog != NULL) |
7 | 2510 { |
2511 int cc; | |
2512 | |
2513 cc = *tagp.tagname_end; | |
2514 *tagp.tagname_end = NUL; | |
3131 | 2515 match = vim_regexec(&orgpat.regmatch, tagp.tagname, (colnr_T)0); |
7 | 2516 if (match) |
2517 { | |
3131 | 2518 matchoff = (int)(orgpat.regmatch.startp[0] - tagp.tagname); |
2519 if (orgpat.regmatch.rm_ic) | |
7 | 2520 { |
3131 | 2521 orgpat.regmatch.rm_ic = FALSE; |
2522 match_no_ic = vim_regexec(&orgpat.regmatch, tagp.tagname, | |
7 | 2523 (colnr_T)0); |
3131 | 2524 orgpat.regmatch.rm_ic = TRUE; |
7 | 2525 } |
2526 } | |
2527 *tagp.tagname_end = cc; | |
2528 match_re = TRUE; | |
2529 } | |
2530 | |
2531 /* | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2532 * If a match is found, add it to ht_match[] and ga_match[]. |
7 | 2533 */ |
2534 if (match) | |
2535 { | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2536 int len = 0; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2537 |
7 | 2538 #ifdef FEAT_CSCOPE |
2539 if (use_cscope) | |
2540 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2541 // Don't change the ordering, always use the same table. |
7 | 2542 mtt = MT_GL_OTH; |
2543 } | |
2544 else | |
2545 #endif | |
2546 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2547 // Decide in which array to store this match. |
7 | 2548 is_current = test_for_current( |
2549 #ifdef FEAT_EMACS_TAGS | |
2550 is_etag, | |
2551 #endif | |
2552 tagp.fname, tagp.fname_end, tag_fname, | |
2553 buf_ffname); | |
2554 #ifdef FEAT_EMACS_TAGS | |
2555 is_static = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2556 if (!is_etag) // emacs tags are never static |
7 | 2557 #endif |
16176
4d7ee5609652
patch 8.1.1093: support for outdated tags format slows down tag parsing
Bram Moolenaar <Bram@vim.org>
parents:
16164
diff
changeset
|
2558 is_static = test_for_static(&tagp); |
7 | 2559 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2560 // decide in which of the sixteen tables to store this |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2561 // match |
7 | 2562 if (is_static) |
2563 { | |
2564 if (is_current) | |
2565 mtt = MT_ST_CUR; | |
2566 else | |
2567 mtt = MT_ST_OTH; | |
2568 } | |
2569 else | |
2570 { | |
2571 if (is_current) | |
2572 mtt = MT_GL_CUR; | |
2573 else | |
2574 mtt = MT_GL_OTH; | |
2575 } | |
3131 | 2576 if (orgpat.regmatch.rm_ic && !match_no_ic) |
7 | 2577 mtt += MT_IC_OFF; |
2578 if (match_re) | |
2579 mtt += MT_RE_OFF; | |
2580 } | |
2581 | |
2582 /* | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2583 * Add the found match in ht_match[mtt] and ga_match[mtt]. |
7 | 2584 * Store the info we need later, which depends on the kind of |
2585 * tags we are dealing with. | |
2586 */ | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2587 if (help_only) |
7 | 2588 { |
2589 #ifdef FEAT_MULTI_LANG | |
2590 # define ML_EXTRA 3 | |
2591 #else | |
2592 # define ML_EXTRA 0 | |
2593 #endif | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2594 /* |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2595 * Append the help-heuristic number after the tagname, for |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2596 * sorting it later. The heuristic is ignored for |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2597 * detecting duplicates. |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2598 * The format is {tagname}@{lang}NUL{heuristic}NUL |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2599 */ |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2600 *tagp.tagname_end = NUL; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2601 len = (int)(tagp.tagname_end - tagp.tagname); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2602 mfp = alloc(sizeof(char_u) + len + 10 + ML_EXTRA + 1); |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2603 if (mfp != NULL) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2604 { |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2605 int heuristic; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2606 |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2607 p = mfp; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2608 STRCPY(p, tagp.tagname); |
7 | 2609 #ifdef FEAT_MULTI_LANG |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2610 p[len] = '@'; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2611 STRCPY(p + len + 1, help_lang); |
7 | 2612 #endif |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2613 |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2614 heuristic = help_heuristic(tagp.tagname, |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2615 match_re ? matchoff : 0, !match_no_ic); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2616 #ifdef FEAT_MULTI_LANG |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2617 heuristic += help_pri; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2618 #endif |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2619 sprintf((char *)p + len + 1 + ML_EXTRA, "%06d", |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2620 heuristic); |
7 | 2621 } |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2622 *tagp.tagname_end = TAB; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2623 } |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2624 else if (name_only) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2625 { |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2626 if (get_it_again) |
7 | 2627 { |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2628 char_u *temp_end = tagp.command; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2629 |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2630 if (*temp_end == '/') |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2631 while (*temp_end && *temp_end != '\r' |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2632 && *temp_end != '\n' |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2633 && *temp_end != '$') |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2634 temp_end++; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2635 |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2636 if (tagp.command + 2 < temp_end) |
7 | 2637 { |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2638 len = (int)(temp_end - tagp.command - 2); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2639 mfp = alloc(len + 2); |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2640 if (mfp != NULL) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2641 vim_strncpy(mfp, tagp.command + 2, len); |
7 | 2642 } |
2643 else | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2644 mfp = NULL; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2645 get_it_again = FALSE; |
7 | 2646 } |
2647 else | |
2648 { | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2649 len = (int)(tagp.tagname_end - tagp.tagname); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2650 mfp = alloc(sizeof(char_u) + len + 1); |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2651 if (mfp != NULL) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2652 vim_strncpy(mfp, tagp.tagname, len); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2653 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2654 // if wanted, re-read line to get long form too |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2655 if (State & INSERT) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2656 get_it_again = p_sft; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2657 } |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2658 } |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2659 else |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2660 { |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2661 size_t tag_fname_len = STRLEN(tag_fname); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2662 #ifdef FEAT_EMACS_TAGS |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2663 size_t ebuf_len = 0; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2664 #endif |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2665 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2666 // Save the tag in a buffer. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2667 // Use 0x02 to separate fields (Can't use NUL because the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2668 // hash key is terminated by NUL, or Ctrl_A because that is |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2669 // part of some Emacs tag files -- see parse_tag_line). |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2670 // Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL> |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2671 // other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL> |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2672 // without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL> |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2673 // Here <mtt> is the "mtt" value plus 1 to avoid NUL. |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2674 len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2675 #ifdef FEAT_EMACS_TAGS |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2676 if (is_etag) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2677 { |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2678 ebuf_len = STRLEN(ebuf); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2679 len += (int)ebuf_len + 1; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2680 } |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2681 else |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2682 ++len; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2683 #endif |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2684 mfp = alloc(sizeof(char_u) + len + 1); |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2685 if (mfp != NULL) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2686 { |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2687 p = mfp; |
10611
6bff81438f27
patch 8.0.0195: fail to jump to static tag in current file
Christian Brabandt <cb@256bit.org>
parents:
10601
diff
changeset
|
2688 p[0] = mtt + 1; |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2689 STRCPY(p + 1, tag_fname); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2690 #ifdef BACKSLASH_IN_FILENAME |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2691 // Ignore differences in slashes, avoid adding |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2692 // both path/file and path\file. |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2693 slash_adjust(p + 1); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2694 #endif |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2695 p[tag_fname_len + 1] = TAG_SEP; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2696 s = p + 1 + tag_fname_len + 1; |
7 | 2697 #ifdef FEAT_EMACS_TAGS |
2698 if (is_etag) | |
2699 { | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2700 STRCPY(s, ebuf); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2701 s[ebuf_len] = TAG_SEP; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2702 s += ebuf_len + 1; |
7 | 2703 } |
2704 else | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2705 *s++ = TAG_SEP; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2706 #endif |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2707 STRCPY(s, lbuf); |
7 | 2708 } |
2709 } | |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2710 |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2711 if (mfp != NULL) |
7 | 2712 { |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2713 hashitem_T *hi; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2714 |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2715 /* |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2716 * Don't add identical matches. |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2717 * Add all cscope tags, because they are all listed. |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2718 * "mfp" is used as a hash key, there is a NUL byte to end |
16378
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16190
diff
changeset
|
2719 * the part that matters for comparing, more bytes may |
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16190
diff
changeset
|
2720 * follow after it. E.g. help tags store the priority |
3d6b282e2d6e
patch 8.1.1194: typos and small problems in source files
Bram Moolenaar <Bram@vim.org>
parents:
16190
diff
changeset
|
2721 * after the NUL. |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2722 */ |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2723 #ifdef FEAT_CSCOPE |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2724 if (use_cscope) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2725 hash++; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2726 else |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2727 #endif |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2728 hash = hash_hash(mfp); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2729 hi = hash_lookup(&ht_match[mtt], mfp, hash); |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2730 if (HASHITEM_EMPTY(hi)) |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2731 { |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2732 if (hash_add_item(&ht_match[mtt], hi, mfp, hash) |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2733 == FAIL |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2734 || ga_grow(&ga_match[mtt], 1) != OK) |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2735 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2736 // Out of memory! Just forget about the rest. |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2737 retval = OK; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2738 stop_searching = TRUE; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2739 break; |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2740 } |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2741 else |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2742 { |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2743 ((char_u **)(ga_match[mtt].ga_data)) |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2744 [ga_match[mtt].ga_len++] = mfp; |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2745 ++match_count; |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2746 } |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2747 } |
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2748 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2749 // duplicate tag, drop it |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2750 vim_free(mfp); |
7 | 2751 } |
2752 } | |
2753 #ifdef FEAT_CSCOPE | |
2754 if (use_cscope && eof) | |
2755 break; | |
2756 #endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2757 } // forever |
7 | 2758 |
2759 if (line_error) | |
2760 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2761 semsg(_("E431: Format error in tags file \"%s\""), tag_fname); |
7 | 2762 #ifdef FEAT_CSCOPE |
2763 if (!use_cscope) | |
2764 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2765 semsg(_("Before byte %ld"), (long)vim_ftell(fp)); |
7 | 2766 stop_searching = TRUE; |
2767 line_error = FALSE; | |
2768 } | |
2769 | |
2770 #ifdef FEAT_CSCOPE | |
2771 if (!use_cscope) | |
2772 #endif | |
2773 fclose(fp); | |
2774 #ifdef FEAT_EMACS_TAGS | |
2775 while (incstack_idx) | |
2776 { | |
2777 --incstack_idx; | |
2778 fclose(incstack[incstack_idx].fp); | |
2779 vim_free(incstack[incstack_idx].etag_fname); | |
2780 } | |
2781 #endif | |
2782 if (vimconv.vc_type != CONV_NONE) | |
2783 convert_setup(&vimconv, NULL, NULL); | |
2784 | |
2785 #ifdef FEAT_TAG_BINS | |
3131 | 2786 tag_file_sorted = NUL; |
7 | 2787 if (sort_error) |
2788 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2789 semsg(_("E432: Tags file not sorted: %s"), tag_fname); |
7 | 2790 sort_error = FALSE; |
2791 } | |
2792 #endif | |
2793 | |
2794 /* | |
2795 * Stop searching if sufficient tags have been found. | |
2796 */ | |
2797 if (match_count >= mincount) | |
2798 { | |
2799 retval = OK; | |
2800 stop_searching = TRUE; | |
2801 } | |
2802 | |
2803 #ifdef FEAT_CSCOPE | |
2804 if (stop_searching || use_cscope) | |
2805 #else | |
2806 if (stop_searching) | |
2807 #endif | |
2808 break; | |
2809 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2810 } // end of for-each-file loop |
7 | 2811 |
692 | 2812 #ifdef FEAT_CSCOPE |
2813 if (!use_cscope) | |
2814 #endif | |
2815 tagname_free(&tn); | |
2816 | |
7 | 2817 #ifdef FEAT_TAG_BINS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2818 // stop searching when already did a linear search, or when TAG_NOIC |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2819 // used, and 'ignorecase' not set or already did case-ignore search |
3131 | 2820 if (stop_searching || linear || (!p_ic && noic) || orgpat.regmatch.rm_ic) |
7 | 2821 break; |
2822 # ifdef FEAT_CSCOPE | |
2823 if (use_cscope) | |
2824 break; | |
2825 # endif | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2826 orgpat.regmatch.rm_ic = TRUE; // try another time while ignoring case |
7 | 2827 } |
2828 #endif | |
2829 | |
2830 if (!stop_searching) | |
2831 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2832 if (!did_open && verbose) // never opened any tags file |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2833 emsg(_("E433: No tags file")); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2834 retval = OK; // It's OK even when no tag found |
7 | 2835 } |
2836 | |
2837 findtag_end: | |
2838 vim_free(lbuf); | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
3804
diff
changeset
|
2839 vim_regfree(orgpat.regmatch.regprog); |
7 | 2840 vim_free(tag_fname); |
2841 #ifdef FEAT_EMACS_TAGS | |
2842 vim_free(ebuf); | |
2843 #endif | |
2844 | |
2845 /* | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2846 * Move the matches from the ga_match[] arrays into one list of |
7 | 2847 * matches. When retval == FAIL, free the matches. |
2848 */ | |
2849 if (retval == FAIL) | |
2850 match_count = 0; | |
2851 | |
2852 if (match_count > 0) | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
2853 matches = ALLOC_MULT(char_u *, match_count); |
7 | 2854 else |
2855 matches = NULL; | |
2856 match_count = 0; | |
2857 for (mtt = 0; mtt < MT_COUNT; ++mtt) | |
2858 { | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2859 for (i = 0; i < ga_match[mtt].ga_len; ++i) |
7 | 2860 { |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2861 mfp = ((char_u **)(ga_match[mtt].ga_data))[i]; |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2862 if (matches == NULL) |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2863 vim_free(mfp); |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2864 else |
7 | 2865 { |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2866 if (!name_only) |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2867 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2868 // Change mtt back to zero-based. |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2869 *mfp = *mfp - 1; |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2870 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2871 // change the TAG_SEP back to NUL |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2872 for (p = mfp + 1; *p != NUL; ++p) |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2873 if (*p == TAG_SEP) |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2874 *p = NUL; |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2875 } |
25852
336e2d9924e6
patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents:
25652
diff
changeset
|
2876 matches[match_count++] = mfp; |
7 | 2877 } |
2878 } | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2879 |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
2880 ga_clear(&ga_match[mtt]); |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
2881 hash_clear(&ht_match[mtt]); |
7 | 2882 } |
2883 | |
2884 *matchesp = matches; | |
2885 *num_matches = match_count; | |
2886 | |
2887 curbuf->b_help = help_save; | |
2888 #ifdef FEAT_MULTI_LANG | |
2889 vim_free(saved_pat); | |
2890 #endif | |
2891 | |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
2892 p_ic = save_p_ic; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
2893 |
7 | 2894 return retval; |
2895 } | |
2896 | |
2897 static garray_T tag_fnames = GA_EMPTY; | |
2898 | |
2899 /* | |
2900 * Callback function for finding all "tags" and "tags-??" files in | |
2901 * 'runtimepath' doc directories. | |
2902 */ | |
2903 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2904 found_tagfile_cb(char_u *fname, void *cookie UNUSED) |
7 | 2905 { |
2906 if (ga_grow(&tag_fnames, 1) == OK) | |
14232
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2907 { |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2908 char_u *tag_fname = vim_strsave(fname); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2909 |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2910 #ifdef BACKSLASH_IN_FILENAME |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2911 slash_adjust(tag_fname); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2912 #endif |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2913 simplify_filename(tag_fname); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2914 ((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] = tag_fname; |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2915 } |
7 | 2916 } |
2917 | |
359 | 2918 #if defined(EXITFREE) || defined(PROTO) |
2919 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2920 free_tag_stuff(void) |
359 | 2921 { |
692 | 2922 ga_clear_strings(&tag_fnames); |
16511
4182f74e2965
patch 8.1.1259: crash when exiting early
Bram Moolenaar <Bram@vim.org>
parents:
16461
diff
changeset
|
2923 if (curwin != NULL) |
4182f74e2965
patch 8.1.1259: crash when exiting early
Bram Moolenaar <Bram@vim.org>
parents:
16461
diff
changeset
|
2924 do_tag(NULL, DT_FREE, 0, 0, 0); |
1818 | 2925 tag_freematch(); |
2926 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2927 # if defined(FEAT_QUICKFIX) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
2928 tagstack_clear_entry(&ptag_entry); |
1818 | 2929 # endif |
359 | 2930 } |
2931 #endif | |
2932 | |
7 | 2933 /* |
2934 * Get the next name of a tag file from the tag file list. | |
2935 * For help files, use "tags" file only. | |
2936 * | |
2937 * Return FAIL if no more tag file names, OK otherwise. | |
2938 */ | |
514 | 2939 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2940 get_tagfname( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2941 tagname_T *tnp, // holds status info |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2942 int first, // TRUE when first file name is wanted |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2943 char_u *buf) // pointer to buffer of MAXPATHL chars |
7 | 2944 { |
2945 char_u *fname = NULL; | |
2946 char_u *r_ptr; | |
14232
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2947 int i; |
7 | 2948 |
692 | 2949 if (first) |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2950 CLEAR_POINTER(tnp); |
692 | 2951 |
514 | 2952 if (curbuf->b_help) |
7 | 2953 { |
514 | 2954 /* |
2955 * For help files it's done in a completely different way: | |
2956 * Find "doc/tags" and "doc/tags-??" in all directories in | |
2957 * 'runtimepath'. | |
2958 */ | |
2959 if (first) | |
7 | 2960 { |
2961 ga_clear_strings(&tag_fnames); | |
2962 ga_init2(&tag_fnames, (int)sizeof(char_u *), 10); | |
2963 do_in_runtimepath((char_u *) | |
2964 #ifdef FEAT_MULTI_LANG | |
36 | 2965 # ifdef VMS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2966 // Functions decc$to_vms() and decc$translate_vms() crash |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2967 // on some VMS systems with wildcards "??". Seems ECO |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2968 // patches do fix the problem in C RTL, but we can't use |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2969 // an #ifdef for that. |
36 | 2970 "doc/tags doc/tags-*" |
2971 # else | |
7 | 2972 "doc/tags doc/tags-??" |
36 | 2973 # endif |
7 | 2974 #else |
2975 "doc/tags" | |
2976 #endif | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
7835
diff
changeset
|
2977 , DIP_ALL, found_tagfile_cb, NULL); |
7 | 2978 } |
602 | 2979 |
692 | 2980 if (tnp->tn_hf_idx >= tag_fnames.ga_len) |
7 | 2981 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2982 // Not found in 'runtimepath', use 'helpfile', if it exists and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2983 // wasn't used yet, replacing "help.txt" with "tags". |
692 | 2984 if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL) |
7 | 2985 return FAIL; |
692 | 2986 ++tnp->tn_hf_idx; |
7 | 2987 STRCPY(buf, p_hf); |
2988 STRCPY(gettail(buf), "tags"); | |
14232
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2989 #ifdef BACKSLASH_IN_FILENAME |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2990 slash_adjust(buf); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2991 #endif |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2992 simplify_filename(buf); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2993 |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2994 for (i = 0; i < tag_fnames.ga_len; ++i) |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2995 if (STRCMP(buf, ((char_u **)(tag_fnames.ga_data))[i]) == 0) |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
2996 return FAIL; // avoid duplicate file names |
7 | 2997 } |
2998 else | |
692 | 2999 vim_strncpy(buf, ((char_u **)(tag_fnames.ga_data))[ |
3000 tnp->tn_hf_idx++], MAXPATHL - 1); | |
514 | 3001 return OK; |
3002 } | |
3003 | |
3004 if (first) | |
3005 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3006 // Init. We make a copy of 'tags', because autocommands may change |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3007 // the value without notifying us. |
692 | 3008 tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL) |
3009 ? curbuf->b_p_tags : p_tags); | |
3010 if (tnp->tn_tags == NULL) | |
3011 return FAIL; | |
3012 tnp->tn_np = tnp->tn_tags; | |
7 | 3013 } |
692 | 3014 |
3015 /* | |
3016 * Loop until we have found a file name that can be used. | |
3017 * There are two states: | |
3018 * tnp->tn_did_filefind_init == FALSE: setup for next part in 'tags'. | |
3019 * tnp->tn_did_filefind_init == TRUE: find next file in this part. | |
3020 */ | |
3021 for (;;) | |
7 | 3022 { |
692 | 3023 if (tnp->tn_did_filefind_init) |
7 | 3024 { |
692 | 3025 fname = vim_findfile(tnp->tn_search_ctx); |
3026 if (fname != NULL) | |
3027 break; | |
3028 | |
3029 tnp->tn_did_filefind_init = FALSE; | |
3030 } | |
3031 else | |
3032 { | |
3033 char_u *filename = NULL; | |
3034 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3035 // Stop when used all parts of 'tags'. |
692 | 3036 if (*tnp->tn_np == NUL) |
7 | 3037 { |
692 | 3038 vim_findfile_cleanup(tnp->tn_search_ctx); |
3039 tnp->tn_search_ctx = NULL; | |
3040 return FAIL; | |
7 | 3041 } |
692 | 3042 |
3043 /* | |
3044 * Copy next file name into buf. | |
3045 */ | |
3046 buf[0] = NUL; | |
3047 (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,"); | |
7 | 3048 |
3049 #ifdef FEAT_PATH_EXTRA | |
692 | 3050 r_ptr = vim_findfile_stopdir(buf); |
7 | 3051 #else |
692 | 3052 r_ptr = NULL; |
7 | 3053 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3054 // move the filename one char forward and truncate the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3055 // filepath with a NUL |
692 | 3056 filename = gettail(buf); |
1620 | 3057 STRMOVE(filename + 1, filename); |
692 | 3058 *filename++ = NUL; |
3059 | |
3060 tnp->tn_search_ctx = vim_findfile_init(buf, filename, | |
3061 r_ptr, 100, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3062 FALSE, // don't free visited list |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3063 FINDFILE_FILE, // we search for a file |
692 | 3064 tnp->tn_search_ctx, TRUE, curbuf->b_ffname); |
3065 if (tnp->tn_search_ctx != NULL) | |
3066 tnp->tn_did_filefind_init = TRUE; | |
7 | 3067 } |
3068 } | |
3069 | |
692 | 3070 STRCPY(buf, fname); |
3071 vim_free(fname); | |
7 | 3072 return OK; |
3073 } | |
3074 | |
3075 /* | |
692 | 3076 * Free the contents of a tagname_T that was filled by get_tagfname(). |
3077 */ | |
3078 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3079 tagname_free(tagname_T *tnp) |
692 | 3080 { |
3081 vim_free(tnp->tn_tags); | |
3082 vim_findfile_cleanup(tnp->tn_search_ctx); | |
1541 | 3083 tnp->tn_search_ctx = NULL; |
692 | 3084 ga_clear_strings(&tag_fnames); |
3085 } | |
3086 | |
3087 /* | |
7 | 3088 * Parse one line from the tags file. Find start/end of tag name, start/end of |
3089 * file name and start of search pattern. | |
3090 * | |
3091 * If is_etag is TRUE, tagp->fname and tagp->fname_end are not set. | |
3092 * | |
3093 * Return FAIL if there is a format error in this line, OK otherwise. | |
3094 */ | |
3095 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3096 parse_tag_line( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3097 char_u *lbuf, // line to be parsed |
7 | 3098 #ifdef FEAT_EMACS_TAGS |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3099 int is_etag, |
7 | 3100 #endif |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3101 tagptrs_T *tagp) |
7 | 3102 { |
3103 char_u *p; | |
3104 | |
3105 #ifdef FEAT_EMACS_TAGS | |
3106 char_u *p_7f; | |
3107 | |
3108 if (is_etag) | |
3109 { | |
3110 /* | |
3111 * There are two formats for an emacs tag line: | |
3112 * 1: struct EnvBase ^?EnvBase^A139,4627 | |
3113 * 2: #define ARPB_WILD_WORLD ^?153,5194 | |
3114 */ | |
3115 p_7f = vim_strchr(lbuf, 0x7f); | |
3116 if (p_7f == NULL) | |
1770 | 3117 { |
3118 etag_fail: | |
3119 if (vim_strchr(lbuf, '\n') == NULL) | |
3120 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3121 // Truncated line. Ignore it. |
1770 | 3122 if (p_verbose >= 5) |
3123 { | |
3124 verbose_enter(); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3125 msg(_("Ignoring long line in tags file")); |
1770 | 3126 verbose_leave(); |
3127 } | |
3128 tagp->command = lbuf; | |
3129 tagp->tagname = lbuf; | |
3130 tagp->tagname_end = lbuf; | |
3131 return OK; | |
3132 } | |
7 | 3133 return FAIL; |
1770 | 3134 } |
7 | 3135 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3136 // Find ^A. If not found the line number is after the 0x7f |
7 | 3137 p = vim_strchr(p_7f, Ctrl_A); |
3138 if (p == NULL) | |
3139 p = p_7f + 1; | |
3140 else | |
3141 ++p; | |
3142 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3143 if (!VIM_ISDIGIT(*p)) // check for start of line number |
1770 | 3144 goto etag_fail; |
7 | 3145 tagp->command = p; |
3146 | |
3147 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3148 if (p[-1] == Ctrl_A) // first format: explicit tagname given |
7 | 3149 { |
3150 tagp->tagname = p_7f + 1; | |
3151 tagp->tagname_end = p - 1; | |
3152 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3153 else // second format: isolate tagname |
7 | 3154 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3155 // find end of tagname |
7 | 3156 for (p = p_7f - 1; !vim_iswordc(*p); --p) |
3157 if (p == lbuf) | |
1770 | 3158 goto etag_fail; |
7 | 3159 tagp->tagname_end = p + 1; |
3160 while (p >= lbuf && vim_iswordc(*p)) | |
3161 --p; | |
3162 tagp->tagname = p + 1; | |
3163 } | |
3164 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3165 else // not an Emacs tag |
7 | 3166 { |
3167 #endif | |
16070
c435843c7535
patch 8.1.1040: FEAT_TAG_ANYWHITE is not enabled in any build
Bram Moolenaar <Bram@vim.org>
parents:
15840
diff
changeset
|
3168 // Isolate the tagname, from lbuf up to the first white |
7 | 3169 tagp->tagname = lbuf; |
3170 p = vim_strchr(lbuf, TAB); | |
3171 if (p == NULL) | |
3172 return FAIL; | |
3173 tagp->tagname_end = p; | |
3174 | |
16070
c435843c7535
patch 8.1.1040: FEAT_TAG_ANYWHITE is not enabled in any build
Bram Moolenaar <Bram@vim.org>
parents:
15840
diff
changeset
|
3175 // Isolate file name, from first to second white space |
7 | 3176 if (*p != NUL) |
3177 ++p; | |
3178 tagp->fname = p; | |
3179 p = vim_strchr(p, TAB); | |
3180 if (p == NULL) | |
3181 return FAIL; | |
3182 tagp->fname_end = p; | |
3183 | |
16070
c435843c7535
patch 8.1.1040: FEAT_TAG_ANYWHITE is not enabled in any build
Bram Moolenaar <Bram@vim.org>
parents:
15840
diff
changeset
|
3184 // find start of search command, after second white space |
7 | 3185 if (*p != NUL) |
3186 ++p; | |
3187 if (*p == NUL) | |
3188 return FAIL; | |
3189 tagp->command = p; | |
3190 #ifdef FEAT_EMACS_TAGS | |
3191 } | |
3192 #endif | |
3193 | |
3194 return OK; | |
3195 } | |
3196 | |
3197 /* | |
3198 * Check if tagname is a static tag | |
3199 * | |
3200 * Static tags produced by the older ctags program have the format: | |
3201 * 'file:tag file /pattern'. | |
1204 | 3202 * This is only recognized when both occurrence of 'file' are the same, to |
7 | 3203 * avoid recognizing "string::string" or ":exit". |
3204 * | |
3205 * Static tags produced by the new ctags program have the format: | |
3206 * 'tag file /pattern/;"<Tab>file:' " | |
3207 * | |
3208 * Return TRUE if it is a static tag and adjust *tagname to the real tag. | |
3209 * Return FALSE if it is not a static tag. | |
3210 */ | |
3211 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3212 test_for_static(tagptrs_T *tagp) |
7 | 3213 { |
3214 char_u *p; | |
3215 | |
3216 /* | |
3217 * Check for new style static tag ":...<Tab>file:[<Tab>...]" | |
3218 */ | |
3219 p = tagp->command; | |
3220 while ((p = vim_strchr(p, '\t')) != NULL) | |
3221 { | |
3222 ++p; | |
3223 if (STRNCMP(p, "file:", 5) == 0) | |
3224 return TRUE; | |
3225 } | |
3226 | |
3227 return FALSE; | |
3228 } | |
3229 | |
3230 /* | |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3231 * Returns the length of a matching tag line. |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3232 */ |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3233 static size_t |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3234 matching_line_len(char_u *lbuf) |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3235 { |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3236 char_u *p = lbuf + 1; |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3237 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3238 // does the same thing as parse_match() |
13227
b88fa651c824
patch 8.0.1488: emacs tags no longer work
Christian Brabandt <cb@256bit.org>
parents:
13068
diff
changeset
|
3239 p += STRLEN(p) + 1; |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3240 #ifdef FEAT_EMACS_TAGS |
13227
b88fa651c824
patch 8.0.1488: emacs tags no longer work
Christian Brabandt <cb@256bit.org>
parents:
13068
diff
changeset
|
3241 p += STRLEN(p) + 1; |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3242 #endif |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3243 return (p - lbuf) + STRLEN(p); |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3244 } |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3245 |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3246 /* |
7 | 3247 * Parse a line from a matching tag. Does not change the line itself. |
3248 * | |
3249 * The line that we get looks like this: | |
3250 * Emacs tag: <mtt><tag_fname><NUL><ebuf><NUL><lbuf> | |
3251 * other tag: <mtt><tag_fname><NUL><NUL><lbuf> | |
3252 * without Emacs tags: <mtt><tag_fname><NUL><lbuf> | |
3253 * | |
3254 * Return OK or FAIL. | |
3255 */ | |
3256 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3257 parse_match( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3258 char_u *lbuf, // input: matching line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3259 tagptrs_T *tagp) // output: pointers into the line |
7 | 3260 { |
3261 int retval; | |
3262 char_u *p; | |
3263 char_u *pc, *pt; | |
3264 | |
3265 tagp->tag_fname = lbuf + 1; | |
3266 lbuf += STRLEN(tagp->tag_fname) + 2; | |
3267 #ifdef FEAT_EMACS_TAGS | |
3268 if (*lbuf) | |
3269 { | |
3270 tagp->is_etag = TRUE; | |
3271 tagp->fname = lbuf; | |
3272 lbuf += STRLEN(lbuf); | |
3273 tagp->fname_end = lbuf++; | |
3274 } | |
3275 else | |
3276 { | |
3277 tagp->is_etag = FALSE; | |
3278 ++lbuf; | |
3279 } | |
3280 #endif | |
3281 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3282 // Find search pattern and the file name for non-etags. |
7 | 3283 retval = parse_tag_line(lbuf, |
3284 #ifdef FEAT_EMACS_TAGS | |
3285 tagp->is_etag, | |
3286 #endif | |
3287 tagp); | |
3288 | |
3289 tagp->tagkind = NULL; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3290 tagp->user_data = NULL; |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3291 tagp->tagline = 0; |
7 | 3292 tagp->command_end = NULL; |
3293 | |
3294 if (retval == OK) | |
3295 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3296 // Try to find a kind field: "kind:<kind>" or just "<kind>" |
7 | 3297 p = tagp->command; |
3298 if (find_extra(&p) == OK) | |
3299 { | |
15808
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3300 if (p > tagp->command && p[-1] == '|') |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3301 tagp->command_end = p - 1; // drop trailing bar |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3302 else |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3303 tagp->command_end = p; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3304 p += 2; // skip ";\"" |
7 | 3305 if (*p++ == TAB) |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3306 // Accept ASCII alphabetic kind characters and any multi-byte |
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3307 // character. |
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3308 while (ASCII_ISALPHA(*p) || mb_ptr2len(p) > 1) |
7 | 3309 { |
3310 if (STRNCMP(p, "kind:", 5) == 0) | |
3311 tagp->tagkind = p + 5; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3312 else if (STRNCMP(p, "user_data:", 10) == 0) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3313 tagp->user_data = p + 10; |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3314 else if (STRNCMP(p, "line:", 5) == 0) |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3315 tagp->tagline = atoi((char *)p + 5); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3316 if (tagp->tagkind != NULL && tagp->user_data != NULL) |
7 | 3317 break; |
3318 pc = vim_strchr(p, ':'); | |
3319 pt = vim_strchr(p, '\t'); | |
3320 if (pc == NULL || (pt != NULL && pc > pt)) | |
3321 tagp->tagkind = p; | |
3322 if (pt == NULL) | |
3323 break; | |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3324 p = pt; |
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3325 MB_PTR_ADV(p); |
7 | 3326 } |
3327 } | |
3328 if (tagp->tagkind != NULL) | |
3329 { | |
3330 for (p = tagp->tagkind; | |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3331 *p && *p != '\t' && *p != '\r' && *p != '\n'; MB_PTR_ADV(p)) |
7 | 3332 ; |
3333 tagp->tagkind_end = p; | |
3334 } | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3335 if (tagp->user_data != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3336 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3337 for (p = tagp->user_data; |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3338 *p && *p != '\t' && *p != '\r' && *p != '\n'; MB_PTR_ADV(p)) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3339 ; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3340 tagp->user_data_end = p; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3341 } |
7 | 3342 } |
3343 return retval; | |
3344 } | |
3345 | |
3346 /* | |
3347 * Find out the actual file name of a tag. Concatenate the tags file name | |
3348 * with the matching tag file name. | |
3349 * Returns an allocated string or NULL (out of memory). | |
3350 */ | |
3351 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3352 tag_full_fname(tagptrs_T *tagp) |
7 | 3353 { |
3354 char_u *fullname; | |
3355 int c; | |
3356 | |
3357 #ifdef FEAT_EMACS_TAGS | |
3358 if (tagp->is_etag) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3359 c = 0; // to shut up GCC |
7 | 3360 else |
3361 #endif | |
3362 { | |
3363 c = *tagp->fname_end; | |
3364 *tagp->fname_end = NUL; | |
3365 } | |
3366 fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE); | |
3367 | |
3368 #ifdef FEAT_EMACS_TAGS | |
3369 if (!tagp->is_etag) | |
3370 #endif | |
3371 *tagp->fname_end = c; | |
3372 | |
3373 return fullname; | |
3374 } | |
3375 | |
3376 /* | |
3377 * Jump to a tag that has been found in one of the tag files | |
3378 * | |
3379 * returns OK for success, NOTAGFILE when file not found, FAIL otherwise. | |
3380 */ | |
3381 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3382 jumpto_tag( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3383 char_u *lbuf_arg, // line from the tags file for this tag |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3384 int forceit, // :ta with ! |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3385 int keep_help) // keep help flag (FALSE for cscope) |
7 | 3386 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3387 optmagic_T save_magic_overruled; |
7 | 3388 int save_p_ws, save_p_scs, save_p_ic; |
3389 linenr_T save_lnum; | |
3390 char_u *str; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3391 char_u *pbuf; // search pattern buffer |
7 | 3392 char_u *pbuf_end; |
3393 char_u *tofree_fname = NULL; | |
3394 char_u *fname; | |
3395 tagptrs_T tagp; | |
3396 int retval = FAIL; | |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3397 int getfile_result = GETFILE_UNUSED; |
7 | 3398 int search_options; |
3399 #ifdef FEAT_SEARCH_EXTRA | |
3400 int save_no_hlsearch; | |
3401 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3402 #if defined(FEAT_QUICKFIX) |
7 | 3403 win_T *curwin_save = NULL; |
3404 #endif | |
3405 char_u *full_fname = NULL; | |
3406 #ifdef FEAT_FOLDING | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3407 int old_KeyTyped = KeyTyped; // getting the file may reset it |
7 | 3408 #endif |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3409 size_t len; |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3410 char_u *lbuf; |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3411 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3412 // Make a copy of the line, it can become invalid when an autocommand calls |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3413 // back here recursively. |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3414 len = matching_line_len(lbuf_arg) + 1; |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3415 lbuf = alloc(len); |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3416 if (lbuf != NULL) |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3417 mch_memmove(lbuf, lbuf_arg, len); |
7 | 3418 |
3419 pbuf = alloc(LSIZE); | |
3420 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3421 // parse the match line into the tagp structure |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3422 if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL) |
7 | 3423 { |
3424 tagp.fname_end = NULL; | |
3425 goto erret; | |
3426 } | |
3427 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3428 // truncate the file name, so it can be used as a string |
7 | 3429 *tagp.fname_end = NUL; |
3430 fname = tagp.fname; | |
3431 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3432 // copy the command to pbuf[], remove trailing CR/NL |
7 | 3433 str = tagp.command; |
3434 for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; ) | |
3435 { | |
3436 #ifdef FEAT_EMACS_TAGS | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3437 if (tagp.is_etag && *str == ',')// stop at ',' after line number |
7 | 3438 break; |
3439 #endif | |
3440 *pbuf_end++ = *str++; | |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
3441 if (pbuf_end - pbuf + 1 >= LSIZE) |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
3442 break; |
7 | 3443 } |
3444 *pbuf_end = NUL; | |
3445 | |
3446 #ifdef FEAT_EMACS_TAGS | |
3447 if (!tagp.is_etag) | |
3448 #endif | |
3449 { | |
3450 /* | |
3451 * Remove the "<Tab>fieldname:value" stuff; we don't need it here. | |
3452 */ | |
3453 str = pbuf; | |
3454 if (find_extra(&str) == OK) | |
3455 { | |
3456 pbuf_end = str; | |
3457 *pbuf_end = NUL; | |
3458 } | |
3459 } | |
3460 | |
3461 /* | |
3462 * Expand file name, when needed (for environment variables). | |
3463 * If 'tagrelative' option set, may change file name. | |
3464 */ | |
3465 fname = expand_tag_fname(fname, tagp.tag_fname, TRUE); | |
3466 if (fname == NULL) | |
3467 goto erret; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3468 tofree_fname = fname; // free() it later |
7 | 3469 |
3470 /* | |
3471 * Check if the file with the tag exists before abandoning the current | |
3472 * file. Also accept a file name for which there is a matching BufReadCmd | |
3473 * autocommand event (e.g., http://sys/file). | |
3474 */ | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3475 if (mch_getperm(fname) < 0 && !has_autocmd(EVENT_BUFREADCMD, fname, NULL)) |
7 | 3476 { |
3477 retval = NOTAGFILE; | |
3478 vim_free(nofile_fname); | |
3479 nofile_fname = vim_strsave(fname); | |
3480 if (nofile_fname == NULL) | |
3481 nofile_fname = empty_option; | |
3482 goto erret; | |
3483 } | |
3484 | |
3485 ++RedrawingDisabled; | |
3486 | |
3487 #ifdef FEAT_GUI | |
3488 need_mouse_correct = TRUE; | |
3489 #endif | |
3490 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3491 #if defined(FEAT_QUICKFIX) |
2713 | 3492 if (g_do_tagpreview != 0) |
7 | 3493 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3494 postponed_split = 0; // don't split again below |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3495 curwin_save = curwin; // Save current window |
728 | 3496 |
7 | 3497 /* |
3498 * If we are reusing a window, we may change dir when | |
3499 * entering it (autocommands) so turn the tag filename | |
3500 * into a fullpath | |
3501 */ | |
3502 if (!curwin->w_p_pvw) | |
3503 { | |
3504 full_fname = FullName_save(fname, FALSE); | |
3505 fname = full_fname; | |
3506 | |
3507 /* | |
3508 * Make the preview window the current window. | |
3509 * Open a preview window when needed. | |
3510 */ | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3511 prepare_tagpreview(TRUE, TRUE, FALSE); |
7 | 3512 } |
3513 } | |
3514 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3515 // If it was a CTRL-W CTRL-] command split window now. For ":tab tag" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3516 // open a new tab page. |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3517 if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB))) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3518 { |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3519 buf_T *existing_buf = buflist_findname_exp(fname); |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3520 |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3521 if (existing_buf != NULL) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3522 { |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3523 win_T *wp = NULL; |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3524 |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3525 if (swb_flags & SWB_USEOPEN) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3526 wp = buf_jump_open_win(existing_buf); |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3527 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3528 // If 'switchbuf' contains "usetab": jump to first window in any tab |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3529 // page containing "existing_buf" if one exists |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3530 if (wp == NULL && (swb_flags & SWB_USETAB)) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3531 wp = buf_jump_open_tab(existing_buf); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3532 // We've switched to the buffer, the usual loading of the file must |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3533 // be skipped. |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3534 if (wp != NULL) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3535 getfile_result = GETFILE_SAME_FILE; |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3536 } |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3537 } |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3538 if (getfile_result == GETFILE_UNUSED |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21996
diff
changeset
|
3539 && (postponed_split || cmdmod.cmod_tab != 0)) |
7 | 3540 { |
11238
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3541 if (win_split(postponed_split > 0 ? postponed_split : 0, |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3542 postponed_split_flags) == FAIL) |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3543 { |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3544 --RedrawingDisabled; |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3545 goto erret; |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3546 } |
2583 | 3547 RESET_BINDING(curwin); |
7 | 3548 } |
3549 #endif | |
3550 | |
3551 if (keep_help) | |
3552 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3553 // A :ta from a help file will keep the b_help flag set. For ":ptag" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3554 // we need to use the flag from the window where we came from. |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3555 #if defined(FEAT_QUICKFIX) |
2713 | 3556 if (g_do_tagpreview != 0) |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3557 keep_help_flag = bt_help(curwin_save->w_buffer); |
7 | 3558 else |
3559 #endif | |
3560 keep_help_flag = curbuf->b_help; | |
3561 } | |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3562 |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3563 if (getfile_result == GETFILE_UNUSED) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3564 // Careful: getfile() may trigger autocommands and call jumpto_tag() |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3565 // recursively. |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3566 getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); |
7 | 3567 keep_help_flag = FALSE; |
3568 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3569 if (GETFILE_SUCCESS(getfile_result)) // got to the right file |
7 | 3570 { |
3571 curwin->w_set_curswant = TRUE; | |
3572 postponed_split = 0; | |
3573 | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
3574 save_magic_overruled = magic_overruled; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3575 magic_overruled = OPTION_MAGIC_OFF; // always execute with 'nomagic' |
7 | 3576 #ifdef FEAT_SEARCH_EXTRA |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3577 // Save value of no_hlsearch, jumping to a tag is not a real search |
7 | 3578 save_no_hlsearch = no_hlsearch; |
3579 #endif | |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
3580 #if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX) |
24053
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3581 // getfile() may have cleared options, apply 'previewpopup' again. |
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3582 if (g_do_tagpreview != 0 && *p_pvp != NUL) |
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3583 parse_previewpopup(curwin); |
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3584 #endif |
7 | 3585 |
3586 /* | |
3587 * If 'cpoptions' contains 't', store the search pattern for the "n" | |
3588 * command. If 'cpoptions' does not contain 't', the search pattern | |
3589 * is not stored. | |
3590 */ | |
3591 if (vim_strchr(p_cpo, CPO_TAGPAT) != NULL) | |
3592 search_options = 0; | |
3593 else | |
3594 search_options = SEARCH_KEEP; | |
3595 | |
3596 /* | |
3597 * If the command is a search, try here. | |
3598 * | |
3599 * Reset 'smartcase' for the search, since the search pattern was not | |
3600 * typed by the user. | |
3601 * Only use do_search() when there is a full search command, without | |
3602 * anything following. | |
3603 */ | |
3604 str = pbuf; | |
3605 if (pbuf[0] == '/' || pbuf[0] == '?') | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3606 str = skip_regexp(pbuf + 1, pbuf[0], FALSE) + 1; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3607 if (str > pbuf_end - 1) // search command with nothing following |
7 | 3608 { |
3609 save_p_ws = p_ws; | |
3610 save_p_ic = p_ic; | |
3611 save_p_scs = p_scs; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3612 p_ws = TRUE; // need 'wrapscan' for backward searches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3613 p_ic = FALSE; // don't ignore case now |
7 | 3614 p_scs = FALSE; |
3615 save_lnum = curwin->w_cursor.lnum; | |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3616 if (tagp.tagline > 0) |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3617 // start search before line from "line:" field |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3618 curwin->w_cursor.lnum = tagp.tagline - 1; |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3619 else |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3620 // start search before first line |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3621 curwin->w_cursor.lnum = 0; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3622 if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3623 search_options, NULL)) |
7 | 3624 retval = OK; |
3625 else | |
3626 { | |
3627 int found = 1; | |
3628 int cc; | |
3629 | |
3630 /* | |
3631 * try again, ignore case now | |
3632 */ | |
3633 p_ic = TRUE; | |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3634 if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3635 search_options, NULL)) |
7 | 3636 { |
3637 /* | |
3638 * Failed to find pattern, take a guess: "^func (" | |
3639 */ | |
3640 found = 2; | |
3641 (void)test_for_static(&tagp); | |
3642 cc = *tagp.tagname_end; | |
3643 *tagp.tagname_end = NUL; | |
3644 sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); | |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3645 if (!do_search(NULL, '/', '/', pbuf, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3646 search_options, NULL)) |
7 | 3647 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3648 // Guess again: "^char * \<func (" |
7 | 3649 sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(", |
3650 tagp.tagname); | |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3651 if (!do_search(NULL, '/', '/', pbuf, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3652 search_options, NULL)) |
7 | 3653 found = 0; |
3654 } | |
3655 *tagp.tagname_end = cc; | |
3656 } | |
3657 if (found == 0) | |
3658 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3659 emsg(_("E434: Can't find tag pattern")); |
7 | 3660 curwin->w_cursor.lnum = save_lnum; |
3661 } | |
3662 else | |
3663 { | |
3664 /* | |
3665 * Only give a message when really guessed, not when 'ic' | |
3666 * is set and match found while ignoring case. | |
3667 */ | |
3668 if (found == 2 || !save_p_ic) | |
3669 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3670 msg(_("E435: Couldn't find tag, just guessing!")); |
7 | 3671 if (!msg_scrolled && msg_silent == 0) |
3672 { | |
3673 out_flush(); | |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18640
diff
changeset
|
3674 ui_delay(1010L, TRUE); |
7 | 3675 } |
3676 } | |
3677 retval = OK; | |
3678 } | |
3679 } | |
3680 p_ws = save_p_ws; | |
3681 p_ic = save_p_ic; | |
3682 p_scs = save_p_scs; | |
3683 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3684 // A search command may have positioned the cursor beyond the end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3685 // of the line. May need to correct that here. |
7 | 3686 check_cursor(); |
3687 } | |
3688 else | |
3689 { | |
25262
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3690 int save_secure = secure; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3691 |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3692 // Setup the sandbox for executing the command from the tags file. |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3693 secure = 1; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3694 #ifdef HAVE_SANDBOX |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3695 ++sandbox; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3696 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3697 curwin->w_cursor.lnum = 1; // start command in line 1 |
7 | 3698 do_cmdline_cmd(pbuf); |
3699 retval = OK; | |
25262
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3700 |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3701 // When the command has done something that is not allowed make |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3702 // sure the error message can be seen. |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3703 if (secure == 2) |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3704 wait_return(TRUE); |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3705 secure = save_secure; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3706 #ifdef HAVE_SANDBOX |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3707 --sandbox; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3708 #endif |
7 | 3709 } |
3710 | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
3711 magic_overruled = save_magic_overruled; |
7 | 3712 #ifdef FEAT_SEARCH_EXTRA |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3713 // restore no_hlsearch when keeping the old search pattern |
7 | 3714 if (search_options) |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
3715 set_no_hlsearch(save_no_hlsearch); |
7 | 3716 #endif |
3717 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3718 // Return OK if jumped to another file (at least we found the file!). |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3719 if (getfile_result == GETFILE_OPEN_OTHER) |
7 | 3720 retval = OK; |
3721 | |
3722 if (retval == OK) | |
3723 { | |
3724 /* | |
3725 * For a help buffer: Put the cursor line at the top of the window, | |
3726 * the help subject will be below it. | |
3727 */ | |
3728 if (curbuf->b_help) | |
3729 set_topline(curwin, curwin->w_cursor.lnum); | |
3730 #ifdef FEAT_FOLDING | |
3731 if ((fdo_flags & FDO_TAG) && old_KeyTyped) | |
3732 foldOpenCursor(); | |
3733 #endif | |
3734 } | |
3735 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3736 #if defined(FEAT_QUICKFIX) |
2713 | 3737 if (g_do_tagpreview != 0 |
3738 && curwin != curwin_save && win_valid(curwin_save)) | |
7 | 3739 { |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3740 // Return cursor to where we were |
7 | 3741 validate_cursor(); |
3742 redraw_later(VALID); | |
3743 win_enter(curwin_save, TRUE); | |
3744 } | |
3745 #endif | |
3746 | |
3747 --RedrawingDisabled; | |
3748 } | |
3749 else | |
3750 { | |
3751 --RedrawingDisabled; | |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3752 got_int = FALSE; // don't want entering window to fail |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3753 |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3754 if (postponed_split) // close the window |
7 | 3755 { |
3756 win_close(curwin, FALSE); | |
3757 postponed_split = 0; | |
3758 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3759 #if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP) |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3760 else if (WIN_IS_POPUP(curwin)) |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3761 { |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3762 win_T *wp = curwin; |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3763 |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3764 if (win_valid(curwin_save)) |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3765 win_enter(curwin_save, TRUE); |
20384
42ab4d40e78f
patch 8.2.0747: cannot forcefully close all popups
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3766 popup_close(wp->w_id, FALSE); |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3767 } |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3768 #endif |
7 | 3769 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3770 #if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP) |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
3771 if (WIN_IS_POPUP(curwin)) |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
3772 // something went wrong, still in popup, but it can't have focus |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
3773 win_enter(firstwin, TRUE); |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
3774 #endif |
7 | 3775 |
3776 erret: | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3777 #if defined(FEAT_QUICKFIX) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3778 g_do_tagpreview = 0; // For next time |
7 | 3779 #endif |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3780 vim_free(lbuf); |
7 | 3781 vim_free(pbuf); |
3782 vim_free(tofree_fname); | |
3783 vim_free(full_fname); | |
3784 | |
3785 return retval; | |
3786 } | |
3787 | |
3788 /* | |
3789 * If "expand" is TRUE, expand wildcards in fname. | |
3790 * If 'tagrelative' option set, change fname (name of file containing tag) | |
3791 * according to tag_fname (name of tag file containing fname). | |
3792 * Returns a pointer to allocated memory (or NULL when out of memory). | |
3793 */ | |
3794 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3795 expand_tag_fname(char_u *fname, char_u *tag_fname, int expand) |
7 | 3796 { |
3797 char_u *p; | |
3798 char_u *retval; | |
3799 char_u *expanded_fname = NULL; | |
3800 expand_T xpc; | |
3801 | |
3802 /* | |
3803 * Expand file name (for environment variables) when needed. | |
3804 */ | |
3805 if (expand && mch_has_wildcard(fname)) | |
3806 { | |
3807 ExpandInit(&xpc); | |
3808 xpc.xp_context = EXPAND_FILES; | |
3809 expanded_fname = ExpandOne(&xpc, (char_u *)fname, NULL, | |
3810 WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); | |
3811 if (expanded_fname != NULL) | |
3812 fname = expanded_fname; | |
3813 } | |
3814 | |
3815 if ((p_tr || curbuf->b_help) | |
3816 && !vim_isAbsName(fname) | |
3817 && (p = gettail(tag_fname)) != tag_fname) | |
3818 { | |
3819 retval = alloc(MAXPATHL); | |
3820 if (retval != NULL) | |
3821 { | |
3822 STRCPY(retval, tag_fname); | |
418 | 3823 vim_strncpy(retval + (p - tag_fname), fname, |
3824 MAXPATHL - (p - tag_fname) - 1); | |
7 | 3825 /* |
3826 * Translate names like "src/a/../b/file.c" into "src/b/file.c". | |
3827 */ | |
3828 simplify_filename(retval); | |
3829 } | |
3830 } | |
3831 else | |
3832 retval = vim_strsave(fname); | |
3833 | |
3834 vim_free(expanded_fname); | |
3835 | |
3836 return retval; | |
3837 } | |
3838 | |
3839 /* | |
3840 * Check if we have a tag for the buffer with name "buf_ffname". | |
3841 * This is a bit slow, because of the full path compare in fullpathcmp(). | |
3842 * Return TRUE if tag for file "fname" if tag file "tag_fname" is for current | |
3843 * file. | |
3844 */ | |
3845 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3846 test_for_current( |
7 | 3847 #ifdef FEAT_EMACS_TAGS |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3848 int is_etag, |
7 | 3849 #endif |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3850 char_u *fname, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3851 char_u *fname_end, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3852 char_u *tag_fname, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3853 char_u *buf_ffname) |
7 | 3854 { |
3855 int c; | |
3856 int retval = FALSE; | |
3857 char_u *fullname; | |
3858 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3859 if (buf_ffname != NULL) // if the buffer has a name |
7 | 3860 { |
3861 #ifdef FEAT_EMACS_TAGS | |
3862 if (is_etag) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3863 c = 0; // to shut up GCC |
7 | 3864 else |
3865 #endif | |
3866 { | |
3867 c = *fname_end; | |
3868 *fname_end = NUL; | |
3869 } | |
3870 fullname = expand_tag_fname(fname, tag_fname, TRUE); | |
3871 if (fullname != NULL) | |
3872 { | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16511
diff
changeset
|
3873 retval = (fullpathcmp(fullname, buf_ffname, TRUE, TRUE) & FPC_SAME); |
7 | 3874 vim_free(fullname); |
3875 } | |
3876 #ifdef FEAT_EMACS_TAGS | |
3877 if (!is_etag) | |
3878 #endif | |
3879 *fname_end = c; | |
3880 } | |
3881 | |
3882 return retval; | |
3883 } | |
3884 | |
3885 /* | |
3886 * Find the end of the tagaddress. | |
3887 * Return OK if ";\"" is following, FAIL otherwise. | |
3888 */ | |
3889 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3890 find_extra(char_u **pp) |
7 | 3891 { |
3892 char_u *str = *pp; | |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
19033
diff
changeset
|
3893 char_u first_char = **pp; |
7 | 3894 |
15808
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3895 // Repeat for addresses separated with ';' |
7 | 3896 for (;;) |
3897 { | |
3898 if (VIM_ISDIGIT(*str)) | |
24665
661d15592d3c
patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
3899 str = skipdigits(str + 1); |
7 | 3900 else if (*str == '/' || *str == '?') |
3901 { | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3902 str = skip_regexp(str + 1, *str, FALSE); |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
19033
diff
changeset
|
3903 if (*str != first_char) |
7 | 3904 str = NULL; |
3905 else | |
3906 ++str; | |
3907 } | |
3908 else | |
15808
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3909 { |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3910 // not a line number or search string, look for terminator. |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3911 str = (char_u *)strstr((char *)str, "|;\""); |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3912 if (str != NULL) |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3913 { |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3914 ++str; |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3915 break; |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3916 } |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3917 |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3918 } |
7 | 3919 if (str == NULL || *str != ';' |
3920 || !(VIM_ISDIGIT(str[1]) || str[1] == '/' || str[1] == '?')) | |
3921 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3922 ++str; // skip ';' |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
19033
diff
changeset
|
3923 first_char = *str; |
7 | 3924 } |
3925 | |
3926 if (str != NULL && STRNCMP(str, ";\"", 2) == 0) | |
3927 { | |
3928 *pp = str; | |
3929 return OK; | |
3930 } | |
3931 return FAIL; | |
3932 } | |
3933 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3934 /* |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3935 * Free a single entry in a tag stack |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3936 */ |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3937 static void |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3938 tagstack_clear_entry(taggy_T *item) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3939 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3940 VIM_CLEAR(item->tagname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3941 VIM_CLEAR(item->user_data); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3942 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3943 |
7 | 3944 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3945 expand_tags( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3946 int tagnames, // expand tag names |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3947 char_u *pat, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3948 int *num_file, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3949 char_u ***file) |
7 | 3950 { |
3951 int i; | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3952 int extra_flag; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3953 char_u *name_buf; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3954 size_t name_buf_size = 100; |
7 | 3955 tagptrs_T t_p; |
3956 int ret; | |
3957 | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3958 name_buf = alloc(name_buf_size); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3959 if (name_buf == NULL) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3960 return FAIL; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3961 |
7 | 3962 if (tagnames) |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3963 extra_flag = TAG_NAMES; |
7 | 3964 else |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3965 extra_flag = 0; |
7 | 3966 if (pat[0] == '/') |
3967 ret = find_tags(pat + 1, num_file, file, | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3968 TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC, |
7 | 3969 TAG_MANY, curbuf->b_ffname); |
3970 else | |
3971 ret = find_tags(pat, num_file, file, | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3972 TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC, |
7 | 3973 TAG_MANY, curbuf->b_ffname); |
3974 if (ret == OK && !tagnames) | |
3975 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3976 // Reorganize the tags for display and matching as strings of: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3977 // "<tagname>\0<kind>\0<filename>\0" |
7 | 3978 for (i = 0; i < *num_file; i++) |
3979 { | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3980 size_t len; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3981 |
7 | 3982 parse_match((*file)[i], &t_p); |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3983 len = t_p.tagname_end - t_p.tagname; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3984 if (len > name_buf_size - 3) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3985 { |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3986 char_u *buf; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3987 |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3988 name_buf_size = len + 3; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3989 buf = vim_realloc(name_buf, name_buf_size); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3990 if (buf == NULL) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3991 { |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3992 vim_free(name_buf); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3993 return FAIL; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3994 } |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3995 name_buf = buf; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3996 } |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3997 |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3998 mch_memmove(name_buf, t_p.tagname, len); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
3999 name_buf[len++] = 0; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4000 name_buf[len++] = (t_p.tagkind != NULL && *t_p.tagkind) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4001 ? *t_p.tagkind : 'f'; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4002 name_buf[len++] = 0; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4003 mch_memmove((*file)[i] + len, t_p.fname, |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4004 t_p.fname_end - t_p.fname); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4005 (*file)[i][len + (t_p.fname_end - t_p.fname)] = 0; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4006 mch_memmove((*file)[i], name_buf, len); |
7 | 4007 } |
4008 } | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4009 |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4010 vim_free(name_buf); |
7 | 4011 return ret; |
4012 } | |
179 | 4013 |
4014 #if defined(FEAT_EVAL) || defined(PROTO) | |
4015 /* | |
2185 | 4016 * Add a tag field to the dictionary "dict". |
4017 * Return OK or FAIL. | |
179 | 4018 */ |
4019 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4020 add_tag_field( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4021 dict_T *dict, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4022 char *field_name, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4023 char_u *start, // start of the value |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4024 char_u *end) // after the value; can be NULL |
179 | 4025 { |
2770 | 4026 char_u *buf; |
188 | 4027 int len = 0; |
2770 | 4028 int retval; |
179 | 4029 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4030 // check that the field name doesn't exist yet |
2185 | 4031 if (dict_find(dict, (char_u *)field_name, -1) != NULL) |
4032 { | |
4033 if (p_verbose > 0) | |
4034 { | |
4035 verbose_enter(); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
4036 smsg(_("Duplicate field name: %s"), field_name); |
2185 | 4037 verbose_leave(); |
4038 } | |
4039 return FAIL; | |
4040 } | |
2770 | 4041 buf = alloc(MAXPATHL); |
4042 if (buf == NULL) | |
4043 return FAIL; | |
188 | 4044 if (start != NULL) |
4045 { | |
211 | 4046 if (end == NULL) |
4047 { | |
4048 end = start + STRLEN(start); | |
4049 while (end > start && (end[-1] == '\r' || end[-1] == '\n')) | |
4050 --end; | |
4051 } | |
835 | 4052 len = (int)(end - start); |
2770 | 4053 if (len > MAXPATHL - 1) |
4054 len = MAXPATHL - 1; | |
418 | 4055 vim_strncpy(buf, start, len); |
188 | 4056 } |
179 | 4057 buf[len] = NUL; |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14232
diff
changeset
|
4058 retval = dict_add_string(dict, field_name, buf); |
2770 | 4059 vim_free(buf); |
4060 return retval; | |
179 | 4061 } |
4062 | |
4063 /* | |
11225
d3415ec1cdaf
patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
4064 * Add the tags matching the specified pattern "pat" to the list "list" |
d3415ec1cdaf
patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
4065 * as a dictionary. Use "buf_fname" for priority, unless NULL. |
179 | 4066 */ |
4067 int | |
11225
d3415ec1cdaf
patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
4068 get_tags(list_T *list, char_u *pat, char_u *buf_fname) |
179 | 4069 { |
4070 int num_matches, i, ret; | |
4071 char_u **matches, *p; | |
970 | 4072 char_u *full_fname; |
179 | 4073 dict_T *dict; |
4074 tagptrs_T tp; | |
4075 long is_static; | |
4076 | |
4077 ret = find_tags(pat, &num_matches, &matches, | |
11225
d3415ec1cdaf
patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
4078 TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname); |
179 | 4079 if (ret == OK && num_matches > 0) |
4080 { | |
4081 for (i = 0; i < num_matches; ++i) | |
4082 { | |
188 | 4083 parse_match(matches[i], &tp); |
4084 is_static = test_for_static(&tp); | |
4085 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4086 // Skip pseudo-tag lines. |
188 | 4087 if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0) |
19237
1a3ebc75cf39
patch 8.2.0177: memory leak in get_tags()
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4088 { |
1a3ebc75cf39
patch 8.2.0177: memory leak in get_tags()
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4089 vim_free(matches[i]); |
188 | 4090 continue; |
19237
1a3ebc75cf39
patch 8.2.0177: memory leak in get_tags()
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4091 } |
188 | 4092 |
179 | 4093 if ((dict = dict_alloc()) == NULL) |
4094 ret = FAIL; | |
4095 if (list_append_dict(list, dict) == FAIL) | |
4096 ret = FAIL; | |
4097 | |
970 | 4098 full_fname = tag_full_fname(&tp); |
179 | 4099 if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL |
970 | 4100 || add_tag_field(dict, "filename", full_fname, |
4101 NULL) == FAIL | |
179 | 4102 || add_tag_field(dict, "cmd", tp.command, |
4103 tp.command_end) == FAIL | |
4104 || add_tag_field(dict, "kind", tp.tagkind, | |
4105 tp.tagkind_end) == FAIL | |
14301
3c80092eb211
patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents:
14232
diff
changeset
|
4106 || dict_add_number(dict, "static", is_static) == FAIL) |
179 | 4107 ret = FAIL; |
4108 | |
970 | 4109 vim_free(full_fname); |
4110 | |
179 | 4111 if (tp.command_end != NULL) |
4112 { | |
4113 for (p = tp.command_end + 3; | |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
4114 *p != NUL && *p != '\n' && *p != '\r'; MB_PTR_ADV(p)) |
179 | 4115 { |
4116 if (p == tp.tagkind || (p + 5 == tp.tagkind | |
4117 && STRNCMP(p, "kind:", 5) == 0)) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4118 // skip "kind:<kind>" and "<kind>" |
179 | 4119 p = tp.tagkind_end - 1; |
4120 else if (STRNCMP(p, "file:", 5) == 0) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4121 // skip "file:" (static tag) |
179 | 4122 p += 4; |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
4123 else if (!VIM_ISWHITE(*p)) |
179 | 4124 { |
4125 char_u *s, *n; | |
188 | 4126 int len; |
179 | 4127 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4128 // Add extra field as a dict entry. Fields are |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4129 // separated by Tabs. |
179 | 4130 n = p; |
799 | 4131 while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') |
179 | 4132 ++p; |
835 | 4133 len = (int)(p - n); |
188 | 4134 if (*p == ':' && len > 0) |
4135 { | |
4136 s = ++p; | |
836 | 4137 while (*p != NUL && *p >= ' ') |
188 | 4138 ++p; |
4139 n[len] = NUL; | |
4140 if (add_tag_field(dict, (char *)n, s, p) == FAIL) | |
4141 ret = FAIL; | |
4142 n[len] = ':'; | |
4143 } | |
836 | 4144 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4145 // Skip field without colon. |
836 | 4146 while (*p != NUL && *p >= ' ') |
4147 ++p; | |
1674 | 4148 if (*p == NUL) |
4149 break; | |
179 | 4150 } |
4151 } | |
4152 } | |
4153 | |
4154 vim_free(matches[i]); | |
4155 } | |
4156 vim_free(matches); | |
4157 } | |
4158 return ret; | |
4159 } | |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4160 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4161 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4162 * Return information about 'tag' in dict 'retdict'. |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4163 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4164 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4165 get_tag_details(taggy_T *tag, dict_T *retdict) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4166 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4167 list_T *pos; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4168 fmark_T *fmark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4169 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4170 dict_add_string(retdict, "tagname", tag->tagname); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4171 dict_add_number(retdict, "matchnr", tag->cur_match + 1); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4172 dict_add_number(retdict, "bufnr", tag->cur_fnum); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4173 if (tag->user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4174 dict_add_string(retdict, "user_data", tag->user_data); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4175 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4176 if ((pos = list_alloc_id(aid_tagstack_from)) == NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4177 return; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4178 dict_add_list(retdict, "from", pos); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4179 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4180 fmark = &tag->fmark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4181 list_append_number(pos, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4182 (varnumber_T)(fmark->fnum != -1 ? fmark->fnum : 0)); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4183 list_append_number(pos, (varnumber_T)fmark->mark.lnum); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4184 list_append_number(pos, (varnumber_T)(fmark->mark.col == MAXCOL ? |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4185 MAXCOL : fmark->mark.col + 1)); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4186 list_append_number(pos, (varnumber_T)fmark->mark.coladd); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4187 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4188 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4189 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4190 * Return the tag stack entries of the specified window 'wp' in dictionary |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4191 * 'retdict'. |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4192 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4193 void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4194 get_tagstack(win_T *wp, dict_T *retdict) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4195 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4196 list_T *l; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4197 int i; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4198 dict_T *d; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4199 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4200 dict_add_number(retdict, "length", wp->w_tagstacklen); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4201 dict_add_number(retdict, "curidx", wp->w_tagstackidx + 1); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4202 l = list_alloc_id(aid_tagstack_items); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4203 if (l == NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4204 return; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4205 dict_add_list(retdict, "items", l); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4206 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4207 for (i = 0; i < wp->w_tagstacklen; i++) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4208 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4209 if ((d = dict_alloc_id(aid_tagstack_details)) == NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4210 return; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4211 list_append_dict(l, d); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4212 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4213 get_tag_details(&wp->w_tagstack[i], d); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4214 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4215 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4216 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4217 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4218 * Free all the entries in the tag stack of the specified window |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4219 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4220 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4221 tagstack_clear(win_T *wp) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4222 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4223 int i; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4224 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4225 // Free the current tag stack |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4226 for (i = 0; i < wp->w_tagstacklen; ++i) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4227 tagstack_clear_entry(&wp->w_tagstack[i]); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4228 wp->w_tagstacklen = 0; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4229 wp->w_tagstackidx = 0; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4230 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4231 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4232 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4233 * Remove the oldest entry from the tag stack and shift the rest of |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19055
diff
changeset
|
4234 * the entries to free up the top of the stack. |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4235 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4236 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4237 tagstack_shift(win_T *wp) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4238 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4239 taggy_T *tagstack = wp->w_tagstack; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4240 int i; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4241 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4242 tagstack_clear_entry(&tagstack[0]); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4243 for (i = 1; i < wp->w_tagstacklen; ++i) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4244 tagstack[i - 1] = tagstack[i]; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4245 wp->w_tagstacklen--; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4246 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4247 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4248 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4249 * Push a new item to the tag stack |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4250 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4251 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4252 tagstack_push_item( |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4253 win_T *wp, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4254 char_u *tagname, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4255 int cur_fnum, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4256 int cur_match, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4257 pos_T mark, |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4258 int fnum, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4259 char_u *user_data) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4260 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4261 taggy_T *tagstack = wp->w_tagstack; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4262 int idx = wp->w_tagstacklen; // top of the stack |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4263 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4264 // if the tagstack is full: remove the oldest entry |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4265 if (idx >= TAGSTACKSIZE) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4266 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4267 tagstack_shift(wp); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4268 idx = TAGSTACKSIZE - 1; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4269 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4270 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4271 wp->w_tagstacklen++; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4272 tagstack[idx].tagname = tagname; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4273 tagstack[idx].cur_fnum = cur_fnum; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4274 tagstack[idx].cur_match = cur_match; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4275 if (tagstack[idx].cur_match < 0) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4276 tagstack[idx].cur_match = 0; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4277 tagstack[idx].fmark.mark = mark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4278 tagstack[idx].fmark.fnum = fnum; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4279 tagstack[idx].user_data = user_data; |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4280 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4281 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4282 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4283 * Add a list of items to the tag stack in the specified window |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4284 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4285 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4286 tagstack_push_items(win_T *wp, list_T *l) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4287 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4288 listitem_T *li; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4289 dictitem_T *di; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4290 dict_T *itemdict; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4291 char_u *tagname; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4292 pos_T mark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4293 int fnum; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4294 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4295 // Add one entry at a time to the tag stack |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19617
diff
changeset
|
4296 FOR_ALL_LIST_ITEMS(l, li) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4297 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4298 if (li->li_tv.v_type != VAR_DICT || li->li_tv.vval.v_dict == NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4299 continue; // Skip non-dict items |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4300 itemdict = li->li_tv.vval.v_dict; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4301 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4302 // parse 'from' for the cursor position before the tag jump |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4303 if ((di = dict_find(itemdict, (char_u *)"from", -1)) == NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4304 continue; |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
4305 if (list2fpos(&di->di_tv, &mark, &fnum, NULL, FALSE) != OK) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4306 continue; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4307 if ((tagname = |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15016
diff
changeset
|
4308 dict_get_string(itemdict, (char_u *)"tagname", TRUE)) == NULL) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4309 continue; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4310 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4311 if (mark.col > 0) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4312 mark.col--; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4313 tagstack_push_item(wp, tagname, |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15016
diff
changeset
|
4314 (int)dict_get_number(itemdict, (char_u *)"bufnr"), |
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15016
diff
changeset
|
4315 (int)dict_get_number(itemdict, (char_u *)"matchnr") - 1, |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4316 mark, fnum, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4317 dict_get_string(itemdict, (char_u *)"user_data", TRUE)); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4318 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4319 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4320 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4321 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4322 * Set the current index in the tag stack. Valid values are between 0 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4323 * and the stack length (inclusive). |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4324 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4325 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4326 tagstack_set_curidx(win_T *wp, int curidx) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4327 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4328 wp->w_tagstackidx = curidx; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4329 if (wp->w_tagstackidx < 0) // sanity check |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4330 wp->w_tagstackidx = 0; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4331 if (wp->w_tagstackidx > wp->w_tagstacklen) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4332 wp->w_tagstackidx = wp->w_tagstacklen; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4333 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4334 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4335 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4336 * Set the tag stack entries of the specified window. |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4337 * 'action' is set to one of: |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4338 * 'a' for append |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4339 * 'r' for replace |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4340 * 't' for truncate |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4341 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4342 int |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4343 set_tagstack(win_T *wp, dict_T *d, int action) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4344 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4345 dictitem_T *di; |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4346 list_T *l = NULL; |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4347 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4348 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4349 // not allowed to alter the tag stack entries from inside tagfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4350 if (tfu_in_use) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4351 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4352 emsg(_(recurmsg)); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4353 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4354 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4355 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4356 |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4357 if ((di = dict_find(d, (char_u *)"items", -1)) != NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4358 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4359 if (di->di_tv.v_type != VAR_LIST) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4360 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
4361 emsg(_(e_list_required)); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4362 return FAIL; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4363 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4364 l = di->di_tv.vval.v_list; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4365 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4366 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4367 if ((di = dict_find(d, (char_u *)"curidx", -1)) != NULL) |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15146
diff
changeset
|
4368 tagstack_set_curidx(wp, (int)tv_get_number(&di->di_tv) - 1); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4369 |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4370 if (action == 't') // truncate the stack |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4371 { |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4372 taggy_T *tagstack = wp->w_tagstack; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4373 int tagstackidx = wp->w_tagstackidx; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4374 int tagstacklen = wp->w_tagstacklen; |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19237
diff
changeset
|
4375 |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4376 // delete all the tag stack entries above the current entry |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4377 while (tagstackidx < tagstacklen) |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4378 tagstack_clear_entry(&tagstack[--tagstacklen]); |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4379 wp->w_tagstacklen = tagstacklen; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4380 } |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4381 |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4382 if (l != NULL) |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4383 { |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4384 if (action == 'r') // replace the stack |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4385 tagstack_clear(wp); |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4386 |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4387 tagstack_push_items(wp, l); |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4388 // set the current index after the last entry |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4389 wp->w_tagstackidx = wp->w_tagstacklen; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4390 } |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4391 |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4392 return OK; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4393 } |
179 | 4394 #endif |