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