Mercurial > vim
annotate src/tag.c @ 27978:442ca2007bec v8.2.4514
patch 8.2.4514: Vim9: some flow commands can be shortened
Commit: https://github.com/vim/vim/commit/b2175220dafc28349b275ac7f3080f89cce78a57
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 5 20:24:41 2022 +0000
patch 8.2.4514: Vim9: some flow commands can be shortened
Problem: Vim9: some flow commands can be shortened.
Solution: Also require using the full name for ":return", ":enddef",
":continue", ":export" and ":import".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 05 Mar 2022 21:30:03 +0100 |
parents | 495418c6cac8 |
children | c724906134a3 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9949
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * Code to handle tags and the tag stack | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 /* | |
17 * Structure to hold pointers to various items in a tag line. | |
18 */ | |
19 typedef struct tag_pointers | |
20 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
21 // filled in by parse_tag_line(): |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
22 char_u *tagname; // start of tag name (skip "file:") |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
23 char_u *tagname_end; // char after tag name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
24 char_u *fname; // first char of file name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
25 char_u *fname_end; // char after file name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
26 char_u *command; // first char of command |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
27 // filled in by parse_match(): |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
28 char_u *command_end; // first char after command |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
29 char_u *tag_fname; // file name of the tags file. This is used |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
30 // when 'tr' is set. |
7 | 31 #ifdef FEAT_EMACS_TAGS |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
32 int is_etag; // TRUE for emacs tag |
7 | 33 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
34 char_u *tagkind; // "kind:" value |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
35 char_u *tagkind_end; // end of tagkind |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
36 char_u *user_data; // user_data string |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
37 char_u *user_data_end; // end of user_data |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
38 linenr_T tagline; // "line:" value |
7 | 39 } tagptrs_T; |
40 | |
41 /* | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
42 * The matching tags are first stored in one of the hash tables. In |
10601
1b09db809d3f
patch 8.0.0190: finding duplicate tags uses a slow linear search
Christian Brabandt <cb@256bit.org>
parents:
10444
diff
changeset
|
43 * which one depends on the priority of the match. |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
44 * ht_match[] is used to find duplicates, ga_match[] to keep them in sequence. |
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
45 * At the end, all the matches from ga_match[] are concatenated, to make a list |
7 | 46 * sorted on priority. |
47 */ | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
48 #define MT_ST_CUR 0 // static match in current file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
49 #define MT_GL_CUR 1 // global match in current file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
50 #define MT_GL_OTH 2 // global match in other file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
51 #define MT_ST_OTH 3 // static match in other file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
52 #define MT_IC_OFF 4 // add for icase match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
53 #define MT_RE_OFF 8 // add for regexp match |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
54 #define MT_MASK 7 // mask for printing priority |
7 | 55 #define MT_COUNT 16 |
56 | |
57 static char *mt_names[MT_COUNT/2] = | |
58 {"FSC", "F C", "F ", "FS ", " SC", " C", " ", " S "}; | |
59 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
60 #define NOTAGFILE 99 // return value for jumpto_tag |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
61 static char_u *nofile_fname = NULL; // fname for NOTAGFILE error |
7 | 62 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
63 static void taglen_advance(int l); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
64 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
65 static int jumpto_tag(char_u *lbuf, int forceit, int keep_help); |
7 | 66 #ifdef FEAT_EMACS_TAGS |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
67 static int parse_tag_line(char_u *lbuf, int is_etag, tagptrs_T *tagp); |
7 | 68 #else |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
69 static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp); |
7 | 70 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
71 static int test_for_static(tagptrs_T *); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
72 static int parse_match(char_u *lbuf, tagptrs_T *tagp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
73 static char_u *tag_full_fname(tagptrs_T *tagp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
74 static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand); |
7 | 75 #ifdef FEAT_EMACS_TAGS |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
76 static int test_for_current(int, char_u *, char_u *, char_u *, char_u *); |
7 | 77 #else |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
78 static int test_for_current(char_u *, char_u *, char_u *, char_u *); |
7 | 79 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7266
diff
changeset
|
80 static int find_extra(char_u **pp); |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
81 static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char_u **matches); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
82 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
83 static int add_llist_tags(char_u *tag, int num_matches, char_u **matches); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
84 #endif |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
85 static void tagstack_clear_entry(taggy_T *item); |
7 | 86 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
87 static char_u *tagmatchname = NULL; // name of last used tag |
7 | 88 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
89 #if defined(FEAT_QUICKFIX) |
7 | 90 /* |
91 * Tag for preview window is remembered separately, to avoid messing up the | |
92 * normal tagstack. | |
93 */ | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
94 static taggy_T ptag_entry = {NULL, {{0, 0, 0}, 0}, 0, 0, NULL}; |
7 | 95 #endif |
96 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
97 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
98 static int tfu_in_use = FALSE; // disallow recursive call of tagfunc |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
99 static callback_T tfu_cb; // 'tagfunc' callback function |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
100 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
101 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
102 // Used instead of NUL to separate tag fields in the growarrays. |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
103 #define TAG_SEP 0x02 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
104 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
105 #if defined(FEAT_EVAL) || defined(PROTO) |
7 | 106 /* |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
107 * Reads the 'tagfunc' option value and convert that to a callback value. |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
108 * Invoked when the 'tagfunc' option is set. The option value can be a name of |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
109 * a function (string), or function(<name>) or funcref(<name>) or a lambda. |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
110 */ |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
111 int |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
112 set_tagfunc_option(void) |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
113 { |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
114 #ifdef FEAT_EVAL |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
115 free_callback(&tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
116 free_callback(&curbuf->b_tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
117 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
118 if (*curbuf->b_p_tfu == NUL) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
119 return OK; |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
120 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
121 if (option_set_callback_func(curbuf->b_p_tfu, &tfu_cb) == FAIL) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
122 return FAIL; |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
123 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
124 copy_callback(&curbuf->b_tfu_cb, &tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
125 #endif |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
126 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
127 return OK; |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
128 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
129 #endif |
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
130 |
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
131 # if defined(EXITFREE) || defined(PROTO) |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
132 void |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
133 free_tagfunc_option(void) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
134 { |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
135 # ifdef FEAT_EVAL |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
136 free_callback(&tfu_cb); |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
137 # endif |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
138 } |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
139 # endif |
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
140 |
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
141 #if defined(FEAT_EVAL) || defined(PROTO) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
142 /* |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
143 * Mark the global 'tagfunc' callback with 'copyID' so that it is not garbage |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
144 * collected. |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
145 */ |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
146 int |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
147 set_ref_in_tagfunc(int copyID UNUSED) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
148 { |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
149 int abort = FALSE; |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
150 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
151 abort = set_ref_in_callback(&tfu_cb, copyID); |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
152 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
153 return abort; |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26492
diff
changeset
|
154 } |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
155 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
156 /* |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
157 * Copy the global 'tagfunc' callback function to the buffer-local 'tagfunc' |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
158 * callback for 'buf'. |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
159 */ |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
160 void |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
161 set_buflocal_tfu_callback(buf_T *buf UNUSED) |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
162 { |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
163 free_callback(&buf->b_tfu_cb); |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
164 if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL) |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
165 copy_callback(&buf->b_tfu_cb, &tfu_cb); |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
166 } |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
167 #endif |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
168 |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
169 /* |
7 | 170 * Jump to tag; handling of tag commands and tag stack |
171 * | |
172 * *tag != NUL: ":tag {tag}", jump to new tag, add to tag stack | |
173 * | |
174 * type == DT_TAG: ":tag [tag]", jump to newer position or same tag again | |
175 * type == DT_HELP: like DT_TAG, but don't use regexp. | |
176 * type == DT_POP: ":pop" or CTRL-T, jump to old position | |
177 * type == DT_NEXT: jump to next match of same tag | |
178 * type == DT_PREV: jump to previous match of same tag | |
179 * type == DT_FIRST: jump to first match of same tag | |
180 * type == DT_LAST: jump to last match of same tag | |
181 * type == DT_SELECT: ":tselect [tag]", select tag from a list of all matches | |
182 * type == DT_JUMP: ":tjump [tag]", jump to tag or select tag from a list | |
359 | 183 * type == DT_CSCOPE: use cscope to find the tag |
649 | 184 * type == DT_LTAG: use location list for displaying tag matches |
359 | 185 * type == DT_FREE: free cached matches |
7 | 186 * |
187 * for cscope, returns TRUE if we jumped to tag or aborted, FALSE otherwise | |
188 */ | |
189 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
190 do_tag( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
191 char_u *tag, // tag (pattern) to jump to |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
192 int type, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
193 int count, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
194 int forceit, // :ta with ! |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
195 int verbose) // print "tag not found" message |
7 | 196 { |
197 taggy_T *tagstack = curwin->w_tagstack; | |
198 int tagstackidx = curwin->w_tagstackidx; | |
199 int tagstacklen = curwin->w_tagstacklen; | |
200 int cur_match = 0; | |
201 int cur_fnum = curbuf->b_fnum; | |
202 int oldtagstackidx = tagstackidx; | |
203 int prevtagstackidx = tagstackidx; | |
204 int prev_num_matches; | |
205 int new_tag = FALSE; | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
206 int i; |
7 | 207 int ic; |
208 int no_regexp = FALSE; | |
209 int error_cur_match = 0; | |
210 int save_pos = FALSE; | |
211 fmark_T saved_fmark; | |
212 #ifdef FEAT_CSCOPE | |
213 int jumped_to_tag = FALSE; | |
214 #endif | |
215 int new_num_matches; | |
216 char_u **new_matches; | |
217 int use_tagstack; | |
218 int skip_msg = FALSE; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
219 char_u *buf_ffname = curbuf->b_ffname; // name to use for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
220 // priority computation |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
221 int use_tfu = 1; |
7 | 222 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
223 // remember the matches for the last used tag |
7 | 224 static int num_matches = 0; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
225 static int max_num_matches = 0; // limit used for match search |
7 | 226 static char_u **matches = NULL; |
227 static int flags; | |
228 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
229 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
230 if (tfu_in_use) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
231 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
232 emsg(_(e_cannot_modify_tag_stack_within_tagfunc)); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
233 return FALSE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
234 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
235 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
236 |
359 | 237 #ifdef EXITFREE |
238 if (type == DT_FREE) | |
239 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
240 // remove the list of matches |
359 | 241 FreeWild(num_matches, matches); |
242 # ifdef FEAT_CSCOPE | |
243 cs_free_tags(); | |
244 # endif | |
245 num_matches = 0; | |
246 return FALSE; | |
247 } | |
248 #endif | |
249 | |
7 | 250 if (type == DT_HELP) |
251 { | |
252 type = DT_TAG; | |
253 no_regexp = TRUE; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
254 use_tfu = 0; |
7 | 255 } |
256 | |
257 prev_num_matches = num_matches; | |
258 free_string_option(nofile_fname); | |
259 nofile_fname = NULL; | |
260 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
261 CLEAR_POS(&saved_fmark.mark); // shutup gcc 4.0 |
698 | 262 saved_fmark.fnum = 0; |
263 | |
7 | 264 /* |
265 * Don't add a tag to the tagstack if 'tagstack' has been reset. | |
266 */ | |
267 if ((!p_tgst && *tag != NUL)) | |
268 { | |
269 use_tagstack = FALSE; | |
270 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
|
271 #if defined(FEAT_QUICKFIX) |
8930
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
272 if (g_do_tagpreview != 0) |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
273 { |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
274 tagstack_clear_entry(&ptag_entry); |
8930
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
275 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
|
276 goto end_do_tag; |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
277 } |
a2aca019ba48
commit https://github.com/vim/vim/commit/def5abe0a2727041ecee69afdccfca405333bd24
Christian Brabandt <cb@256bit.org>
parents:
8863
diff
changeset
|
278 #endif |
7 | 279 } |
280 else | |
281 { | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
282 #if defined(FEAT_QUICKFIX) |
2713 | 283 if (g_do_tagpreview != 0) |
7 | 284 use_tagstack = FALSE; |
285 else | |
286 #endif | |
287 use_tagstack = TRUE; | |
288 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
289 // new pattern, add to the tag stack |
845 | 290 if (*tag != NUL |
291 && (type == DT_TAG || type == DT_SELECT || type == DT_JUMP | |
649 | 292 #ifdef FEAT_QUICKFIX |
293 || type == DT_LTAG | |
294 #endif | |
7 | 295 #ifdef FEAT_CSCOPE |
296 || type == DT_CSCOPE | |
297 #endif | |
298 )) | |
299 { | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
300 #if defined(FEAT_QUICKFIX) |
2713 | 301 if (g_do_tagpreview != 0) |
7 | 302 { |
303 if (ptag_entry.tagname != NULL | |
304 && STRCMP(ptag_entry.tagname, tag) == 0) | |
305 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
306 // Jumping to same tag: keep the current match, so that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
307 // the CursorHold autocommand example works. |
7 | 308 cur_match = ptag_entry.cur_match; |
309 cur_fnum = ptag_entry.cur_fnum; | |
310 } | |
311 else | |
312 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
313 tagstack_clear_entry(&ptag_entry); |
7 | 314 if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) |
315 goto end_do_tag; | |
316 } | |
317 } | |
318 else | |
319 #endif | |
320 { | |
321 /* | |
322 * If the last used entry is not at the top, delete all tag | |
323 * stack entries above it. | |
324 */ | |
325 while (tagstackidx < tagstacklen) | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
326 tagstack_clear_entry(&tagstack[--tagstacklen]); |
7 | 327 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
328 // if the tagstack is full: remove oldest entry |
7 | 329 if (++tagstacklen > TAGSTACKSIZE) |
330 { | |
331 tagstacklen = TAGSTACKSIZE; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
332 tagstack_clear_entry(&tagstack[0]); |
7 | 333 for (i = 1; i < tagstacklen; ++i) |
334 tagstack[i - 1] = tagstack[i]; | |
335 --tagstackidx; | |
336 } | |
337 | |
338 /* | |
339 * put the tag name in the tag stack | |
340 */ | |
341 if ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL) | |
342 { | |
343 curwin->w_tagstacklen = tagstacklen - 1; | |
344 goto end_do_tag; | |
345 } | |
346 curwin->w_tagstacklen = tagstacklen; | |
347 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
348 save_pos = TRUE; // save the cursor position below |
7 | 349 } |
350 | |
351 new_tag = TRUE; | |
352 } | |
353 else | |
354 { | |
355 if ( | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
356 #if defined(FEAT_QUICKFIX) |
2713 | 357 g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : |
7 | 358 #endif |
359 tagstacklen == 0) | |
360 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
361 // empty stack |
26436
ef0c07cbf53f
patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
362 emsg(_(e_tag_stack_empty)); |
7 | 363 goto end_do_tag; |
364 } | |
365 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
366 if (type == DT_POP) // go to older position |
7 | 367 { |
368 #ifdef FEAT_FOLDING | |
369 int old_KeyTyped = KeyTyped; | |
370 #endif | |
371 if ((tagstackidx -= count) < 0) | |
372 { | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
373 emsg(_(e_at_bottom_of_tag_stack)); |
7 | 374 if (tagstackidx + count == 0) |
375 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
376 // We did [num]^T from the bottom of the stack |
7 | 377 tagstackidx = 0; |
378 goto end_do_tag; | |
379 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
380 // We weren't at the bottom of the stack, so jump all the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
381 // way to the bottom now. |
7 | 382 tagstackidx = 0; |
383 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
384 else if (tagstackidx >= tagstacklen) // count == 0? |
7 | 385 { |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
386 emsg(_(e_at_top_of_tag_stack)); |
7 | 387 goto end_do_tag; |
388 } | |
389 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
390 // Make a copy of the fmark, autocommands may invalidate the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
391 // tagstack before it's used. |
7 | 392 saved_fmark = tagstack[tagstackidx].fmark; |
393 if (saved_fmark.fnum != curbuf->b_fnum) | |
394 { | |
395 /* | |
396 * Jump to other file. If this fails (e.g. because the | |
397 * file was changed) keep original position in tag stack. | |
398 */ | |
399 if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum, | |
400 GETF_SETMARK, forceit) == FAIL) | |
401 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
402 tagstackidx = oldtagstackidx; // back to old posn |
7 | 403 goto end_do_tag; |
404 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
405 // An BufReadPost autocommand may jump to the '" mark, but |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
406 // we don't what that here. |
7 | 407 curwin->w_cursor.lnum = saved_fmark.mark.lnum; |
408 } | |
409 else | |
410 { | |
411 setpcmark(); | |
412 curwin->w_cursor.lnum = saved_fmark.mark.lnum; | |
413 } | |
414 curwin->w_cursor.col = saved_fmark.mark.col; | |
415 curwin->w_set_curswant = TRUE; | |
416 check_cursor(); | |
417 #ifdef FEAT_FOLDING | |
418 if ((fdo_flags & FDO_TAG) && old_KeyTyped) | |
419 foldOpenCursor(); | |
420 #endif | |
421 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
422 // remove the old list of matches |
7 | 423 FreeWild(num_matches, matches); |
424 #ifdef FEAT_CSCOPE | |
425 cs_free_tags(); | |
426 #endif | |
427 num_matches = 0; | |
845 | 428 tag_freematch(); |
7 | 429 goto end_do_tag; |
430 } | |
431 | |
692 | 432 if (type == DT_TAG |
433 #if defined(FEAT_QUICKFIX) | |
845 | 434 || type == DT_LTAG |
692 | 435 #endif |
845 | 436 ) |
7 | 437 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
438 #if defined(FEAT_QUICKFIX) |
2713 | 439 if (g_do_tagpreview != 0) |
7 | 440 { |
441 cur_match = ptag_entry.cur_match; | |
442 cur_fnum = ptag_entry.cur_fnum; | |
443 } | |
444 else | |
445 #endif | |
446 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
447 // ":tag" (no argument): go to newer pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
448 save_pos = TRUE; // save the cursor position below |
7 | 449 if ((tagstackidx += count - 1) >= tagstacklen) |
450 { | |
451 /* | |
452 * Beyond the last one, just give an error message and | |
453 * go to the last one. Don't store the cursor | |
1204 | 454 * position. |
7 | 455 */ |
456 tagstackidx = tagstacklen - 1; | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
457 emsg(_(e_at_top_of_tag_stack)); |
7 | 458 save_pos = FALSE; |
459 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
460 else if (tagstackidx < 0) // must have been count == 0 |
7 | 461 { |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
462 emsg(_(e_at_bottom_of_tag_stack)); |
7 | 463 tagstackidx = 0; |
464 goto end_do_tag; | |
465 } | |
466 cur_match = tagstack[tagstackidx].cur_match; | |
467 cur_fnum = tagstack[tagstackidx].cur_fnum; | |
468 } | |
469 new_tag = TRUE; | |
470 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
471 else // go to other matching tag |
7 | 472 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
473 // Save index for when selection is cancelled. |
7 | 474 prevtagstackidx = tagstackidx; |
475 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
476 #if defined(FEAT_QUICKFIX) |
2713 | 477 if (g_do_tagpreview != 0) |
7 | 478 { |
479 cur_match = ptag_entry.cur_match; | |
480 cur_fnum = ptag_entry.cur_fnum; | |
481 } | |
482 else | |
483 #endif | |
484 { | |
485 if (--tagstackidx < 0) | |
486 tagstackidx = 0; | |
487 cur_match = tagstack[tagstackidx].cur_match; | |
488 cur_fnum = tagstack[tagstackidx].cur_fnum; | |
489 } | |
490 switch (type) | |
491 { | |
492 case DT_FIRST: cur_match = count - 1; break; | |
493 case DT_SELECT: | |
494 case DT_JUMP: | |
495 #ifdef FEAT_CSCOPE | |
496 case DT_CSCOPE: | |
497 #endif | |
498 case DT_LAST: cur_match = MAXCOL - 1; break; | |
499 case DT_NEXT: cur_match += count; break; | |
500 case DT_PREV: cur_match -= count; break; | |
501 } | |
502 if (cur_match >= MAXCOL) | |
503 cur_match = MAXCOL - 1; | |
504 else if (cur_match < 0) | |
505 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
506 emsg(_(e_cannot_go_before_first_matching_tag)); |
7 | 507 skip_msg = TRUE; |
508 cur_match = 0; | |
509 cur_fnum = curbuf->b_fnum; | |
510 } | |
511 } | |
512 } | |
513 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
514 #if defined(FEAT_QUICKFIX) |
2713 | 515 if (g_do_tagpreview != 0) |
7 | 516 { |
517 if (type != DT_SELECT && type != DT_JUMP) | |
518 { | |
519 ptag_entry.cur_match = cur_match; | |
520 ptag_entry.cur_fnum = cur_fnum; | |
521 } | |
522 } | |
523 else | |
524 #endif | |
525 { | |
526 /* | |
527 * For ":tag [arg]" or ":tselect" remember position before the jump. | |
528 */ | |
529 saved_fmark = tagstack[tagstackidx].fmark; | |
530 if (save_pos) | |
531 { | |
532 tagstack[tagstackidx].fmark.mark = curwin->w_cursor; | |
533 tagstack[tagstackidx].fmark.fnum = curbuf->b_fnum; | |
534 } | |
535 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
536 // Curwin will change in the call to jumpto_tag() if ":stag" was |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
537 // used or an autocommand jumps to another window; store value of |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
538 // tagstackidx now. |
7 | 539 curwin->w_tagstackidx = tagstackidx; |
540 if (type != DT_SELECT && type != DT_JUMP) | |
541 { | |
542 curwin->w_tagstack[tagstackidx].cur_match = cur_match; | |
543 curwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum; | |
544 } | |
545 } | |
546 } | |
547 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
548 // When not using the current buffer get the name of buffer "cur_fnum". |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
549 // Makes sure that the tag order doesn't change when using a remembered |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
550 // position for "cur_match". |
7 | 551 if (cur_fnum != curbuf->b_fnum) |
552 { | |
553 buf_T *buf = buflist_findnr(cur_fnum); | |
554 | |
555 if (buf != NULL) | |
556 buf_ffname = buf->b_ffname; | |
557 } | |
558 | |
559 /* | |
560 * Repeat searching for tags, when a file has not been found. | |
561 */ | |
562 for (;;) | |
563 { | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
564 int other_name; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
565 char_u *name; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
566 |
7 | 567 /* |
568 * When desired match not found yet, try to find it (and others). | |
569 */ | |
570 if (use_tagstack) | |
571 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
|
572 #if defined(FEAT_QUICKFIX) |
2713 | 573 else if (g_do_tagpreview != 0) |
7 | 574 name = ptag_entry.tagname; |
575 #endif | |
576 else | |
577 name = tag; | |
578 other_name = (tagmatchname == NULL || STRCMP(tagmatchname, name) != 0); | |
579 if (new_tag | |
580 || (cur_match >= num_matches && max_num_matches != MAXCOL) | |
581 || other_name) | |
582 { | |
583 if (other_name) | |
584 { | |
585 vim_free(tagmatchname); | |
586 tagmatchname = vim_strsave(name); | |
587 } | |
588 | |
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_SELECT || type == DT_JUMP |
692 | 590 #if defined(FEAT_QUICKFIX) |
591 || type == DT_LTAG | |
592 #endif | |
593 ) | |
7 | 594 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
|
595 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
|
596 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
|
597 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
|
598 max_num_matches = cur_match + 1; |
7 | 599 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
600 // when the argument starts with '/', use it as a regexp |
7 | 601 if (!no_regexp && *name == '/') |
602 { | |
603 flags = TAG_REGEXP; | |
604 ++name; | |
605 } | |
606 else | |
607 flags = TAG_NOIC; | |
608 | |
609 #ifdef FEAT_CSCOPE | |
610 if (type == DT_CSCOPE) | |
611 flags = TAG_CSCOPE; | |
612 #endif | |
613 if (verbose) | |
614 flags |= TAG_VERBOSE; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
615 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
616 if (!use_tfu) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
617 flags |= TAG_NO_TAGFUNC; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
618 |
7 | 619 if (find_tags(name, &new_num_matches, &new_matches, flags, |
620 max_num_matches, buf_ffname) == OK | |
621 && new_num_matches < max_num_matches) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
622 max_num_matches = MAXCOL; // If less than max_num_matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
623 // found: all matches found. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
624 |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
625 // If there already were some matches for the same name, move them |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
626 // to the start. Avoids that the order changes when using |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
627 // ":tnext" and jumping to another file. |
7 | 628 if (!new_tag && !other_name) |
629 { | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
630 int j, k; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
631 int idx = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
632 tagptrs_T tagp, tagp2; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
633 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
634 // Find the position of each old match in the new list. Need |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
635 // to use parse_match() to find the tag line. |
7 | 636 for (j = 0; j < num_matches; ++j) |
637 { | |
638 parse_match(matches[j], &tagp); | |
639 for (i = idx; i < new_num_matches; ++i) | |
640 { | |
641 parse_match(new_matches[i], &tagp2); | |
642 if (STRCMP(tagp.tagname, tagp2.tagname) == 0) | |
643 { | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
644 char_u *p = new_matches[i]; |
7 | 645 for (k = i; k > idx; --k) |
646 new_matches[k] = new_matches[k - 1]; | |
647 new_matches[idx++] = p; | |
648 break; | |
649 } | |
650 } | |
651 } | |
652 } | |
653 FreeWild(num_matches, matches); | |
654 num_matches = new_num_matches; | |
655 matches = new_matches; | |
656 } | |
657 | |
658 if (num_matches <= 0) | |
659 { | |
660 if (verbose) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
661 semsg(_(e_tag_not_found_str), name); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
662 #if defined(FEAT_QUICKFIX) |
7 | 663 g_do_tagpreview = 0; |
664 #endif | |
665 } | |
666 else | |
667 { | |
668 int ask_for_selection = FALSE; | |
669 | |
670 #ifdef FEAT_CSCOPE | |
671 if (type == DT_CSCOPE && num_matches > 1) | |
672 { | |
673 cs_print_tags(); | |
674 ask_for_selection = TRUE; | |
675 } | |
676 else | |
677 #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
|
678 if (type == DT_TAG && *tag != NUL) |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
679 // If a count is supplied to the ":tag <name>" command, then |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
680 // jump to count'th matching tag. |
6851 | 681 cur_match = count > 0 ? count - 1 : 0; |
682 else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1)) | |
7 | 683 { |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
684 print_tag_list(new_tag, use_tagstack, num_matches, matches); |
7 | 685 ask_for_selection = TRUE; |
686 } | |
649 | 687 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
692 | 688 else if (type == DT_LTAG) |
649 | 689 { |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
690 if (add_llist_tags(tag, num_matches, matches) == FAIL) |
649 | 691 goto end_do_tag; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
692 cur_match = 0; // Jump to the first tag |
649 | 693 } |
694 #endif | |
7 | 695 |
696 if (ask_for_selection == TRUE) | |
697 { | |
698 /* | |
699 * Ask to select a tag from the list. | |
700 */ | |
373 | 701 i = prompt_for_number(NULL); |
7 | 702 if (i <= 0 || i > num_matches || got_int) |
703 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
704 // no valid choice: don't change anything |
7 | 705 if (use_tagstack) |
706 { | |
707 tagstack[tagstackidx].fmark = saved_fmark; | |
708 tagstackidx = prevtagstackidx; | |
709 } | |
710 #ifdef FEAT_CSCOPE | |
711 cs_free_tags(); | |
712 jumped_to_tag = TRUE; | |
713 #endif | |
714 break; | |
715 } | |
716 cur_match = i - 1; | |
717 } | |
718 | |
719 if (cur_match >= num_matches) | |
720 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
721 // Avoid giving this error when a file wasn't found and we're |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
722 // looking for a match in another file, which wasn't found. |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
723 // There will be an emsg("file doesn't exist") below then. |
7 | 724 if ((type == DT_NEXT || type == DT_FIRST) |
725 && nofile_fname == NULL) | |
726 { | |
727 if (num_matches == 1) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
728 emsg(_(e_there_is_only_one_matching_tag)); |
7 | 729 else |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
730 emsg(_(e_cannot_go_beyond_last_matching_tag)); |
7 | 731 skip_msg = TRUE; |
732 } | |
733 cur_match = num_matches - 1; | |
734 } | |
735 if (use_tagstack) | |
736 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
737 tagptrs_T tagp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
738 |
7 | 739 tagstack[tagstackidx].cur_match = cur_match; |
740 tagstack[tagstackidx].cur_fnum = cur_fnum; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
741 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
742 // store user-provided data originating from tagfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
743 if (use_tfu && parse_match(matches[cur_match], &tagp) == OK |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
744 && tagp.user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
745 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
746 VIM_CLEAR(tagstack[tagstackidx].user_data); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
747 tagstack[tagstackidx].user_data = vim_strnsave( |
21996
808edde1e97d
patch 8.2.1547: various comment problems
Bram Moolenaar <Bram@vim.org>
parents:
20384
diff
changeset
|
748 tagp.user_data, tagp.user_data_end - tagp.user_data); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
749 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
750 |
7 | 751 ++tagstackidx; |
752 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
753 #if defined(FEAT_QUICKFIX) |
2713 | 754 else if (g_do_tagpreview != 0) |
7 | 755 { |
756 ptag_entry.cur_match = cur_match; | |
757 ptag_entry.cur_fnum = cur_fnum; | |
758 } | |
759 #endif | |
760 | |
761 /* | |
762 * 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
|
763 * file didn't exist. Otherwise an emsg() is given below. |
7 | 764 */ |
765 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
|
766 smsg(_("File \"%s\" does not exist"), nofile_fname); |
7 | 767 |
768 | |
769 ic = (matches[cur_match][0] & MT_IC_OFF); | |
6851 | 770 if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP |
7 | 771 #ifdef FEAT_CSCOPE |
772 && type != DT_CSCOPE | |
773 #endif | |
774 && (num_matches > 1 || ic) | |
775 && !skip_msg) | |
776 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
777 // Give an indication of the number of matching tags |
7 | 778 sprintf((char *)IObuff, _("tag %d of %d%s"), |
779 cur_match + 1, | |
780 num_matches, | |
781 max_num_matches != MAXCOL ? _(" or more") : ""); | |
782 if (ic) | |
783 STRCAT(IObuff, _(" Using tag with different case!")); | |
784 if ((num_matches > prev_num_matches || new_tag) | |
785 && num_matches > 1) | |
786 { | |
787 if (ic) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
788 msg_attr((char *)IObuff, HL_ATTR(HLF_W)); |
7 | 789 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
790 msg((char *)IObuff); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
791 msg_scroll = TRUE; // don't overwrite this message |
7 | 792 } |
793 else | |
794 give_warning(IObuff, ic); | |
795 if (ic && !msg_scrolled && msg_silent == 0) | |
796 { | |
797 out_flush(); | |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18640
diff
changeset
|
798 ui_delay(1007L, TRUE); |
7 | 799 } |
800 } | |
801 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
802 #if defined(FEAT_EVAL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
803 // Let the SwapExists event know what tag we are jumping to. |
589 | 804 vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name); |
805 set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1); | |
806 #endif | |
807 | |
7 | 808 /* |
809 * Jump to the desired match. | |
810 */ | |
589 | 811 i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE); |
812 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
813 #if defined(FEAT_EVAL) |
589 | 814 set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); |
815 #endif | |
816 | |
817 if (i == NOTAGFILE) | |
7 | 818 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
819 // File not found: try again with another matching tag |
7 | 820 if ((type == DT_PREV && cur_match > 0) |
821 || ((type == DT_TAG || type == DT_NEXT | |
822 || type == DT_FIRST) | |
823 && (max_num_matches != MAXCOL | |
824 || cur_match < num_matches - 1))) | |
825 { | |
826 error_cur_match = cur_match; | |
827 if (use_tagstack) | |
828 --tagstackidx; | |
829 if (type == DT_PREV) | |
830 --cur_match; | |
831 else | |
832 { | |
833 type = DT_NEXT; | |
834 ++cur_match; | |
835 } | |
836 continue; | |
837 } | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
838 semsg(_(e_file_str_does_not_exist), nofile_fname); |
7 | 839 } |
840 else | |
841 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
842 // We may have jumped to another window, check that |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
843 // tagstackidx is still valid. |
7 | 844 if (use_tagstack && tagstackidx > curwin->w_tagstacklen) |
845 tagstackidx = curwin->w_tagstackidx; | |
846 #ifdef FEAT_CSCOPE | |
847 jumped_to_tag = TRUE; | |
848 #endif | |
849 } | |
850 } | |
851 break; | |
852 } | |
853 | |
854 end_do_tag: | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
855 // Only store the new index when using the tagstack and it's valid. |
7 | 856 if (use_tagstack && tagstackidx <= curwin->w_tagstacklen) |
857 curwin->w_tagstackidx = tagstackidx; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
858 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
|
859 # ifdef FEAT_QUICKFIX |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
860 g_do_tagpreview = 0; // don't do tag preview next time |
9949
30be4b26a37e
commit https://github.com/vim/vim/commit/358308dd99abdd56c6540339e505585d8db7bdfe
Christian Brabandt <cb@256bit.org>
parents:
9913
diff
changeset
|
861 # endif |
7 | 862 |
863 #ifdef FEAT_CSCOPE | |
864 return jumped_to_tag; | |
865 #else | |
866 return FALSE; | |
867 #endif | |
868 } | |
869 | |
870 /* | |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
871 * List all the matching tags. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
872 */ |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
873 static void |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
874 print_tag_list( |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
875 int new_tag, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
876 int use_tagstack, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
877 int num_matches, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
878 char_u **matches) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
879 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
880 taggy_T *tagstack = curwin->w_tagstack; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
881 int tagstackidx = curwin->w_tagstackidx; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
882 int i; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
883 char_u *p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
884 char_u *command_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
885 tagptrs_T tagp; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
886 int taglen; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
887 int attr; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
888 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
889 /* |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
890 * Assume that the first match indicates how long the tags can |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
891 * be, and align the file names to that. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
892 */ |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
893 parse_match(matches[0], &tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
894 taglen = (int)(tagp.tagname_end - tagp.tagname + 2); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
895 if (taglen < 18) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
896 taglen = 18; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
897 if (taglen > Columns - 25) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
898 taglen = MAXCOL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
899 if (msg_col == 0) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
900 msg_didout = FALSE; // overwrite previous message |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
901 msg_start(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
902 msg_puts_attr(_(" # pri kind tag"), HL_ATTR(HLF_T)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
903 msg_clr_eos(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
904 taglen_advance(taglen); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
905 msg_puts_attr(_("file\n"), HL_ATTR(HLF_T)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
906 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
907 for (i = 0; i < num_matches && !got_int; ++i) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
908 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
909 parse_match(matches[i], &tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
910 if (!new_tag && ( |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
911 #if defined(FEAT_QUICKFIX) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
912 (g_do_tagpreview != 0 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
913 && i == ptag_entry.cur_match) || |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
914 #endif |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
915 (use_tagstack |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
916 && i == tagstack[tagstackidx].cur_match))) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
917 *IObuff = '>'; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
918 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
919 *IObuff = ' '; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
920 vim_snprintf((char *)IObuff + 1, IOSIZE - 1, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
921 "%2d %s ", i + 1, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
922 mt_names[matches[i][0] & MT_MASK]); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
923 msg_puts((char *)IObuff); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
924 if (tagp.tagkind != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
925 msg_outtrans_len(tagp.tagkind, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
926 (int)(tagp.tagkind_end - tagp.tagkind)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
927 msg_advance(13); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
928 msg_outtrans_len_attr(tagp.tagname, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
929 (int)(tagp.tagname_end - tagp.tagname), |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
930 HL_ATTR(HLF_T)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
931 msg_putchar(' '); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
932 taglen_advance(taglen); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
933 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
934 // Find out the actual file name. If it is long, truncate |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
935 // it and put "..." in the middle |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
936 p = tag_full_fname(&tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
937 if (p != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
938 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
939 msg_outtrans_long_attr(p, HL_ATTR(HLF_D)); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
940 vim_free(p); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
941 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
942 if (msg_col > 0) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
943 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
944 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
945 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
946 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
947 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
948 // print any extra fields |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
949 command_end = tagp.command_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
950 if (command_end != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
951 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
952 p = command_end + 3; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
953 while (*p && *p != '\r' && *p != '\n') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
954 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
955 while (*p == TAB) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
956 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
957 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
958 // skip "file:" without a value (static tag) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
959 if (STRNCMP(p, "file:", 5) == 0 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
960 && vim_isspace(p[5])) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
961 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
962 p += 5; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
963 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
964 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
965 // skip "kind:<kind>" and "<kind>" |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
966 if (p == tagp.tagkind |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
967 || (p + 5 == tagp.tagkind |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
968 && STRNCMP(p, "kind:", 5) == 0)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
969 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
970 p = tagp.tagkind_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
971 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
972 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
973 // print all other extra fields |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
974 attr = HL_ATTR(HLF_CM); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
975 while (*p && *p != '\r' && *p != '\n') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
976 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
977 if (msg_col + ptr2cells(p) >= Columns) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
978 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
979 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
980 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
981 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
982 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
983 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
984 p = msg_outtrans_one(p, attr); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
985 if (*p == TAB) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
986 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
987 msg_puts_attr(" ", attr); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
988 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
989 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
990 if (*p == ':') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
991 attr = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
992 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
993 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
994 if (msg_col > 15) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
995 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
996 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
997 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
998 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
999 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1000 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1001 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1002 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1003 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1004 for (p = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1005 *p && *p != '\r' && *p != '\n'; ++p) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1006 ; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1007 command_end = p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1008 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1009 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1010 // Put the info (in several lines) at column 15. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1011 // Don't display "/^" and "?^". |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1012 p = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1013 if (*p == '/' || *p == '?') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1014 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1015 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1016 if (*p == '^') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1017 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1018 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1019 // Remove leading whitespace from pattern |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1020 while (p != command_end && vim_isspace(*p)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1021 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1022 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1023 while (p != command_end) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1024 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1025 if (msg_col + (*p == TAB ? 1 : ptr2cells(p)) > Columns) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1026 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1027 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1028 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1029 msg_advance(15); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1030 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1031 // skip backslash used for escaping a command char or |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1032 // a backslash |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1033 if (*p == '\\' && (*(p + 1) == *tagp.command |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1034 || *(p + 1) == '\\')) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1035 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1036 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1037 if (*p == TAB) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1038 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1039 msg_putchar(' '); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1040 ++p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1041 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1042 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1043 p = msg_outtrans_one(p, 0); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1044 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1045 // don't display the "$/;\"" and "$?;\"" |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1046 if (p == command_end - 2 && *p == '$' |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1047 && *(p + 1) == *tagp.command) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1048 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1049 // don't display matching '/' or '?' |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1050 if (p == command_end - 1 && *p == *tagp.command |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1051 && (*p == '/' || *p == '?')) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1052 break; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1053 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1054 if (msg_col) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1055 msg_putchar('\n'); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1056 ui_breakcheck(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1057 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1058 if (got_int) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1059 got_int = FALSE; // only stop the listing |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1060 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1061 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1062 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1063 /* |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1064 * Add the matching tags to the location list for the current |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1065 * window. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1066 */ |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1067 static int |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1068 add_llist_tags( |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1069 char_u *tag, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1070 int num_matches, |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1071 char_u **matches) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1072 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1073 list_T *list; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1074 char_u tag_name[128 + 1]; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1075 char_u *fname; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1076 char_u *cmd; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1077 int i; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1078 char_u *p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1079 tagptrs_T tagp; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1080 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1081 fname = alloc(MAXPATHL + 1); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1082 cmd = alloc(CMDBUFFSIZE + 1); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1083 list = list_alloc(); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1084 if (list == NULL || fname == NULL || cmd == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1085 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1086 vim_free(cmd); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1087 vim_free(fname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1088 if (list != NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1089 list_free(list); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1090 return FAIL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1091 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1092 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1093 for (i = 0; i < num_matches; ++i) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1094 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1095 int len, cmd_len; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1096 long lnum; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1097 dict_T *dict; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1098 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1099 parse_match(matches[i], &tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1100 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1101 // Save the tag name |
16188
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1102 len = (int)(tagp.tagname_end - tagp.tagname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1103 if (len > 128) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1104 len = 128; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1105 vim_strncpy(tag_name, tagp.tagname, len); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1106 tag_name[len] = NUL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1107 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1108 // Save the tag file name |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1109 p = tag_full_fname(&tagp); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1110 if (p == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1111 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1112 vim_strncpy(fname, p, MAXPATHL); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1113 vim_free(p); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1114 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1115 // Get the line number or the search pattern used to locate |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1116 // the tag. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1117 lnum = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1118 if (isdigit(*tagp.command)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1119 // Line number is used to locate the tag |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1120 lnum = atol((char *)tagp.command); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1121 else |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1122 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1123 char_u *cmd_start, *cmd_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1124 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1125 // Search pattern is used to locate the tag |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1126 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1127 // Locate the end of the command |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1128 cmd_start = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1129 cmd_end = tagp.command_end; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1130 if (cmd_end == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1131 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1132 for (p = tagp.command; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1133 *p && *p != '\r' && *p != '\n'; ++p) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1134 ; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1135 cmd_end = p; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1136 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1137 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1138 // Now, cmd_end points to the character after the |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1139 // command. Adjust it to point to the last |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1140 // character of the command. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1141 cmd_end--; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1142 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1143 // Skip the '/' and '?' characters at the |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1144 // beginning and end of the search pattern. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1145 if (*cmd_start == '/' || *cmd_start == '?') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1146 cmd_start++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1147 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1148 if (*cmd_end == '/' || *cmd_end == '?') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1149 cmd_end--; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1150 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1151 len = 0; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1152 cmd[0] = NUL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1153 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1154 // If "^" is present in the tag search pattern, then |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1155 // copy it first. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1156 if (*cmd_start == '^') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1157 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1158 STRCPY(cmd, "^"); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1159 cmd_start++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1160 len++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1161 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1162 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1163 // Precede the tag pattern with \V to make it very |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1164 // nomagic. |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1165 STRCAT(cmd, "\\V"); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1166 len += 2; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1167 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1168 cmd_len = (int)(cmd_end - cmd_start + 1); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1169 if (cmd_len > (CMDBUFFSIZE - 5)) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1170 cmd_len = CMDBUFFSIZE - 5; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1171 STRNCAT(cmd, cmd_start, cmd_len); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1172 len += cmd_len; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1173 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1174 if (cmd[len - 1] == '$') |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1175 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1176 // Replace '$' at the end of the search pattern |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1177 // with '\$' |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1178 cmd[len - 1] = '\\'; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1179 cmd[len] = '$'; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1180 len++; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1181 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1182 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1183 cmd[len] = NUL; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1184 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1185 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1186 if ((dict = dict_alloc()) == NULL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1187 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1188 if (list_append_dict(list, dict) == FAIL) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1189 { |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1190 vim_free(dict); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1191 continue; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1192 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1193 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1194 dict_add_string(dict, "text", tag_name); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1195 dict_add_string(dict, "filename", fname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1196 dict_add_number(dict, "lnum", lnum); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1197 if (lnum == 0) |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1198 dict_add_string(dict, "pattern", cmd); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1199 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1200 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1201 vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1202 set_errorlist(curwin, list, ' ', IObuff, NULL); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1203 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1204 list_free(list); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1205 vim_free(fname); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1206 vim_free(cmd); |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1207 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1208 return OK; |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1209 } |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1210 #endif |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1211 |
848d4c6e391e
patch 8.1.1099: the do_tag() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
16178
diff
changeset
|
1212 /* |
7 | 1213 * Free cached tags. |
1214 */ | |
1215 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1216 tag_freematch(void) |
7 | 1217 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13227
diff
changeset
|
1218 VIM_CLEAR(tagmatchname); |
7 | 1219 } |
1220 | |
1221 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1222 taglen_advance(int l) |
7 | 1223 { |
1224 if (l == MAXCOL) | |
1225 { | |
1226 msg_putchar('\n'); | |
1227 msg_advance(24); | |
1228 } | |
1229 else | |
1230 msg_advance(13 + l); | |
1231 } | |
1232 | |
1233 /* | |
1234 * Print the tag stack | |
1235 */ | |
1236 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1237 do_tags(exarg_T *eap UNUSED) |
7 | 1238 { |
1239 int i; | |
1240 char_u *name; | |
1241 taggy_T *tagstack = curwin->w_tagstack; | |
1242 int tagstackidx = curwin->w_tagstackidx; | |
1243 int tagstacklen = curwin->w_tagstacklen; | |
1244 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1245 // Highlight title |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1246 msg_puts_title(_("\n # TO tag FROM line in file/text")); |
7 | 1247 for (i = 0; i < tagstacklen; ++i) |
1248 { | |
1249 if (tagstack[i].tagname != NULL) | |
1250 { | |
1251 name = fm_getname(&(tagstack[i].fmark), 30); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1252 if (name == NULL) // file name not available |
7 | 1253 continue; |
1254 | |
1255 msg_putchar('\n'); | |
13068
63fdea6e9c6c
patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents:
12680
diff
changeset
|
1256 vim_snprintf((char *)IObuff, IOSIZE, "%c%2d %2d %-15s %5ld ", |
7 | 1257 i == tagstackidx ? '>' : ' ', |
1258 i + 1, | |
1259 tagstack[i].cur_match + 1, | |
1260 tagstack[i].tagname, | |
1261 tagstack[i].fmark.mark.lnum); | |
1262 msg_outtrans(IObuff); | |
1263 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
|
1264 ? HL_ATTR(HLF_D) : 0); |
7 | 1265 vim_free(name); |
1266 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1267 out_flush(); // show one line at a time |
7 | 1268 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1269 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
|
1270 msg_puts("\n>"); |
7 | 1271 } |
1272 | |
1273 #ifdef FEAT_TAG_BINS | |
1274 /* | |
1275 * Compare two strings, for length "len", ignoring case the ASCII way. | |
1276 * return 0 for match, < 0 for smaller, > 0 for bigger | |
1277 * Make sure case is folded to uppercase in comparison (like for 'sort -f') | |
1278 */ | |
1279 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1280 tag_strnicmp(char_u *s1, char_u *s2, size_t len) |
7 | 1281 { |
1282 int i; | |
1283 | |
1284 while (len > 0) | |
1285 { | |
1286 i = (int)TOUPPER_ASC(*s1) - (int)TOUPPER_ASC(*s2); | |
1287 if (i != 0) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1288 return i; // this character different |
7 | 1289 if (*s1 == NUL) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1290 break; // strings match until NUL |
7 | 1291 ++s1; |
1292 ++s2; | |
1293 --len; | |
1294 } | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1295 return 0; // strings match |
7 | 1296 } |
1297 #endif | |
1298 | |
1299 /* | |
1300 * Structure to hold info about the tag pattern being used. | |
1301 */ | |
1302 typedef struct | |
1303 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1304 char_u *pat; // the pattern |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1305 int len; // length of pat[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1306 char_u *head; // start of pattern head |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1307 int headlen; // length of head[] |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1308 regmatch_T regmatch; // regexp program, may be NULL |
7 | 1309 } pat_T; |
1310 | |
1311 /* | |
1312 * Extract info from the tag search pattern "pats->pat". | |
1313 */ | |
1314 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1315 prepare_pats(pat_T *pats, int has_re) |
7 | 1316 { |
1317 pats->head = pats->pat; | |
1318 pats->headlen = pats->len; | |
1319 if (has_re) | |
1320 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1321 // When the pattern starts with '^' or "\\<", binary searching can be |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1322 // used (much faster). |
7 | 1323 if (pats->pat[0] == '^') |
1324 pats->head = pats->pat + 1; | |
1325 else if (pats->pat[0] == '\\' && pats->pat[1] == '<') | |
1326 pats->head = pats->pat + 2; | |
1327 if (pats->head == pats->pat) | |
1328 pats->headlen = 0; | |
1329 else | |
1330 for (pats->headlen = 0; pats->head[pats->headlen] != NUL; | |
1331 ++pats->headlen) | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1332 if (vim_strchr((char_u *)(magic_isset() ? ".[~*\\$" : "\\$"), |
7 | 1333 pats->head[pats->headlen]) != NULL) |
1334 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1335 if (p_tl != 0 && pats->headlen > p_tl) // adjust for 'taglength' |
7 | 1336 pats->headlen = p_tl; |
1337 } | |
1338 | |
1339 if (has_re) | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1340 pats->regmatch.regprog = vim_regcomp(pats->pat, |
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1341 magic_isset() ? RE_MAGIC : 0); |
7 | 1342 else |
1343 pats->regmatch.regprog = NULL; | |
1344 } | |
1345 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1346 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1347 /* |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1348 * Call the user-defined function to generate a list of tags used by |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1349 * find_tags(). |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1350 * |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1351 * Return OK if at least 1 tag has been successfully found, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1352 * NOTDONE if the function returns v:null, and FAIL otherwise. |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1353 */ |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1354 static int |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1355 find_tagfunc_tags( |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1356 char_u *pat, // pattern supplied to the user-defined function |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1357 garray_T *ga, // the tags will be placed here |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1358 int *match_count, // here the number of tags found will be placed |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1359 int flags, // flags from find_tags (TAG_*) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1360 char_u *buf_ffname) // name of buffer for priority |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1361 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1362 pos_T save_pos; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1363 list_T *taglist; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1364 listitem_T *item; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1365 int ntags = 0; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1366 int result = FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1367 typval_T args[4]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1368 typval_T rettv; |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1369 char_u flagString[4]; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1370 dict_T *d; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1371 taggy_T *tag = &curwin->w_tagstack[curwin->w_tagstackidx]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1372 |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26436
diff
changeset
|
1373 if (*curbuf->b_p_tfu == NUL || curbuf->b_tfu_cb.cb_name == NULL |
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26436
diff
changeset
|
1374 || *curbuf->b_tfu_cb.cb_name == NUL) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1375 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1376 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1377 args[0].v_type = VAR_STRING; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1378 args[0].vval.v_string = pat; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1379 args[1].v_type = VAR_STRING; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1380 args[1].vval.v_string = flagString; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1381 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1382 // create 'info' dict argument |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1383 if ((d = dict_alloc_lock(VAR_FIXED)) == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1384 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1385 if (tag->user_data != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1386 dict_add_string(d, "user_data", tag->user_data); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1387 if (buf_ffname != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1388 dict_add_string(d, "buf_ffname", buf_ffname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1389 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1390 ++d->dv_refcount; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1391 args[2].v_type = VAR_DICT; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1392 args[2].vval.v_dict = d; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1393 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1394 args[3].v_type = VAR_UNKNOWN; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1395 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1396 vim_snprintf((char *)flagString, sizeof(flagString), |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1397 "%s%s%s", |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1398 g_tag_at_cursor ? "c": "", |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1399 flags & TAG_INS_COMP ? "i": "", |
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
24053
diff
changeset
|
1400 flags & TAG_REGEXP ? "r": ""); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1401 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1402 save_pos = curwin->w_cursor; |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
1403 result = call_callback(&curbuf->b_tfu_cb, 0, &rettv, 3, args); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1404 curwin->w_cursor = save_pos; // restore the cursor position |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1405 --d->dv_refcount; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1406 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1407 if (result == FAIL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1408 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1409 if (rettv.v_type == VAR_SPECIAL && rettv.vval.v_number == VVAL_NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1410 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1411 clear_tv(&rettv); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1412 return NOTDONE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1413 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1414 if (rettv.v_type != VAR_LIST || !rettv.vval.v_list) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1415 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1416 clear_tv(&rettv); |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
1417 emsg(_(e_invalid_return_value_from_tagfunc)); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1418 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1419 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1420 taglist = rettv.vval.v_list; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1421 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19617
diff
changeset
|
1422 FOR_ALL_LIST_ITEMS(taglist, item) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1423 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1424 char_u *mfp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1425 char_u *res_name, *res_fname, *res_cmd, *res_kind; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1426 int len; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1427 dict_iterator_T iter; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1428 char_u *dict_key; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1429 typval_T *tv; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1430 int has_extra = 0; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1431 int name_only = flags & TAG_NAMES; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1432 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1433 if (item->li_tv.v_type != VAR_DICT) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1434 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
1435 emsg(_(e_invalid_return_value_from_tagfunc)); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1436 break; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1437 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1438 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1439 #ifdef FEAT_EMACS_TAGS |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1440 len = 3; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1441 #else |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1442 len = 2; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1443 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1444 res_name = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1445 res_fname = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1446 res_cmd = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1447 res_kind = NULL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1448 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1449 dict_iterate_start(&item->li_tv, &iter); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1450 while (NULL != (dict_key = dict_iterate_next(&iter, &tv))) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1451 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1452 if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1453 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1454 |
16461
826ad48af5e3
patch 8.1.1235: compiler warnings for using STRLEN() value
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
1455 len += (int)STRLEN(tv->vval.v_string) + 1; // Space for "\tVALUE" |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1456 if (!STRCMP(dict_key, "name")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1457 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1458 res_name = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1459 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1460 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1461 if (!STRCMP(dict_key, "filename")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1462 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1463 res_fname = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1464 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1465 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1466 if (!STRCMP(dict_key, "cmd")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1467 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1468 res_cmd = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1469 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1470 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1471 has_extra = 1; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1472 if (!STRCMP(dict_key, "kind")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1473 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1474 res_kind = tv->vval.v_string; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1475 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1476 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1477 // Other elements will be stored as "\tKEY:VALUE" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1478 // Allocate space for the key and the colon |
16461
826ad48af5e3
patch 8.1.1235: compiler warnings for using STRLEN() value
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
1479 len += (int)STRLEN(dict_key) + 1; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1480 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1481 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1482 if (has_extra) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1483 len += 2; // need space for ;" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1484 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1485 if (!res_name || !res_fname || !res_cmd) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1486 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
1487 emsg(_(e_invalid_return_value_from_tagfunc)); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1488 break; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1489 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1490 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1491 if (name_only) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1492 mfp = vim_strsave(res_name); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1493 else |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
1494 mfp = alloc(sizeof(char_u) + len + 1); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1495 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1496 if (mfp == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1497 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1498 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1499 if (!name_only) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1500 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1501 char_u *p = mfp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1502 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1503 *p++ = MT_GL_OTH + 1; // mtt |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1504 *p++ = TAG_SEP; // no tag file name |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1505 #ifdef FEAT_EMACS_TAGS |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1506 *p++ = TAG_SEP; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1507 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1508 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1509 STRCPY(p, res_name); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1510 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1511 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1512 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1513 STRCPY(p, res_fname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1514 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1515 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1516 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1517 STRCPY(p, res_cmd); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1518 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1519 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1520 if (has_extra) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1521 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1522 STRCPY(p, ";\""); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1523 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1524 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1525 if (res_kind) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1526 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1527 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1528 STRCPY(p, res_kind); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1529 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1530 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1531 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1532 dict_iterate_start(&item->li_tv, &iter); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1533 while (NULL != (dict_key = dict_iterate_next(&iter, &tv))) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1534 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1535 if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1536 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1537 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1538 if (!STRCMP(dict_key, "name")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1539 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1540 if (!STRCMP(dict_key, "filename")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1541 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1542 if (!STRCMP(dict_key, "cmd")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1543 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1544 if (!STRCMP(dict_key, "kind")) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1545 continue; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1546 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1547 *p++ = TAB; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1548 STRCPY(p, dict_key); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1549 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1550 STRCPY(p, ":"); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1551 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1552 STRCPY(p, tv->vval.v_string); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1553 p += STRLEN(p); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1554 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1555 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1556 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1557 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1558 // Add all matches because tagfunc should do filtering. |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1559 if (ga_grow(ga, 1) == OK) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1560 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1561 ((char_u **)(ga->ga_data))[ga->ga_len++] = mfp; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1562 ++ntags; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1563 result = OK; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1564 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1565 else |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1566 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1567 vim_free(mfp); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1568 break; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1569 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1570 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1571 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1572 clear_tv(&rettv); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1573 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1574 *match_count = ntags; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1575 return result; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1576 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1577 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
1578 |
7 | 1579 /* |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1580 * State information used during a tag search |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1581 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1582 typedef struct { |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1583 char_u *tag_fname; // name of the tag file |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1584 pat_T orgpat; // holds unconverted pattern info |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1585 int name_only; // get only tag names |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1586 int get_searchpat; // used for 'showfulltag' |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1587 int help_only; // only search for help tags |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1588 #ifdef FEAT_MULTI_LANG |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1589 char_u *help_lang_find; // lang to be found |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1590 int is_txt; // flag of file extension |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1591 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1592 int did_open; // did open a tag file |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1593 int mincount; // MAXCOL: find all matches |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1594 // other: minimal number of matches |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1595 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1596 int linear; // do a linear search |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1597 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1598 char_u *lbuf; // line buffer |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1599 int lbuf_size; // length of lbuf |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1600 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1601 char_u *ebuf; // additional buffer for etag fname |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1602 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1603 int match_count; // number of matches found |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1604 garray_T ga_match[MT_COUNT]; // stores matches in sequence |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1605 hashtab_T ht_match[MT_COUNT]; // stores matches by key |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1606 int stop_searching; // stop when match found or error |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1607 } findtags_state_T; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1608 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1609 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1610 * Initialize the state used by find_tags() |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1611 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1612 static int |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1613 findtags_state_init( |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1614 findtags_state_T *st, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1615 char_u *pat, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1616 int flags, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1617 int mincount) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1618 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1619 int mtt; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1620 |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
1621 st->tag_fname = alloc(MAXPATHL + 1); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1622 st->orgpat.pat = pat; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1623 st->orgpat.len = (int)STRLEN(pat); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1624 st->orgpat.regmatch.regprog = NULL; |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1625 st->help_only = (flags & TAG_HELP); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1626 st->name_only = (flags & TAG_NAMES); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1627 st->get_searchpat = FALSE; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1628 #ifdef FEAT_MULTI_LANG |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1629 st->help_lang_find = NULL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1630 st->is_txt = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1631 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1632 st->did_open = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1633 st->mincount = mincount; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1634 st->lbuf_size = LSIZE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1635 st->lbuf = alloc(st->lbuf_size); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1636 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1637 st->ebuf = alloc(LSIZE); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1638 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1639 st->match_count = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1640 st->stop_searching = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1641 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1642 for (mtt = 0; mtt < MT_COUNT; ++mtt) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1643 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1644 ga_init2(&st->ga_match[mtt], sizeof(char_u *), 100); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1645 hash_init(&st->ht_match[mtt]); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1646 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1647 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1648 // check for out of memory situation |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
1649 if (st->tag_fname == NULL |
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
1650 || st->lbuf == NULL |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1651 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1652 || st->ebuf == NULL |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1653 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1654 ) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1655 return FAIL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1656 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1657 return OK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1658 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1659 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1660 /* |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1661 * Free the state used by find_tags() |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1662 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1663 static void |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1664 findtags_state_free(findtags_state_T *st) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1665 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1666 vim_free(st->tag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1667 vim_free(st->lbuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1668 vim_regfree(st->orgpat.regmatch.regprog); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1669 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1670 vim_free(st->ebuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1671 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1672 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1673 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1674 #ifdef FEAT_MULTI_LANG |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1675 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1676 * Initialize the state for searching tags in a Vim help file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1677 * Returns TRUE to process the help file and FALSE to skip the file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1678 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1679 static int |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1680 findtags_in_help_init( |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1681 findtags_state_T *st, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1682 int flags, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1683 char_u *help_lang, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1684 int *help_pri) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1685 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1686 int i; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1687 char_u *s; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1688 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1689 // Keep en if the file extension is .txt |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1690 if (st->is_txt) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1691 STRCPY(help_lang, "en"); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1692 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1693 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1694 // Prefer help tags according to 'helplang'. Put the |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1695 // two-letter language name in help_lang[]. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1696 i = (int)STRLEN(st->tag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1697 if (i > 3 && st->tag_fname[i - 3] == '-') |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1698 STRCPY(help_lang, st->tag_fname + i - 2); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1699 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1700 STRCPY(help_lang, "en"); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1701 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1702 // When searching for a specific language skip tags files |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1703 // for other languages. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1704 if (st->help_lang_find != NULL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1705 && STRICMP(help_lang, st->help_lang_find) != 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1706 return FALSE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1707 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1708 // For CTRL-] in a help file prefer a match with the same |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1709 // language. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1710 if ((flags & TAG_KEEP_LANG) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1711 && st->help_lang_find == NULL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1712 && curbuf->b_fname != NULL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1713 && (i = (int)STRLEN(curbuf->b_fname)) > 4 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1714 && curbuf->b_fname[i - 1] == 'x' |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1715 && curbuf->b_fname[i - 4] == '.' |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1716 && STRNICMP(curbuf->b_fname + i - 3, help_lang, 2) == 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1717 *help_pri = 0; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1718 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1719 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1720 *help_pri = 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1721 for (s = p_hlg; *s != NUL; ++s) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1722 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1723 if (STRNICMP(s, help_lang, 2) == 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1724 break; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1725 ++*help_pri; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1726 if ((s = vim_strchr(s, ',')) == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1727 break; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1728 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1729 if (s == NULL || *s == NUL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1730 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1731 // Language not in 'helplang': use last, prefer English, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1732 // unless found already. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1733 ++*help_pri; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1734 if (STRICMP(help_lang, "en") != 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1735 ++*help_pri; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1736 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1737 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1738 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1739 return TRUE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1740 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1741 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1742 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1743 #ifdef FEAT_EVAL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1744 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1745 * Use the 'tagfunc' (if configured and enabled) to get the tags. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1746 * Return OK if at least 1 tag has been successfully found, NOTDONE if the |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1747 * 'tagfunc' is not used or the 'tagfunc' returns v:null and FAIL otherwise. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1748 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1749 static int |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1750 findtags_apply_tfu( |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1751 char_u *pat, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1752 findtags_state_T *st, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1753 int flags, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1754 char_u *buf_ffname) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1755 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1756 int use_tfu = ((flags & TAG_NO_TAGFUNC) == 0); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1757 int retval; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1758 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1759 if (!use_tfu || tfu_in_use || *curbuf->b_p_tfu == NUL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1760 return NOTDONE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1761 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1762 tfu_in_use = TRUE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1763 retval = find_tagfunc_tags(pat, st->ga_match, &st->match_count, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1764 flags, buf_ffname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1765 tfu_in_use = FALSE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1766 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1767 return retval; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1768 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1769 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1770 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1771 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1772 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1773 * Stack for included emacs-tags file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1774 * It has a fixed size, to truncate cyclic includes. jw |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1775 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1776 # define INCSTACK_SIZE 42 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1777 static struct |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1778 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1779 FILE *fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1780 char_u *etag_fname; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1781 } incstack[INCSTACK_SIZE]; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1782 static int incstack_idx = 0; // index in incstack |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1783 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1784 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1785 * Free the include tags file stack. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1786 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1787 static void |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1788 emacs_tags_incstack_free(void) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1789 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1790 while (incstack_idx) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1791 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1792 --incstack_idx; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1793 fclose(incstack[incstack_idx].fp); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1794 incstack[incstack_idx].fp = NULL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1795 VIM_CLEAR(incstack[incstack_idx].etag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1796 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1797 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1798 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1799 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1800 * Emacs tags line with CTRL-L: New file name on next line. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1801 * The file name is followed by a ','. Remember etag file name in ebuf. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1802 * Returns a FILE pointer to the tags file. If another tags file is included, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1803 * then returns a pointer to the new tags file. The old file pointer is saved |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1804 * in incstack. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1805 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1806 static FILE * |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1807 emacs_tags_new_filename(findtags_state_T *st, FILE *fp, int *is_etag) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1808 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1809 char_u *p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1810 char_u *fullpath_ebuf; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1811 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1812 if (vim_fgets(st->ebuf, LSIZE, fp)) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1813 return fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1814 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1815 for (p = st->ebuf; *p && *p != ','; p++) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1816 ; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1817 *p = NUL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1818 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1819 // check for an included tags file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1820 // atoi(p+1) is the number of bytes before the next ^L unless it is an |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1821 // include statement. Skip the included tags file if it exceeds the |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1822 // maximum. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1823 if (STRNCMP(p + 1, "include", 7) != 0 || incstack_idx >= INCSTACK_SIZE) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1824 return fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1825 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1826 // Save current "fp" and "tag_fname" in the stack. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1827 incstack[incstack_idx].etag_fname = vim_strsave(st->tag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1828 if (incstack[incstack_idx].etag_fname == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1829 return fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1830 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1831 incstack[incstack_idx].fp = fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1832 fp = NULL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1833 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1834 // Figure out "tag_fname" and "fp" to use for |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1835 // included file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1836 fullpath_ebuf = expand_tag_fname(st->ebuf, st->tag_fname, FALSE); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1837 if (fullpath_ebuf != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1838 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1839 fp = mch_fopen((char *)fullpath_ebuf, "r"); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1840 if (fp != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1841 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1842 if (STRLEN(fullpath_ebuf) > LSIZE) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1843 semsg(_(e_tag_file_path_truncated_for_str), st->ebuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1844 vim_strncpy(st->tag_fname, fullpath_ebuf, MAXPATHL); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1845 ++incstack_idx; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1846 *is_etag = 0; // we can include anything |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1847 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1848 vim_free(fullpath_ebuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1849 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1850 if (fp == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1851 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1852 // Can't open the included file, skip it and |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1853 // restore old value of "fp". |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1854 fp = incstack[incstack_idx].fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1855 vim_free(incstack[incstack_idx].etag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1856 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1857 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1858 return fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1859 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1860 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1861 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1862 * Reached the end of an emacs-style tags file. If this is an included tags |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1863 * file, then pop it from the incstack and continue processing the parent tags |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1864 * file. Otherwise, processed all the tags. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1865 * Returns TRUE if an included tags file is popped and processing should |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1866 * continue with the parent tags file. Otherwise returns FALSE. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1867 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1868 static int |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1869 emacs_tags_file_eof(findtags_state_T *st, FILE **fp) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1870 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1871 if (!incstack_idx) // reached end of file. stop processing. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1872 return FALSE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1873 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1874 // reached the end of an included tags file. pop it. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1875 --incstack_idx; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1876 fclose(*fp); // end of this file ... |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1877 *fp = incstack[incstack_idx].fp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1878 STRCPY(st->tag_fname, incstack[incstack_idx].etag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1879 vim_free(incstack[incstack_idx].etag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1880 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1881 return TRUE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1882 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1883 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1884 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1885 * Parse a line from an emacs-style tags file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1886 * Returns OK is the line is parsed successfully, otherwise FALSE. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1887 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1888 static int |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1889 emacs_tags_parse_line(char_u *lbuf, tagptrs_T *tagp) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1890 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1891 char_u *p_7f; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1892 char_u *p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1893 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1894 // There are two formats for an emacs tag line: |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1895 // 1: struct EnvBase ^?EnvBase^A139,4627 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1896 // 2: #define ARPB_WILD_WORLD ^?153,5194 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1897 p_7f = vim_strchr(lbuf, 0x7f); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1898 if (p_7f == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1899 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1900 etag_fail: |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1901 if (vim_strchr(lbuf, '\n') != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1902 return FAIL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1903 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1904 // Truncated line. Ignore it. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1905 if (p_verbose >= 5) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1906 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1907 verbose_enter(); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1908 msg(_("Ignoring long line in tags file")); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1909 verbose_leave(); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1910 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1911 tagp->command = lbuf; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1912 tagp->tagname = lbuf; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1913 tagp->tagname_end = lbuf; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1914 return OK; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1915 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1916 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1917 // Find ^A. If not found the line number is after the 0x7f |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1918 p = vim_strchr(p_7f, Ctrl_A); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1919 if (p == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1920 p = p_7f + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1921 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1922 ++p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1923 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1924 if (!VIM_ISDIGIT(*p)) // check for start of line number |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1925 goto etag_fail; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1926 tagp->command = p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1927 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1928 if (p[-1] == Ctrl_A) // first format: explicit tagname given |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1929 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1930 tagp->tagname = p_7f + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1931 tagp->tagname_end = p - 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1932 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1933 else // second format: isolate tagname |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1934 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1935 // find end of tagname |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1936 for (p = p_7f - 1; !vim_iswordc(*p); --p) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1937 if (p == lbuf) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1938 goto etag_fail; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1939 tagp->tagname_end = p + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1940 while (p >= lbuf && vim_iswordc(*p)) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1941 --p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1942 tagp->tagname = p + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1943 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1944 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1945 return OK; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1946 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1947 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1948 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1949 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1950 * Parse a tags file header line in 'st->lbuf'. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1951 * Returns TRUE to read the next header line and FALSE to process the line. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1952 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1953 static int |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1954 tags_file_hdr_parse(findtags_state_T *st, vimconv_T *vcp, int *sorted_file) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1955 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1956 char_u *p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1957 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1958 if (STRNCMP(st->lbuf, "!_TAG_", 6) != 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1959 // Non-header item before the header, e.g. "!" itself. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1960 return FALSE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1961 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1962 // Read header line. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1963 #ifdef FEAT_TAG_BINS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1964 if (STRNCMP(st->lbuf, "!_TAG_FILE_SORTED\t", 18) == 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1965 *sorted_file = st->lbuf[18]; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1966 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1967 if (STRNCMP(st->lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1968 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1969 // Prepare to convert every line from the specified |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1970 // encoding to 'encoding'. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1971 for (p = st->lbuf + 20; *p > ' ' && *p < 127; ++p) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1972 ; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1973 *p = NUL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1974 convert_setup(vcp, st->lbuf + 20, p_enc); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1975 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1976 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1977 // Read the next line. Unrecognized flags are ignored. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1978 return TRUE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1979 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1980 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1981 /* |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1982 * Convert the encoding of a line read from a tags file in 'st->lbuf'. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1983 * Converting the pattern from 'enc' to the tags file encoding doesn't work, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1984 * because characters are not recognized. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1985 */ |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1986 static void |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1987 findtags_string_convert(findtags_state_T *st, vimconv_T *vcp) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1988 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1989 char_u *conv_line; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1990 int len; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1991 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1992 conv_line = string_convert(vcp, st->lbuf, NULL); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1993 if (conv_line == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1994 return; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1995 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1996 // Copy or swap lbuf and conv_line. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1997 len = (int)STRLEN(conv_line) + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1998 if (len > st->lbuf_size) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
1999 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2000 vim_free(st->lbuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2001 st->lbuf = conv_line; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2002 st->lbuf_size = len; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2003 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2004 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2005 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2006 STRCPY(st->lbuf, conv_line); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2007 vim_free(conv_line); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2008 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2009 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2010 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2011 static int |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2012 findtags_add_match( |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2013 findtags_state_T *st, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2014 tagptrs_T *tagp, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2015 char_u *buf_ffname, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2016 int flags UNUSED, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2017 hash_T *hash, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2018 int match_re, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2019 int match_no_ic, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2020 int matchoff, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2021 int is_etag UNUSED, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2022 char_u *help_lang UNUSED, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2023 int help_pri UNUSED) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2024 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2025 #ifdef FEAT_CSCOPE |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2026 int use_cscope = (flags & TAG_CSCOPE); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2027 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2028 int mtt; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2029 int len = 0; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2030 int is_current; // file name matches |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2031 int is_static; // current tag line is static |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2032 char_u *mfp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2033 char_u *p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2034 char_u *s; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2035 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2036 #ifdef FEAT_CSCOPE |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2037 if (use_cscope) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2038 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2039 // Don't change the ordering, always use the same table. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2040 mtt = MT_GL_OTH; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2041 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2042 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2043 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2044 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2045 // Decide in which array to store this match. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2046 is_current = test_for_current( |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2047 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2048 is_etag, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2049 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2050 tagp->fname, tagp->fname_end, st->tag_fname, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2051 buf_ffname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2052 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2053 is_static = FALSE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2054 if (!is_etag) // emacs tags are never static |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2055 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2056 is_static = test_for_static(tagp); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2057 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2058 // decide in which of the sixteen tables to store this |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2059 // match |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2060 if (is_static) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2061 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2062 if (is_current) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2063 mtt = MT_ST_CUR; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2064 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2065 mtt = MT_ST_OTH; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2066 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2067 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2068 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2069 if (is_current) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2070 mtt = MT_GL_CUR; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2071 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2072 mtt = MT_GL_OTH; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2073 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2074 if (st->orgpat.regmatch.rm_ic && !match_no_ic) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2075 mtt += MT_IC_OFF; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2076 if (match_re) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2077 mtt += MT_RE_OFF; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2078 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2079 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2080 // Add the found match in ht_match[mtt] and ga_match[mtt]. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2081 // Store the info we need later, which depends on the kind of |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2082 // tags we are dealing with. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2083 if (st->help_only) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2084 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2085 #ifdef FEAT_MULTI_LANG |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2086 # define ML_EXTRA 3 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2087 #else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2088 # define ML_EXTRA 0 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2089 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2090 // Append the help-heuristic number after the tagname, for |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2091 // sorting it later. The heuristic is ignored for |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2092 // detecting duplicates. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2093 // The format is {tagname}@{lang}NUL{heuristic}NUL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2094 *tagp->tagname_end = NUL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2095 len = (int)(tagp->tagname_end - tagp->tagname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2096 mfp = alloc(sizeof(char_u) + len + 10 + ML_EXTRA + 1); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2097 if (mfp != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2098 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2099 int heuristic; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2100 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2101 p = mfp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2102 STRCPY(p, tagp->tagname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2103 #ifdef FEAT_MULTI_LANG |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2104 p[len] = '@'; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2105 STRCPY(p + len + 1, help_lang); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2106 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2107 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2108 heuristic = help_heuristic(tagp->tagname, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2109 match_re ? matchoff : 0, !match_no_ic); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2110 #ifdef FEAT_MULTI_LANG |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2111 heuristic += help_pri; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2112 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2113 sprintf((char *)p + len + 1 + ML_EXTRA, "%06d", |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2114 heuristic); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2115 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2116 *tagp->tagname_end = TAB; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2117 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2118 else if (st->name_only) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2119 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2120 if (st->get_searchpat) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2121 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2122 char_u *temp_end = tagp->command; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2123 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2124 if (*temp_end == '/') |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2125 while (*temp_end && *temp_end != '\r' |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2126 && *temp_end != '\n' |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2127 && *temp_end != '$') |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2128 temp_end++; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2129 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2130 if (tagp->command + 2 < temp_end) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2131 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2132 len = (int)(temp_end - tagp->command - 2); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2133 mfp = alloc(len + 2); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2134 if (mfp != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2135 vim_strncpy(mfp, tagp->command + 2, len); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2136 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2137 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2138 mfp = NULL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2139 st->get_searchpat = FALSE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2140 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2141 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2142 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2143 len = (int)(tagp->tagname_end - tagp->tagname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2144 mfp = alloc(sizeof(char_u) + len + 1); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2145 if (mfp != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2146 vim_strncpy(mfp, tagp->tagname, len); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2147 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2148 // if wanted, re-read line to get long form too |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2149 if (State & INSERT) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2150 st->get_searchpat = p_sft; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2151 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2152 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2153 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2154 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2155 size_t tag_fname_len = STRLEN(st->tag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2156 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2157 size_t ebuf_len = 0; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2158 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2159 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2160 // Save the tag in a buffer. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2161 // Use 0x02 to separate fields (Can't use NUL because the |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2162 // hash key is terminated by NUL, or Ctrl_A because that is |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2163 // part of some Emacs tag files -- see parse_tag_line). |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2164 // Emacs tag: <mtt><tag_fname><0x02><ebuf><0x02><lbuf><NUL> |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2165 // other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL> |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2166 // without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL> |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2167 // Here <mtt> is the "mtt" value plus 1 to avoid NUL. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2168 len = (int)tag_fname_len + (int)STRLEN(st->lbuf) + 3; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2169 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2170 if (is_etag) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2171 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2172 ebuf_len = STRLEN(st->ebuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2173 len += (int)ebuf_len + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2174 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2175 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2176 ++len; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2177 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2178 mfp = alloc(sizeof(char_u) + len + 1); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2179 if (mfp != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2180 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2181 p = mfp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2182 p[0] = mtt + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2183 STRCPY(p + 1, st->tag_fname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2184 #ifdef BACKSLASH_IN_FILENAME |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2185 // Ignore differences in slashes, avoid adding |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2186 // both path/file and path\file. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2187 slash_adjust(p + 1); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2188 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2189 p[tag_fname_len + 1] = TAG_SEP; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2190 s = p + 1 + tag_fname_len + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2191 #ifdef FEAT_EMACS_TAGS |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2192 if (is_etag) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2193 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2194 STRCPY(s, st->ebuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2195 s[ebuf_len] = TAG_SEP; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2196 s += ebuf_len + 1; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2197 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2198 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2199 *s++ = TAG_SEP; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2200 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2201 STRCPY(s, st->lbuf); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2202 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2203 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2204 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2205 if (mfp != NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2206 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2207 hashitem_T *hi; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2208 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2209 // Don't add identical matches. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2210 // Add all cscope tags, because they are all listed. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2211 // "mfp" is used as a hash key, there is a NUL byte to end |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2212 // the part that matters for comparing, more bytes may |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2213 // follow after it. E.g. help tags store the priority |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2214 // after the NUL. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2215 #ifdef FEAT_CSCOPE |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2216 if (use_cscope) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2217 ++*hash; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2218 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2219 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2220 *hash = hash_hash(mfp); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2221 hi = hash_lookup(&st->ht_match[mtt], mfp, *hash); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2222 if (HASHITEM_EMPTY(hi)) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2223 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2224 if (hash_add_item(&st->ht_match[mtt], hi, mfp, *hash) == FAIL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2225 || ga_grow(&st->ga_match[mtt], 1) != OK) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2226 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2227 // Out of memory! Just forget about the rest. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2228 st->stop_searching = TRUE; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2229 return FAIL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2230 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2231 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2232 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2233 ((char_u **)(st->ga_match[mtt].ga_data)) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2234 [st->ga_match[mtt].ga_len++] = mfp; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2235 st->match_count++; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2236 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2237 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2238 else |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2239 // duplicate tag, drop it |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2240 vim_free(mfp); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2241 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2242 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2243 return OK; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2244 } |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2245 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2246 /* |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2247 * Search for tags matching 'st->orgpat.pat' in the 'st->tag_fname' tags file. |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2248 * Information needed to search for the tags is in the 'st' state structure. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2249 * The matching tags are returned in 'st'. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2250 * Returns OK if successfully processed the file and FAIL on memory allocation |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2251 * failure. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2252 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2253 static int |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2254 find_tags_in_file( |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2255 findtags_state_T *st, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2256 int flags, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2257 char_u *buf_ffname) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2258 { |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2259 FILE *fp = NULL; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2260 tagptrs_T tagp; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2261 int eof = FALSE; // found end-of-file |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2262 int i; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2263 #ifdef FEAT_MULTI_LANG |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2264 int help_pri = 0; |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2265 char_u help_lang[3] = ""; // lang of current tags file |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2266 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2267 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2268 int tag_file_sorted = NUL; // !_TAG_FILE_SORTED value |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2269 off_T filesize; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2270 int tagcmp; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2271 off_T offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2272 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2273 enum |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2274 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2275 TS_START, // at start of file |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2276 TS_LINEAR // linear searching forward, till EOF |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2277 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2278 , TS_BINARY, // binary searching |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2279 TS_SKIP_BACK, // skipping backwards |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2280 TS_STEP_FORWARD // stepping forwards |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2281 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2282 } state; // Current search state |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2283 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2284 struct tag_search_info // Binary search file offsets |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2285 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2286 off_T low_offset; // offset for first char of first line that |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2287 // could match |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2288 off_T high_offset; // offset of char after last line that could |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2289 // match |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2290 off_T curr_offset; // Current file offset in search range |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2291 off_T curr_offset_used; // curr_offset used when skipping back |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2292 off_T match_offset; // Where the binary search found a tag |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2293 int low_char; // first char at low_offset |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2294 int high_char; // first char at high_offset |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2295 } search_info; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2296 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2297 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2298 int cmplen; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2299 int match; // matches |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2300 int match_no_ic = 0;// matches with rm_ic == FALSE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2301 int match_re; // match with regexp |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2302 int matchoff = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2303 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2304 int is_etag; // current file is emaces style |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2305 |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2306 hash_T hash = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2307 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2308 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2309 int sort_error = FALSE; // tags file not sorted |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2310 int sortic = FALSE; // tag file sorted in nocase |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2311 int noic = (flags & TAG_NOIC); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2312 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2313 int line_error = FALSE; // syntax error |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2314 int has_re = (flags & TAG_REGEXP); // regexp used |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2315 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2316 int use_cscope = (flags & TAG_CSCOPE); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2317 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2318 vimconv_T vimconv; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2319 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2320 vimconv.vc_type = CONV_NONE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2321 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2322 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2323 // This is only to avoid a compiler warning for using search_info |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2324 // uninitialised. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2325 CLEAR_FIELD(search_info); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2326 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2327 |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2328 // A file that doesn't exist is silently ignored. Only when not a |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2329 // single file is found, an error message is given (further on). |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2330 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2331 if (use_cscope) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2332 fp = NULL; // avoid GCC warning |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2333 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2334 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2335 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2336 #ifdef FEAT_MULTI_LANG |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2337 if (curbuf->b_help) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2338 { |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2339 if (!findtags_in_help_init(st, flags, help_lang, &help_pri)) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2340 return OK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2341 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2342 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2343 |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2344 if ((fp = mch_fopen((char *)st->tag_fname, "r")) == NULL) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2345 return OK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2346 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2347 if (p_verbose >= 5) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2348 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2349 verbose_enter(); |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2350 smsg(_("Searching tags file %s"), st->tag_fname); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2351 verbose_leave(); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2352 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2353 } |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2354 st->did_open = TRUE; // remember that we found at least one file |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2355 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2356 state = TS_START; // we're at the start of the file |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2357 is_etag = 0; // default is: not emacs style |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2358 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2359 // Read and parse the lines in the file one by one |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2360 for (;;) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2361 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2362 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2363 // check for CTRL-C typed, more often when jumping around |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2364 if (state == TS_BINARY || state == TS_SKIP_BACK) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2365 line_breakcheck(); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2366 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2367 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2368 fast_breakcheck(); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2369 if ((flags & TAG_INS_COMP)) // Double brackets for gcc |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2370 ins_compl_check_keys(30, FALSE); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2371 if (got_int || ins_compl_interrupted()) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2372 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2373 st->stop_searching = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2374 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2375 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2376 // When mincount is TAG_MANY, stop when enough matches have been |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2377 // found (for completion). |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2378 if (st->mincount == TAG_MANY && st->match_count >= TAG_MANY) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2379 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2380 st->stop_searching = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2381 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2382 } |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2383 if (st->get_searchpat) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2384 goto line_read_in; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2385 #ifdef FEAT_TAG_BINS |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2386 // For binary search: compute the next offset to use. |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2387 if (state == TS_BINARY) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2388 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2389 offset = search_info.low_offset + ((search_info.high_offset |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2390 - search_info.low_offset) / 2); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2391 if (offset == search_info.curr_offset) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2392 break; // End the binary search without a match. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2393 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2394 search_info.curr_offset = offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2395 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2396 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2397 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2398 * Skipping back (after a match during binary search). |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2399 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2400 else if (state == TS_SKIP_BACK) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2401 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2402 search_info.curr_offset -= st->lbuf_size * 2; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2403 if (search_info.curr_offset < 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2404 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2405 search_info.curr_offset = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2406 rewind(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2407 state = TS_STEP_FORWARD; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2408 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2409 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2410 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2411 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2412 * When jumping around in the file, first read a line to find the |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2413 * start of the next line. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2414 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2415 if (state == TS_BINARY || state == TS_SKIP_BACK) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2416 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2417 // Adjust the search file offset to the correct position |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2418 search_info.curr_offset_used = search_info.curr_offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2419 vim_fseek(fp, search_info.curr_offset, SEEK_SET); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2420 eof = vim_fgets(st->lbuf, st->lbuf_size, fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2421 if (!eof && search_info.curr_offset != 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2422 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2423 search_info.curr_offset = vim_ftell(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2424 if (search_info.curr_offset == search_info.high_offset) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2425 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2426 // oops, gone a bit too far; try from low offset |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2427 vim_fseek(fp, search_info.low_offset, SEEK_SET); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2428 search_info.curr_offset = search_info.low_offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2429 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2430 eof = vim_fgets(st->lbuf, st->lbuf_size, fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2431 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2432 // skip empty and blank lines |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2433 while (!eof && vim_isblankline(st->lbuf)) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2434 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2435 search_info.curr_offset = vim_ftell(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2436 eof = vim_fgets(st->lbuf, st->lbuf_size, fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2437 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2438 if (eof) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2439 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2440 // Hit end of file. Skip backwards. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2441 state = TS_SKIP_BACK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2442 search_info.match_offset = vim_ftell(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2443 search_info.curr_offset = search_info.curr_offset_used; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2444 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2445 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2446 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2447 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2448 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2449 * Not jumping around in the file: Read the next line. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2450 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2451 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2452 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2453 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2454 // skip empty and blank lines |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2455 do |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2456 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2457 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2458 if (use_cscope) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2459 eof = cs_fgets(st->lbuf, st->lbuf_size); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2460 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2461 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2462 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2463 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2464 search_info.curr_offset = vim_ftell(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2465 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2466 eof = vim_fgets(st->lbuf, st->lbuf_size, fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2467 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2468 } while (!eof && vim_isblankline(st->lbuf)); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2469 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2470 if (eof) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2471 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2472 #ifdef FEAT_EMACS_TAGS |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2473 if (emacs_tags_file_eof(st, &fp) == TRUE) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2474 { |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2475 // an included tags file. Continue processing the parent |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2476 // tags file. |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2477 is_etag = 1; // (only etags can include) |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2478 continue; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2479 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2480 #endif |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2481 break; // end of file |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2482 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2483 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2484 line_read_in: |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2485 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2486 if (vimconv.vc_type != CONV_NONE) |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2487 findtags_string_convert(st, &vimconv); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2488 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2489 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2490 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2491 * Emacs tags line with CTRL-L: New file name on next line. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2492 * The file name is followed by a ','. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2493 * Remember etag file name in ebuf. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2494 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2495 if (*st->lbuf == Ctrl_L |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2496 # ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2497 && !use_cscope |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2498 # endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2499 ) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2500 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2501 is_etag = 1; // in case at the start |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2502 state = TS_LINEAR; |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2503 fp = emacs_tags_new_filename(st, fp, &is_etag); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2504 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2505 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2506 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2507 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2508 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2509 * When still at the start of the file, check for Emacs tags file |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2510 * format, and for "not sorted" flag. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2511 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2512 if (state == TS_START) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2513 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2514 // The header ends when the line sorts below "!_TAG_". When |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2515 // case is folded lower case letters sort before "_". |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2516 if (STRNCMP(st->lbuf, "!_TAG_", 6) <= 0 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2517 || (st->lbuf[0] == '!' && ASCII_ISLOWER(st->lbuf[1]))) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2518 { |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2519 if (tags_file_hdr_parse(st, &vimconv, &tag_file_sorted)) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2520 // Read the next line. Unrecognized flags are ignored. |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2521 continue; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2522 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2523 goto parse_line; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2524 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2525 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2526 // Headers ends. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2527 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2528 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2529 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2530 * When there is no tag head, or ignoring case, need to do a |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2531 * linear search. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2532 * When no "!_TAG_" is found, default to binary search. If |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2533 * the tag file isn't sorted, the second loop will find it. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2534 * When "!_TAG_FILE_SORTED" found: start binary search if |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2535 * flag set. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2536 * For cscope, it's always linear. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2537 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2538 # ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2539 if (st->linear || use_cscope) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2540 # else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2541 if (st->linear) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2542 # endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2543 state = TS_LINEAR; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2544 else if (tag_file_sorted == NUL) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2545 state = TS_BINARY; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2546 else if (tag_file_sorted == '1') |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2547 state = TS_BINARY; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2548 else if (tag_file_sorted == '2') |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2549 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2550 state = TS_BINARY; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2551 sortic = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2552 st->orgpat.regmatch.rm_ic = (p_ic || !noic); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2553 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2554 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2555 state = TS_LINEAR; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2556 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2557 if (state == TS_BINARY && st->orgpat.regmatch.rm_ic && !sortic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2558 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2559 // Binary search won't work for ignoring case, use linear |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2560 // search. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2561 st->linear = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2562 state = TS_LINEAR; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2563 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2564 #else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2565 state = TS_LINEAR; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2566 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2567 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2568 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2569 // When starting a binary search, get the size of the file and |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2570 // compute the first offset. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2571 if (state == TS_BINARY) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2572 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2573 if (vim_fseek(fp, 0L, SEEK_END) != 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2574 // can't seek, don't use binary search |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2575 state = TS_LINEAR; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2576 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2577 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2578 // Get the tag file size (don't use mch_fstat(), it's |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2579 // not portable). Don't use lseek(), it doesn't work |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2580 // properly on MacOS Catalina. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2581 filesize = vim_ftell(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2582 vim_fseek(fp, 0L, SEEK_SET); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2583 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2584 // Calculate the first read offset in the file. Start |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2585 // the search in the middle of the file. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2586 search_info.low_offset = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2587 search_info.low_char = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2588 search_info.high_offset = filesize; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2589 search_info.curr_offset = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2590 search_info.high_char = 0xff; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2591 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2592 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2593 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2594 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2595 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2596 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2597 parse_line: |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2598 // When the line is too long the NUL will not be in the |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2599 // last-but-one byte (see vim_fgets()). |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2600 // Has been reported for Mozilla JS with extremely long names. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2601 // In that case we need to increase lbuf_size. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2602 if (st->lbuf[st->lbuf_size - 2] != NUL |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2603 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2604 && !use_cscope |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2605 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2606 ) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2607 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2608 st->lbuf_size *= 2; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2609 vim_free(st->lbuf); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2610 st->lbuf = alloc(st->lbuf_size); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2611 if (st->lbuf == NULL) |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2612 { |
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2613 if (fp != NULL) |
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2614 fclose(fp); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2615 return FAIL; |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2616 } |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2617 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2618 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2619 if (state == TS_STEP_FORWARD) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2620 // Seek to the same position to read the same line again |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2621 vim_fseek(fp, search_info.curr_offset, SEEK_SET); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2622 // this will try the same thing again, make sure the offset is |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2623 // different |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2624 search_info.curr_offset = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2625 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2626 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2627 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2628 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2629 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2630 * Figure out where the different strings are in this line. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2631 * For "normal" tags: Do a quick check if the tag matches. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2632 * This speeds up tag searching a lot! |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2633 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2634 if (st->orgpat.headlen |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2635 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2636 && !is_etag |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2637 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2638 ) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2639 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2640 CLEAR_FIELD(tagp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2641 tagp.tagname = st->lbuf; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2642 tagp.tagname_end = vim_strchr(st->lbuf, TAB); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2643 if (tagp.tagname_end == NULL) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2644 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2645 // Corrupted tag line. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2646 line_error = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2647 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2648 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2649 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2650 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2651 * Skip this line if the length of the tag is different and |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2652 * there is no regexp, or the tag is too short. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2653 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2654 cmplen = (int)(tagp.tagname_end - tagp.tagname); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2655 if (p_tl != 0 && cmplen > p_tl) // adjust for 'taglength' |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2656 cmplen = p_tl; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2657 if (has_re && st->orgpat.headlen < cmplen) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2658 cmplen = st->orgpat.headlen; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2659 else if (state == TS_LINEAR && st->orgpat.headlen != cmplen) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2660 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2661 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2662 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2663 if (state == TS_BINARY) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2664 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2665 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2666 * Simplistic check for unsorted tags file. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2667 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2668 i = (int)tagp.tagname[0]; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2669 if (sortic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2670 i = (int)TOUPPER_ASC(tagp.tagname[0]); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2671 if (i < search_info.low_char || i > search_info.high_char) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2672 sort_error = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2673 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2674 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2675 * Compare the current tag with the searched tag. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2676 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2677 if (sortic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2678 tagcmp = tag_strnicmp(tagp.tagname, st->orgpat.head, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2679 (size_t)cmplen); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2680 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2681 tagcmp = STRNCMP(tagp.tagname, st->orgpat.head, cmplen); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2682 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2683 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2684 * A match with a shorter tag means to search forward. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2685 * A match with a longer tag means to search backward. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2686 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2687 if (tagcmp == 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2688 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2689 if (cmplen < st->orgpat.headlen) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2690 tagcmp = -1; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2691 else if (cmplen > st->orgpat.headlen) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2692 tagcmp = 1; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2693 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2694 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2695 if (tagcmp == 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2696 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2697 // We've located the tag, now skip back and search |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2698 // forward until the first matching tag is found. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2699 state = TS_SKIP_BACK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2700 search_info.match_offset = search_info.curr_offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2701 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2702 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2703 if (tagcmp < 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2704 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2705 search_info.curr_offset = vim_ftell(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2706 if (search_info.curr_offset < search_info.high_offset) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2707 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2708 search_info.low_offset = search_info.curr_offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2709 if (sortic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2710 search_info.low_char = |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2711 TOUPPER_ASC(tagp.tagname[0]); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2712 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2713 search_info.low_char = tagp.tagname[0]; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2714 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2715 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2716 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2717 if (tagcmp > 0 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2718 && search_info.curr_offset != search_info.high_offset) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2719 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2720 search_info.high_offset = search_info.curr_offset; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2721 if (sortic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2722 search_info.high_char = |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2723 TOUPPER_ASC(tagp.tagname[0]); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2724 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2725 search_info.high_char = tagp.tagname[0]; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2726 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2727 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2728 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2729 // No match yet and are at the end of the binary search. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2730 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2731 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2732 else if (state == TS_SKIP_BACK) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2733 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2734 if (MB_STRNICMP(tagp.tagname, st->orgpat.head, cmplen) != 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2735 state = TS_STEP_FORWARD; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2736 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2737 // Have to skip back more. Restore the curr_offset |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2738 // used, otherwise we get stuck at a long line. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2739 search_info.curr_offset = search_info.curr_offset_used; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2740 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2741 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2742 else if (state == TS_STEP_FORWARD) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2743 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2744 if (MB_STRNICMP(tagp.tagname, st->orgpat.head, cmplen) != 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2745 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2746 if ((off_T)vim_ftell(fp) > search_info.match_offset) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2747 break; // past last match |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2748 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2749 continue; // before first match |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2750 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2751 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2752 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2753 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2754 // skip this match if it can't match |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2755 if (MB_STRNICMP(tagp.tagname, st->orgpat.head, cmplen) != 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2756 continue; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2757 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2758 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2759 * Can be a matching tag, isolate the file name and command. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2760 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2761 tagp.fname = tagp.tagname_end + 1; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2762 tagp.fname_end = vim_strchr(tagp.fname, TAB); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2763 if (tagp.fname_end == NULL) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2764 i = FAIL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2765 else |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2766 { |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2767 tagp.command = tagp.fname_end + 1; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2768 i = OK; |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2769 } |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2770 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2771 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2772 i = parse_tag_line(st->lbuf, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2773 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2774 is_etag, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2775 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2776 &tagp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2777 if (i == FAIL) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2778 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2779 line_error = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2780 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2781 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2782 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2783 #ifdef FEAT_EMACS_TAGS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2784 if (is_etag) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2785 tagp.fname = st->ebuf; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2786 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2787 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2788 * First try matching with the pattern literally (also when it is |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2789 * a regexp). |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2790 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2791 cmplen = (int)(tagp.tagname_end - tagp.tagname); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2792 if (p_tl != 0 && cmplen > p_tl) // adjust for 'taglength' |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2793 cmplen = p_tl; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2794 // if tag length does not match, don't try comparing |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2795 if (st->orgpat.len != cmplen) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2796 match = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2797 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2798 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2799 if (st->orgpat.regmatch.rm_ic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2800 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2801 match = (MB_STRNICMP(tagp.tagname, st->orgpat.pat, cmplen) == 0); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2802 if (match) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2803 match_no_ic = (STRNCMP(tagp.tagname, st->orgpat.pat, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2804 cmplen) == 0); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2805 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2806 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2807 match = (STRNCMP(tagp.tagname, st->orgpat.pat, cmplen) == 0); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2808 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2809 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2810 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2811 * Has a regexp: Also find tags matching regexp. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2812 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2813 match_re = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2814 if (!match && st->orgpat.regmatch.regprog != NULL) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2815 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2816 int cc; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2817 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2818 cc = *tagp.tagname_end; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2819 *tagp.tagname_end = NUL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2820 match = vim_regexec(&st->orgpat.regmatch, tagp.tagname, (colnr_T)0); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2821 if (match) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2822 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2823 matchoff = (int)(st->orgpat.regmatch.startp[0] - tagp.tagname); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2824 if (st->orgpat.regmatch.rm_ic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2825 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2826 st->orgpat.regmatch.rm_ic = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2827 match_no_ic = vim_regexec(&st->orgpat.regmatch, tagp.tagname, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2828 (colnr_T)0); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2829 st->orgpat.regmatch.rm_ic = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2830 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2831 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2832 *tagp.tagname_end = cc; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2833 match_re = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2834 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2835 |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2836 // If a match is found, add it to ht_match[] and ga_match[]. |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2837 if (match) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2838 { |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2839 if (findtags_add_match(st, &tagp, buf_ffname, flags, &hash, |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2840 match_re, match_no_ic, matchoff, |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2841 is_etag, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2842 #ifdef FEAT_MULTI_LANG |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2843 help_lang, help_pri |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2844 #else |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2845 (char_u *)"", 0 |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2846 #endif |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2847 ) == FAIL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2848 break; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2849 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2850 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2851 if (use_cscope && eof) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2852 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2853 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2854 } // forever |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2855 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2856 if (line_error) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2857 { |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2858 semsg(_(e_format_error_in_tags_file_str), st->tag_fname); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2859 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2860 if (!use_cscope) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2861 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2862 semsg(_("Before byte %ld"), (long)vim_ftell(fp)); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2863 st->stop_searching = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2864 line_error = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2865 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2866 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2867 #ifdef FEAT_CSCOPE |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2868 if (!use_cscope) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2869 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2870 fclose(fp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2871 #ifdef FEAT_EMACS_TAGS |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2872 emacs_tags_incstack_free(); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2873 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2874 if (vimconv.vc_type != CONV_NONE) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2875 convert_setup(&vimconv, NULL, NULL); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2876 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2877 #ifdef FEAT_TAG_BINS |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2878 tag_file_sorted = NUL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2879 if (sort_error) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2880 { |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
2881 semsg(_(e_tags_file_not_sorted_str), st->tag_fname); |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2882 sort_error = FALSE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2883 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2884 #endif |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2885 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2886 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2887 * Stop searching if sufficient tags have been found. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2888 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2889 if (st->match_count >= st->mincount) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2890 st->stop_searching = TRUE; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2891 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2892 return OK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2893 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2894 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2895 /* |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2896 * Copy the tags found by find_tags() to 'matchesp'. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2897 */ |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2898 static void |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2899 findtags_copy_matches( |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2900 findtags_state_T *st, |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2901 char_u ***matchesp, |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2902 int *num_matches) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2903 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2904 char_u **matches; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2905 int mtt; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2906 int i; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2907 char_u *mfp; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2908 char_u *p; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2909 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2910 if (st->match_count > 0) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2911 matches = ALLOC_MULT(char_u *, st->match_count); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2912 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2913 matches = NULL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2914 st->match_count = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2915 for (mtt = 0; mtt < MT_COUNT; ++mtt) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2916 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2917 for (i = 0; i < st->ga_match[mtt].ga_len; ++i) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2918 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2919 mfp = ((char_u **)(st->ga_match[mtt].ga_data))[i]; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2920 if (matches == NULL) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2921 vim_free(mfp); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2922 else |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2923 { |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
2924 if (!st->name_only) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2925 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2926 // Change mtt back to zero-based. |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2927 *mfp = *mfp - 1; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2928 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2929 // change the TAG_SEP back to NUL |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2930 for (p = mfp + 1; *p != NUL; ++p) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2931 if (*p == TAG_SEP) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2932 *p = NUL; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2933 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2934 matches[st->match_count++] = mfp; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2935 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2936 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2937 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2938 ga_clear(&st->ga_match[mtt]); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2939 hash_clear(&st->ht_match[mtt]); |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2940 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2941 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2942 *matchesp = matches; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2943 *num_matches = st->match_count; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2944 } |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2945 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2946 /* |
7 | 2947 * find_tags() - search for tags in tags files |
2948 * | |
2949 * Return FAIL if search completely failed (*num_matches will be 0, *matchesp | |
2950 * will be NULL), OK otherwise. | |
2951 * | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2952 * Priority depending on which type of tag is recognized: |
7 | 2953 * 6. A static or global tag with a full matching tag for the current file. |
2954 * 5. A global tag with a full matching tag for another file. | |
2955 * 4. A static tag with a full matching tag for another file. | |
2956 * 3. A static or global tag with an ignore-case matching tag for the | |
2957 * current file. | |
2958 * 2. A global tag with an ignore-case matching tag for another file. | |
2959 * 1. A static tag with an ignore-case matching tag for another file. | |
2960 * | |
2961 * Tags in an emacs-style tags file are always global. | |
2962 * | |
2963 * flags: | |
2964 * TAG_HELP only search for help tags | |
2965 * TAG_NAMES only return name of tag | |
2966 * TAG_REGEXP use "pat" as a regexp | |
2967 * TAG_NOIC don't always ignore case | |
2968 * 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
|
2969 * TAG_CSCOPE use cscope results for tags |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
2970 * TAG_NO_TAGFUNC do not call the 'tagfunc' function |
7 | 2971 */ |
2972 int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2973 find_tags( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2974 char_u *pat, // pattern to search for |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2975 int *num_matches, // return: number of matches found |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2976 char_u ***matchesp, // return: array of matches found |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2977 int flags, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2978 int mincount, // MAXCOL: find all matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2979 // other: minimal number of matches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2980 char_u *buf_ffname) // name of buffer for priority |
7 | 2981 { |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2982 findtags_state_T st; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2983 tagname_T tn; // info for get_tagfname() |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2984 int first_file; // trying first tag file |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2985 int retval = FAIL; // return value |
7 | 2986 #ifdef FEAT_TAG_BINS |
2987 int round; | |
2988 #endif | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2989 |
5513 | 2990 int save_emsg_off; |
7 | 2991 |
2992 int help_save; | |
2993 #ifdef FEAT_MULTI_LANG | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2994 int i; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2995 char_u *saved_pat = NULL; // copy of pat[] |
7 | 2996 #endif |
2997 | |
2998 #ifdef FEAT_TAG_BINS | |
2999 int findall = (mincount == MAXCOL || mincount == TAG_MANY); | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3000 // find all matching tags |
7 | 3001 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3002 int has_re = (flags & TAG_REGEXP); // regexp used |
7 | 3003 int noic = (flags & TAG_NOIC); |
3004 #ifdef FEAT_CSCOPE | |
3005 int use_cscope = (flags & TAG_CSCOPE); | |
3006 #endif | |
3007 int verbose = (flags & TAG_VERBOSE); | |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3008 int save_p_ic = p_ic; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3009 |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3010 /* |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3011 * 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
|
3012 * duration of this function. |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3013 */ |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3014 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
|
3015 { |
10444
2edda415c28a
commit https://github.com/vim/vim/commit/6dbf66aa3e2197ce41f2b1cc7602bb9c15840548
Christian Brabandt <cb@256bit.org>
parents:
10430
diff
changeset
|
3016 case TC_FOLLOWIC: break; |
9913
bb00c661b3a4
commit https://github.com/vim/vim/commit/66e29d7112e437b2b50efe1f82c7e892736d23e4
Christian Brabandt <cb@256bit.org>
parents:
9850
diff
changeset
|
3017 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
|
3018 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
|
3019 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
|
3020 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
|
3021 } |
7 | 3022 |
3023 help_save = curbuf->b_help; | |
3024 | |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3025 if (findtags_state_init(&st, pat, flags, mincount) == FAIL) |
7 | 3026 goto findtag_end; |
3027 | |
3028 #ifdef FEAT_CSCOPE | |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
3029 STRCPY(st.tag_fname, "from cscope"); // for error messages |
7 | 3030 #endif |
3031 | |
3032 /* | |
3033 * Initialize a few variables | |
3034 */ | |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3035 if (st.help_only) // want tags from help file |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3036 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
|
3037 #ifdef FEAT_CSCOPE |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
3038 else if (use_cscope) |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
3039 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3040 // Make sure we don't mix help and cscope, confuses Coverity. |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3041 st.help_only = FALSE; |
10666
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
3042 curbuf->b_help = FALSE; |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
3043 } |
ed6f03535745
patch 8.0.0223: Coverity warns for an uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10654
diff
changeset
|
3044 #endif |
7 | 3045 |
3046 #ifdef FEAT_MULTI_LANG | |
3047 if (curbuf->b_help) | |
3048 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3049 // When "@ab" is specified use only the "ab" language, otherwise |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3050 // search all languages. |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3051 if (st.orgpat.len > 3 && pat[st.orgpat.len - 3] == '@' |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3052 && ASCII_ISALPHA(pat[st.orgpat.len - 2]) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3053 && ASCII_ISALPHA(pat[st.orgpat.len - 1])) |
7 | 3054 { |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3055 saved_pat = vim_strnsave(pat, st.orgpat.len - 3); |
7 | 3056 if (saved_pat != NULL) |
3057 { | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3058 st.help_lang_find = &pat[st.orgpat.len - 2]; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3059 st.orgpat.pat = saved_pat; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3060 st.orgpat.len -= 3; |
7 | 3061 } |
3062 } | |
3063 } | |
3064 #endif | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3065 if (p_tl != 0 && st.orgpat.len > p_tl) // adjust for 'taglength' |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3066 st.orgpat.len = p_tl; |
3131 | 3067 |
5513 | 3068 save_emsg_off = emsg_off; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3069 emsg_off = TRUE; // don't want error for invalid RE here |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3070 prepare_pats(&st.orgpat, has_re); |
5513 | 3071 emsg_off = save_emsg_off; |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3072 if (has_re && st.orgpat.regmatch.regprog == NULL) |
3784 | 3073 goto findtag_end; |
7 | 3074 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3075 #ifdef FEAT_EVAL |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3076 retval = findtags_apply_tfu(pat, &st, flags, buf_ffname); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3077 if (retval != NOTDONE) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3078 goto findtag_end; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3079 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3080 // re-initialize the default return value |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3081 retval = FAIL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3082 #endif |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3083 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3084 #ifdef FEAT_MULTI_LANG |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3085 // Set a flag if the file extension is .txt |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3086 if ((flags & TAG_KEEP_LANG) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3087 && st.help_lang_find == NULL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3088 && curbuf->b_fname != NULL |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3089 && (i = (int)STRLEN(curbuf->b_fname)) > 4 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3090 && STRICMP(curbuf->b_fname + i - 4, ".txt") == 0) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3091 st.is_txt = TRUE; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3092 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3093 |
413 | 3094 /* |
3095 * When finding a specified number of matches, first try with matching | |
3096 * case, so binary search can be used, and try ignore-case matches in a | |
3097 * second loop. | |
3098 * When finding all matches, 'tagbsearch' is off, or there is no fixed | |
3099 * string to look for, ignore case right away to avoid going though the | |
3100 * tags files twice. | |
3101 * When the tag file is case-fold sorted, it is either one or the other. | |
3102 * Only ignore case when TAG_NOIC not used or 'ignorecase' set. | |
3103 */ | |
7 | 3104 #ifdef FEAT_TAG_BINS |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3105 st.orgpat.regmatch.rm_ic = ((p_ic || !noic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3106 && (findall || st.orgpat.headlen == 0 || !p_tbs)); |
7 | 3107 for (round = 1; round <= 2; ++round) |
3108 { | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3109 st.linear = (st.orgpat.headlen == 0 || !p_tbs || round == 2); |
7 | 3110 #else |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3111 st.orgpat.regmatch.rm_ic = (p_ic || !noic); |
7 | 3112 #endif |
3113 | |
3114 /* | |
3115 * Try tag file names from tags option one by one. | |
3116 */ | |
3117 for (first_file = TRUE; | |
3118 #ifdef FEAT_CSCOPE | |
3119 use_cscope || | |
3120 #endif | |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
3121 get_tagfname(&tn, first_file, st.tag_fname) == OK; |
692 | 3122 first_file = FALSE) |
7 | 3123 { |
27942
4a76119d6372
patch 8.2.4496: Coverity gives warnings after tags code refactoring
Bram Moolenaar <Bram@vim.org>
parents:
27938
diff
changeset
|
3124 if (find_tags_in_file(&st, flags, buf_ffname) == FAIL) |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3125 goto findtag_end; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3126 if (st.stop_searching |
7 | 3127 #ifdef FEAT_CSCOPE |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3128 || use_cscope |
7 | 3129 #endif |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3130 ) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3131 { |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3132 retval = OK; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3133 break; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3134 } |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3135 } // end of for-each-file loop |
7 | 3136 |
692 | 3137 #ifdef FEAT_CSCOPE |
3138 if (!use_cscope) | |
3139 #endif | |
3140 tagname_free(&tn); | |
3141 | |
7 | 3142 #ifdef FEAT_TAG_BINS |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3143 // stop searching when already did a linear search, or when TAG_NOIC |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3144 // used, and 'ignorecase' not set or already did case-ignore search |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3145 if (st.stop_searching || st.linear || (!p_ic && noic) || |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3146 st.orgpat.regmatch.rm_ic) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3147 break; |
7 | 3148 # ifdef FEAT_CSCOPE |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3149 if (use_cscope) |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3150 break; |
7 | 3151 # endif |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3152 |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3153 // try another time while ignoring case |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3154 st.orgpat.regmatch.rm_ic = TRUE; |
7 | 3155 } |
3156 #endif | |
3157 | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3158 if (!st.stop_searching) |
7 | 3159 { |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3160 if (!st.did_open && verbose) // never opened any tags file |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3161 emsg(_(e_no_tags_file)); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3162 retval = OK; // It's OK even when no tag found |
7 | 3163 } |
3164 | |
3165 findtag_end: | |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3166 findtags_state_free(&st); |
7 | 3167 |
3168 /* | |
11008
0ecd07cd2e43
patch 8.0.0393: order of duplicate tags is not preserved
Christian Brabandt <cb@256bit.org>
parents:
10666
diff
changeset
|
3169 * Move the matches from the ga_match[] arrays into one list of |
7 | 3170 * matches. When retval == FAIL, free the matches. |
3171 */ | |
3172 if (retval == FAIL) | |
27938
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3173 st.match_count = 0; |
b65a50d2fa4f
patch 8.2.4494: the find_tags() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
3174 |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3175 findtags_copy_matches(&st, matchesp, num_matches); |
7 | 3176 |
3177 curbuf->b_help = help_save; | |
3178 #ifdef FEAT_MULTI_LANG | |
3179 vim_free(saved_pat); | |
3180 #endif | |
3181 | |
7266
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3182 p_ic = save_p_ic; |
6ba7182fb7bd
commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents:
6851
diff
changeset
|
3183 |
7 | 3184 return retval; |
3185 } | |
3186 | |
3187 static garray_T tag_fnames = GA_EMPTY; | |
3188 | |
3189 /* | |
3190 * Callback function for finding all "tags" and "tags-??" files in | |
3191 * 'runtimepath' doc directories. | |
3192 */ | |
3193 static void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3194 found_tagfile_cb(char_u *fname, void *cookie UNUSED) |
7 | 3195 { |
3196 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
|
3197 { |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3198 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
|
3199 |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3200 #ifdef BACKSLASH_IN_FILENAME |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3201 slash_adjust(tag_fname); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3202 #endif |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3203 simplify_filename(tag_fname); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3204 ((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
|
3205 } |
7 | 3206 } |
3207 | |
359 | 3208 #if defined(EXITFREE) || defined(PROTO) |
3209 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3210 free_tag_stuff(void) |
359 | 3211 { |
692 | 3212 ga_clear_strings(&tag_fnames); |
16511
4182f74e2965
patch 8.1.1259: crash when exiting early
Bram Moolenaar <Bram@vim.org>
parents:
16461
diff
changeset
|
3213 if (curwin != NULL) |
4182f74e2965
patch 8.1.1259: crash when exiting early
Bram Moolenaar <Bram@vim.org>
parents:
16461
diff
changeset
|
3214 do_tag(NULL, DT_FREE, 0, 0, 0); |
1818 | 3215 tag_freematch(); |
3216 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3217 # if defined(FEAT_QUICKFIX) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3218 tagstack_clear_entry(&ptag_entry); |
1818 | 3219 # endif |
359 | 3220 } |
3221 #endif | |
3222 | |
7 | 3223 /* |
3224 * Get the next name of a tag file from the tag file list. | |
3225 * For help files, use "tags" file only. | |
3226 * | |
3227 * Return FAIL if no more tag file names, OK otherwise. | |
3228 */ | |
514 | 3229 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3230 get_tagfname( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3231 tagname_T *tnp, // holds status info |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3232 int first, // TRUE when first file name is wanted |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3233 char_u *buf) // pointer to buffer of MAXPATHL chars |
7 | 3234 { |
3235 char_u *fname = NULL; | |
3236 char_u *r_ptr; | |
14232
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3237 int i; |
7 | 3238 |
692 | 3239 if (first) |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
3240 CLEAR_POINTER(tnp); |
692 | 3241 |
514 | 3242 if (curbuf->b_help) |
7 | 3243 { |
514 | 3244 /* |
3245 * For help files it's done in a completely different way: | |
3246 * Find "doc/tags" and "doc/tags-??" in all directories in | |
3247 * 'runtimepath'. | |
3248 */ | |
3249 if (first) | |
7 | 3250 { |
3251 ga_clear_strings(&tag_fnames); | |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
27018
diff
changeset
|
3252 ga_init2(&tag_fnames, sizeof(char_u *), 10); |
7 | 3253 do_in_runtimepath((char_u *) |
3254 #ifdef FEAT_MULTI_LANG | |
36 | 3255 # ifdef VMS |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3256 // Functions decc$to_vms() and decc$translate_vms() crash |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3257 // on some VMS systems with wildcards "??". Seems ECO |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3258 // patches do fix the problem in C RTL, but we can't use |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3259 // an #ifdef for that. |
36 | 3260 "doc/tags doc/tags-*" |
3261 # else | |
7 | 3262 "doc/tags doc/tags-??" |
36 | 3263 # endif |
7 | 3264 #else |
3265 "doc/tags" | |
3266 #endif | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
7835
diff
changeset
|
3267 , DIP_ALL, found_tagfile_cb, NULL); |
7 | 3268 } |
602 | 3269 |
692 | 3270 if (tnp->tn_hf_idx >= tag_fnames.ga_len) |
7 | 3271 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3272 // Not found in 'runtimepath', use 'helpfile', if it exists and |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3273 // wasn't used yet, replacing "help.txt" with "tags". |
692 | 3274 if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL) |
7 | 3275 return FAIL; |
692 | 3276 ++tnp->tn_hf_idx; |
7 | 3277 STRCPY(buf, p_hf); |
3278 STRCPY(gettail(buf), "tags"); | |
14232
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3279 #ifdef BACKSLASH_IN_FILENAME |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3280 slash_adjust(buf); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3281 #endif |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3282 simplify_filename(buf); |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3283 |
4afe2386aae8
patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
3284 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
|
3285 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
|
3286 return FAIL; // avoid duplicate file names |
7 | 3287 } |
3288 else | |
692 | 3289 vim_strncpy(buf, ((char_u **)(tag_fnames.ga_data))[ |
3290 tnp->tn_hf_idx++], MAXPATHL - 1); | |
514 | 3291 return OK; |
3292 } | |
3293 | |
3294 if (first) | |
3295 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3296 // Init. We make a copy of 'tags', because autocommands may change |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3297 // the value without notifying us. |
692 | 3298 tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL) |
3299 ? curbuf->b_p_tags : p_tags); | |
3300 if (tnp->tn_tags == NULL) | |
3301 return FAIL; | |
3302 tnp->tn_np = tnp->tn_tags; | |
7 | 3303 } |
692 | 3304 |
3305 /* | |
3306 * Loop until we have found a file name that can be used. | |
3307 * There are two states: | |
3308 * tnp->tn_did_filefind_init == FALSE: setup for next part in 'tags'. | |
3309 * tnp->tn_did_filefind_init == TRUE: find next file in this part. | |
3310 */ | |
3311 for (;;) | |
7 | 3312 { |
692 | 3313 if (tnp->tn_did_filefind_init) |
7 | 3314 { |
692 | 3315 fname = vim_findfile(tnp->tn_search_ctx); |
3316 if (fname != NULL) | |
3317 break; | |
3318 | |
3319 tnp->tn_did_filefind_init = FALSE; | |
3320 } | |
3321 else | |
3322 { | |
3323 char_u *filename = NULL; | |
3324 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3325 // Stop when used all parts of 'tags'. |
692 | 3326 if (*tnp->tn_np == NUL) |
7 | 3327 { |
692 | 3328 vim_findfile_cleanup(tnp->tn_search_ctx); |
3329 tnp->tn_search_ctx = NULL; | |
3330 return FAIL; | |
7 | 3331 } |
692 | 3332 |
3333 /* | |
3334 * Copy next file name into buf. | |
3335 */ | |
3336 buf[0] = NUL; | |
3337 (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,"); | |
7 | 3338 |
3339 #ifdef FEAT_PATH_EXTRA | |
692 | 3340 r_ptr = vim_findfile_stopdir(buf); |
7 | 3341 #else |
692 | 3342 r_ptr = NULL; |
7 | 3343 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3344 // move the filename one char forward and truncate the |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3345 // filepath with a NUL |
692 | 3346 filename = gettail(buf); |
1620 | 3347 STRMOVE(filename + 1, filename); |
692 | 3348 *filename++ = NUL; |
3349 | |
3350 tnp->tn_search_ctx = vim_findfile_init(buf, filename, | |
3351 r_ptr, 100, | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3352 FALSE, // don't free visited list |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3353 FINDFILE_FILE, // we search for a file |
692 | 3354 tnp->tn_search_ctx, TRUE, curbuf->b_ffname); |
3355 if (tnp->tn_search_ctx != NULL) | |
3356 tnp->tn_did_filefind_init = TRUE; | |
7 | 3357 } |
3358 } | |
3359 | |
692 | 3360 STRCPY(buf, fname); |
3361 vim_free(fname); | |
7 | 3362 return OK; |
3363 } | |
3364 | |
3365 /* | |
692 | 3366 * Free the contents of a tagname_T that was filled by get_tagfname(). |
3367 */ | |
3368 void | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3369 tagname_free(tagname_T *tnp) |
692 | 3370 { |
3371 vim_free(tnp->tn_tags); | |
3372 vim_findfile_cleanup(tnp->tn_search_ctx); | |
1541 | 3373 tnp->tn_search_ctx = NULL; |
692 | 3374 ga_clear_strings(&tag_fnames); |
3375 } | |
3376 | |
3377 /* | |
7 | 3378 * Parse one line from the tags file. Find start/end of tag name, start/end of |
3379 * file name and start of search pattern. | |
3380 * | |
3381 * If is_etag is TRUE, tagp->fname and tagp->fname_end are not set. | |
3382 * | |
3383 * Return FAIL if there is a format error in this line, OK otherwise. | |
3384 */ | |
3385 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3386 parse_tag_line( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3387 char_u *lbuf, // line to be parsed |
7 | 3388 #ifdef FEAT_EMACS_TAGS |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3389 int is_etag, |
7 | 3390 #endif |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3391 tagptrs_T *tagp) |
7 | 3392 { |
3393 char_u *p; | |
3394 | |
3395 #ifdef FEAT_EMACS_TAGS | |
3396 if (is_etag) | |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3397 // emacs-style tag file |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3398 return emacs_tags_parse_line(lbuf, tagp); |
7 | 3399 #endif |
27974
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3400 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3401 // Isolate the tagname, from lbuf up to the first white |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3402 tagp->tagname = lbuf; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3403 p = vim_strchr(lbuf, TAB); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3404 if (p == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3405 return FAIL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3406 tagp->tagname_end = p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3407 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3408 // Isolate file name, from first to second white space |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3409 if (*p != NUL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3410 ++p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3411 tagp->fname = p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3412 p = vim_strchr(p, TAB); |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3413 if (p == NULL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3414 return FAIL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3415 tagp->fname_end = p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3416 |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3417 // find start of search command, after second white space |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3418 if (*p != NUL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3419 ++p; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3420 if (*p == NUL) |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3421 return FAIL; |
495418c6cac8
patch 8.2.4512: the find_tags_in_file() function is much too long
Bram Moolenaar <Bram@vim.org>
parents:
27942
diff
changeset
|
3422 tagp->command = p; |
7 | 3423 |
3424 return OK; | |
3425 } | |
3426 | |
3427 /* | |
3428 * Check if tagname is a static tag | |
3429 * | |
3430 * Static tags produced by the older ctags program have the format: | |
3431 * 'file:tag file /pattern'. | |
1204 | 3432 * This is only recognized when both occurrence of 'file' are the same, to |
7 | 3433 * avoid recognizing "string::string" or ":exit". |
3434 * | |
3435 * Static tags produced by the new ctags program have the format: | |
3436 * 'tag file /pattern/;"<Tab>file:' " | |
3437 * | |
3438 * Return TRUE if it is a static tag and adjust *tagname to the real tag. | |
3439 * Return FALSE if it is not a static tag. | |
3440 */ | |
3441 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3442 test_for_static(tagptrs_T *tagp) |
7 | 3443 { |
3444 char_u *p; | |
3445 | |
3446 /* | |
3447 * Check for new style static tag ":...<Tab>file:[<Tab>...]" | |
3448 */ | |
3449 p = tagp->command; | |
3450 while ((p = vim_strchr(p, '\t')) != NULL) | |
3451 { | |
3452 ++p; | |
3453 if (STRNCMP(p, "file:", 5) == 0) | |
3454 return TRUE; | |
3455 } | |
3456 | |
3457 return FALSE; | |
3458 } | |
3459 | |
3460 /* | |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3461 * 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
|
3462 */ |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3463 static size_t |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3464 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
|
3465 { |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3466 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
|
3467 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3468 // 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
|
3469 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
|
3470 #ifdef FEAT_EMACS_TAGS |
13227
b88fa651c824
patch 8.0.1488: emacs tags no longer work
Christian Brabandt <cb@256bit.org>
parents:
13068
diff
changeset
|
3471 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
|
3472 #endif |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3473 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
|
3474 } |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3475 |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3476 /* |
7 | 3477 * Parse a line from a matching tag. Does not change the line itself. |
3478 * | |
3479 * The line that we get looks like this: | |
3480 * Emacs tag: <mtt><tag_fname><NUL><ebuf><NUL><lbuf> | |
3481 * other tag: <mtt><tag_fname><NUL><NUL><lbuf> | |
3482 * without Emacs tags: <mtt><tag_fname><NUL><lbuf> | |
3483 * | |
3484 * Return OK or FAIL. | |
3485 */ | |
3486 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3487 parse_match( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3488 char_u *lbuf, // input: matching line |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3489 tagptrs_T *tagp) // output: pointers into the line |
7 | 3490 { |
3491 int retval; | |
3492 char_u *p; | |
3493 char_u *pc, *pt; | |
3494 | |
3495 tagp->tag_fname = lbuf + 1; | |
3496 lbuf += STRLEN(tagp->tag_fname) + 2; | |
3497 #ifdef FEAT_EMACS_TAGS | |
3498 if (*lbuf) | |
3499 { | |
3500 tagp->is_etag = TRUE; | |
3501 tagp->fname = lbuf; | |
3502 lbuf += STRLEN(lbuf); | |
3503 tagp->fname_end = lbuf++; | |
3504 } | |
3505 else | |
3506 { | |
3507 tagp->is_etag = FALSE; | |
3508 ++lbuf; | |
3509 } | |
3510 #endif | |
3511 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3512 // Find search pattern and the file name for non-etags. |
7 | 3513 retval = parse_tag_line(lbuf, |
3514 #ifdef FEAT_EMACS_TAGS | |
3515 tagp->is_etag, | |
3516 #endif | |
3517 tagp); | |
3518 | |
3519 tagp->tagkind = NULL; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3520 tagp->user_data = NULL; |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3521 tagp->tagline = 0; |
7 | 3522 tagp->command_end = NULL; |
3523 | |
3524 if (retval == OK) | |
3525 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3526 // Try to find a kind field: "kind:<kind>" or just "<kind>" |
7 | 3527 p = tagp->command; |
3528 if (find_extra(&p) == OK) | |
3529 { | |
15808
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3530 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
|
3531 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
|
3532 else |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3533 tagp->command_end = p; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3534 p += 2; // skip ";\"" |
7 | 3535 if (*p++ == TAB) |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3536 // Accept ASCII alphabetic kind characters and any multi-byte |
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3537 // character. |
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3538 while (ASCII_ISALPHA(*p) || mb_ptr2len(p) > 1) |
7 | 3539 { |
3540 if (STRNCMP(p, "kind:", 5) == 0) | |
3541 tagp->tagkind = p + 5; | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3542 else if (STRNCMP(p, "user_data:", 10) == 0) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3543 tagp->user_data = p + 10; |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3544 else if (STRNCMP(p, "line:", 5) == 0) |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3545 tagp->tagline = atoi((char *)p + 5); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3546 if (tagp->tagkind != NULL && tagp->user_data != NULL) |
7 | 3547 break; |
3548 pc = vim_strchr(p, ':'); | |
3549 pt = vim_strchr(p, '\t'); | |
3550 if (pc == NULL || (pt != NULL && pc > pt)) | |
3551 tagp->tagkind = p; | |
3552 if (pt == NULL) | |
3553 break; | |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3554 p = pt; |
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3555 MB_PTR_ADV(p); |
7 | 3556 } |
3557 } | |
3558 if (tagp->tagkind != NULL) | |
3559 { | |
3560 for (p = tagp->tagkind; | |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3561 *p && *p != '\t' && *p != '\r' && *p != '\n'; MB_PTR_ADV(p)) |
7 | 3562 ; |
3563 tagp->tagkind_end = p; | |
3564 } | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3565 if (tagp->user_data != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3566 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3567 for (p = tagp->user_data; |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3568 *p && *p != '\t' && *p != '\r' && *p != '\n'; MB_PTR_ADV(p)) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3569 ; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3570 tagp->user_data_end = p; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
3571 } |
7 | 3572 } |
3573 return retval; | |
3574 } | |
3575 | |
3576 /* | |
3577 * Find out the actual file name of a tag. Concatenate the tags file name | |
3578 * with the matching tag file name. | |
3579 * Returns an allocated string or NULL (out of memory). | |
3580 */ | |
3581 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3582 tag_full_fname(tagptrs_T *tagp) |
7 | 3583 { |
3584 char_u *fullname; | |
3585 int c; | |
3586 | |
3587 #ifdef FEAT_EMACS_TAGS | |
3588 if (tagp->is_etag) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3589 c = 0; // to shut up GCC |
7 | 3590 else |
3591 #endif | |
3592 { | |
3593 c = *tagp->fname_end; | |
3594 *tagp->fname_end = NUL; | |
3595 } | |
3596 fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE); | |
3597 | |
3598 #ifdef FEAT_EMACS_TAGS | |
3599 if (!tagp->is_etag) | |
3600 #endif | |
3601 *tagp->fname_end = c; | |
3602 | |
3603 return fullname; | |
3604 } | |
3605 | |
3606 /* | |
3607 * Jump to a tag that has been found in one of the tag files | |
3608 * | |
3609 * returns OK for success, NOTAGFILE when file not found, FAIL otherwise. | |
3610 */ | |
3611 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3612 jumpto_tag( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3613 char_u *lbuf_arg, // line from the tags file for this tag |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3614 int forceit, // :ta with ! |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3615 int keep_help) // keep help flag (FALSE for cscope) |
7 | 3616 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3617 optmagic_T save_magic_overruled; |
7 | 3618 int save_p_ws, save_p_scs, save_p_ic; |
3619 linenr_T save_lnum; | |
3620 char_u *str; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3621 char_u *pbuf; // search pattern buffer |
7 | 3622 char_u *pbuf_end; |
3623 char_u *tofree_fname = NULL; | |
3624 char_u *fname; | |
3625 tagptrs_T tagp; | |
3626 int retval = FAIL; | |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3627 int getfile_result = GETFILE_UNUSED; |
7 | 3628 int search_options; |
3629 #ifdef FEAT_SEARCH_EXTRA | |
3630 int save_no_hlsearch; | |
3631 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3632 #if defined(FEAT_QUICKFIX) |
7 | 3633 win_T *curwin_save = NULL; |
3634 #endif | |
3635 char_u *full_fname = NULL; | |
3636 #ifdef FEAT_FOLDING | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3637 int old_KeyTyped = KeyTyped; // getting the file may reset it |
7 | 3638 #endif |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3639 size_t len; |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3640 char_u *lbuf; |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3641 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3642 // Make a copy of the line, it can become invalid when an autocommand calls |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3643 // back here recursively. |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3644 len = matching_line_len(lbuf_arg) + 1; |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3645 lbuf = alloc(len); |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3646 if (lbuf != NULL) |
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3647 mch_memmove(lbuf, lbuf_arg, len); |
7 | 3648 |
3649 pbuf = alloc(LSIZE); | |
3650 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3651 // 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
|
3652 if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL) |
7 | 3653 { |
3654 tagp.fname_end = NULL; | |
3655 goto erret; | |
3656 } | |
3657 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3658 // truncate the file name, so it can be used as a string |
7 | 3659 *tagp.fname_end = NUL; |
3660 fname = tagp.fname; | |
3661 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3662 // copy the command to pbuf[], remove trailing CR/NL |
7 | 3663 str = tagp.command; |
3664 for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; ) | |
3665 { | |
3666 #ifdef FEAT_EMACS_TAGS | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3667 if (tagp.is_etag && *str == ',')// stop at ',' after line number |
7 | 3668 break; |
3669 #endif | |
3670 *pbuf_end++ = *str++; | |
18550
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
3671 if (pbuf_end - pbuf + 1 >= LSIZE) |
90e5812af76b
patch 8.1.2269: tags file with very long line stops using binary search
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
3672 break; |
7 | 3673 } |
3674 *pbuf_end = NUL; | |
3675 | |
3676 #ifdef FEAT_EMACS_TAGS | |
3677 if (!tagp.is_etag) | |
3678 #endif | |
3679 { | |
3680 /* | |
3681 * Remove the "<Tab>fieldname:value" stuff; we don't need it here. | |
3682 */ | |
3683 str = pbuf; | |
3684 if (find_extra(&str) == OK) | |
3685 { | |
3686 pbuf_end = str; | |
3687 *pbuf_end = NUL; | |
3688 } | |
3689 } | |
3690 | |
3691 /* | |
3692 * Expand file name, when needed (for environment variables). | |
3693 * If 'tagrelative' option set, may change file name. | |
3694 */ | |
3695 fname = expand_tag_fname(fname, tagp.tag_fname, TRUE); | |
3696 if (fname == NULL) | |
3697 goto erret; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3698 tofree_fname = fname; // free() it later |
7 | 3699 |
3700 /* | |
3701 * Check if the file with the tag exists before abandoning the current | |
3702 * file. Also accept a file name for which there is a matching BufReadCmd | |
3703 * autocommand event (e.g., http://sys/file). | |
3704 */ | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
3705 if (mch_getperm(fname) < 0 && !has_autocmd(EVENT_BUFREADCMD, fname, NULL)) |
7 | 3706 { |
3707 retval = NOTAGFILE; | |
3708 vim_free(nofile_fname); | |
3709 nofile_fname = vim_strsave(fname); | |
3710 if (nofile_fname == NULL) | |
3711 nofile_fname = empty_option; | |
3712 goto erret; | |
3713 } | |
3714 | |
3715 ++RedrawingDisabled; | |
3716 | |
3717 #ifdef FEAT_GUI | |
3718 need_mouse_correct = TRUE; | |
3719 #endif | |
3720 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3721 #if defined(FEAT_QUICKFIX) |
2713 | 3722 if (g_do_tagpreview != 0) |
7 | 3723 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3724 postponed_split = 0; // don't split again below |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3725 curwin_save = curwin; // Save current window |
728 | 3726 |
7 | 3727 /* |
3728 * If we are reusing a window, we may change dir when | |
3729 * entering it (autocommands) so turn the tag filename | |
3730 * into a fullpath | |
3731 */ | |
3732 if (!curwin->w_p_pvw) | |
3733 { | |
3734 full_fname = FullName_save(fname, FALSE); | |
3735 fname = full_fname; | |
3736 | |
3737 /* | |
3738 * Make the preview window the current window. | |
3739 * Open a preview window when needed. | |
3740 */ | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3741 prepare_tagpreview(TRUE, TRUE, FALSE); |
7 | 3742 } |
3743 } | |
3744 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3745 // If it was a CTRL-W CTRL-] command split window now. For ":tab tag" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3746 // 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
|
3747 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
|
3748 { |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3749 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
|
3750 |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3751 if (existing_buf != NULL) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3752 { |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3753 win_T *wp = NULL; |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3754 |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3755 if (swb_flags & SWB_USEOPEN) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3756 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
|
3757 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3758 // If 'switchbuf' contains "usetab": jump to first window in any tab |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3759 // page containing "existing_buf" if one exists |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3760 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
|
3761 wp = buf_jump_open_tab(existing_buf); |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3762 // We've switched to the buffer, the usual loading of the file must |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3763 // be skipped. |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3764 if (wp != NULL) |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3765 getfile_result = GETFILE_SAME_FILE; |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3766 } |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3767 } |
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3768 if (getfile_result == GETFILE_UNUSED |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21996
diff
changeset
|
3769 && (postponed_split || cmdmod.cmod_tab != 0)) |
7 | 3770 { |
11238
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3771 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
|
3772 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
|
3773 { |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3774 --RedrawingDisabled; |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3775 goto erret; |
5b524c2286ce
patch 8.0.0505: failed window split for :stag not handled
Christian Brabandt <cb@256bit.org>
parents:
11225
diff
changeset
|
3776 } |
2583 | 3777 RESET_BINDING(curwin); |
7 | 3778 } |
3779 #endif | |
3780 | |
3781 if (keep_help) | |
3782 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3783 // A :ta from a help file will keep the b_help flag set. For ":ptag" |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3784 // 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
|
3785 #if defined(FEAT_QUICKFIX) |
2713 | 3786 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
|
3787 keep_help_flag = bt_help(curwin_save->w_buffer); |
7 | 3788 else |
3789 #endif | |
3790 keep_help_flag = curbuf->b_help; | |
3791 } | |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3792 |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3793 if (getfile_result == GETFILE_UNUSED) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3794 // Careful: getfile() may trigger autocommands and call jumpto_tag() |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3795 // recursively. |
11476
c45fb081391c
patch 8.0.0621: :stag does not respect 'switchbuf'
Christian Brabandt <cb@256bit.org>
parents:
11329
diff
changeset
|
3796 getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); |
7 | 3797 keep_help_flag = FALSE; |
3798 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3799 if (GETFILE_SUCCESS(getfile_result)) // got to the right file |
7 | 3800 { |
3801 curwin->w_set_curswant = TRUE; | |
3802 postponed_split = 0; | |
3803 | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
3804 save_magic_overruled = magic_overruled; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
3805 magic_overruled = OPTION_MAGIC_OFF; // always execute with 'nomagic' |
7 | 3806 #ifdef FEAT_SEARCH_EXTRA |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3807 // Save value of no_hlsearch, jumping to a tag is not a real search |
7 | 3808 save_no_hlsearch = no_hlsearch; |
3809 #endif | |
24594
5c456a88f651
patch 8.2.2836: build failure without the +quickfix feature
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
3810 #if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX) |
24053
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3811 // getfile() may have cleared options, apply 'previewpopup' again. |
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3812 if (g_do_tagpreview != 0 && *p_pvp != NUL) |
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3813 parse_previewpopup(curwin); |
bcf16185be60
patch 8.2.2568: second time a preview popup is opened highlight is not set
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
3814 #endif |
7 | 3815 |
3816 /* | |
3817 * If 'cpoptions' contains 't', store the search pattern for the "n" | |
3818 * command. If 'cpoptions' does not contain 't', the search pattern | |
3819 * is not stored. | |
3820 */ | |
3821 if (vim_strchr(p_cpo, CPO_TAGPAT) != NULL) | |
3822 search_options = 0; | |
3823 else | |
3824 search_options = SEARCH_KEEP; | |
3825 | |
3826 /* | |
3827 * If the command is a search, try here. | |
3828 * | |
3829 * Reset 'smartcase' for the search, since the search pattern was not | |
3830 * typed by the user. | |
3831 * Only use do_search() when there is a full search command, without | |
3832 * anything following. | |
3833 */ | |
3834 str = pbuf; | |
3835 if (pbuf[0] == '/' || pbuf[0] == '?') | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3836 str = skip_regexp(pbuf + 1, pbuf[0], FALSE) + 1; |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3837 if (str > pbuf_end - 1) // search command with nothing following |
7 | 3838 { |
3839 save_p_ws = p_ws; | |
3840 save_p_ic = p_ic; | |
3841 save_p_scs = p_scs; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3842 p_ws = TRUE; // need 'wrapscan' for backward searches |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3843 p_ic = FALSE; // don't ignore case now |
7 | 3844 p_scs = FALSE; |
3845 save_lnum = curwin->w_cursor.lnum; | |
18640
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3846 if (tagp.tagline > 0) |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3847 // start search before line from "line:" field |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3848 curwin->w_cursor.lnum = tagp.tagline - 1; |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3849 else |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3850 // start search before first line |
b9240fe40dd4
patch 8.1.2312: "line:" field in tags file not used
Bram Moolenaar <Bram@vim.org>
parents:
18554
diff
changeset
|
3851 curwin->w_cursor.lnum = 0; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3852 if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3853 search_options, NULL)) |
7 | 3854 retval = OK; |
3855 else | |
3856 { | |
3857 int found = 1; | |
3858 int cc; | |
3859 | |
3860 /* | |
3861 * try again, ignore case now | |
3862 */ | |
3863 p_ic = TRUE; | |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3864 if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3865 search_options, NULL)) |
7 | 3866 { |
3867 /* | |
3868 * Failed to find pattern, take a guess: "^func (" | |
3869 */ | |
3870 found = 2; | |
3871 (void)test_for_static(&tagp); | |
3872 cc = *tagp.tagname_end; | |
3873 *tagp.tagname_end = NUL; | |
3874 sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); | |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3875 if (!do_search(NULL, '/', '/', pbuf, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3876 search_options, NULL)) |
7 | 3877 { |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3878 // Guess again: "^char * \<func (" |
7 | 3879 sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(", |
3880 tagp.tagname); | |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19241
diff
changeset
|
3881 if (!do_search(NULL, '/', '/', pbuf, (long)1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18315
diff
changeset
|
3882 search_options, NULL)) |
7 | 3883 found = 0; |
3884 } | |
3885 *tagp.tagname_end = cc; | |
3886 } | |
3887 if (found == 0) | |
3888 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3889 emsg(_(e_canot_find_tag_pattern)); |
7 | 3890 curwin->w_cursor.lnum = save_lnum; |
3891 } | |
3892 else | |
3893 { | |
3894 /* | |
3895 * Only give a message when really guessed, not when 'ic' | |
3896 * is set and match found while ignoring case. | |
3897 */ | |
3898 if (found == 2 || !save_p_ic) | |
3899 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
3900 msg(_(e_couldnt_find_tag_just_guessing)); |
7 | 3901 if (!msg_scrolled && msg_silent == 0) |
3902 { | |
3903 out_flush(); | |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18640
diff
changeset
|
3904 ui_delay(1010L, TRUE); |
7 | 3905 } |
3906 } | |
3907 retval = OK; | |
3908 } | |
3909 } | |
3910 p_ws = save_p_ws; | |
3911 p_ic = save_p_ic; | |
3912 p_scs = save_p_scs; | |
3913 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3914 // A search command may have positioned the cursor beyond the end |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3915 // of the line. May need to correct that here. |
7 | 3916 check_cursor(); |
3917 } | |
3918 else | |
3919 { | |
25262
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3920 int save_secure = secure; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3921 |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3922 // Setup the sandbox for executing the command from the tags file. |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3923 secure = 1; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3924 #ifdef HAVE_SANDBOX |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3925 ++sandbox; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3926 #endif |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3927 curwin->w_cursor.lnum = 1; // start command in line 1 |
7 | 3928 do_cmdline_cmd(pbuf); |
3929 retval = OK; | |
25262
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3930 |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3931 // When the command has done something that is not allowed make |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3932 // sure the error message can be seen. |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3933 if (secure == 2) |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3934 wait_return(TRUE); |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3935 secure = save_secure; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3936 #ifdef HAVE_SANDBOX |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3937 --sandbox; |
e9065d299e9b
patch 8.2.3167: get E12 in a job callback when searching for tags
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3938 #endif |
7 | 3939 } |
3940 | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
3941 magic_overruled = save_magic_overruled; |
7 | 3942 #ifdef FEAT_SEARCH_EXTRA |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3943 // restore no_hlsearch when keeping the old search pattern |
7 | 3944 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
|
3945 set_no_hlsearch(save_no_hlsearch); |
7 | 3946 #endif |
3947 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3948 // 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
|
3949 if (getfile_result == GETFILE_OPEN_OTHER) |
7 | 3950 retval = OK; |
3951 | |
3952 if (retval == OK) | |
3953 { | |
3954 /* | |
3955 * For a help buffer: Put the cursor line at the top of the window, | |
3956 * the help subject will be below it. | |
3957 */ | |
3958 if (curbuf->b_help) | |
3959 set_topline(curwin, curwin->w_cursor.lnum); | |
3960 #ifdef FEAT_FOLDING | |
3961 if ((fdo_flags & FDO_TAG) && old_KeyTyped) | |
3962 foldOpenCursor(); | |
3963 #endif | |
3964 } | |
3965 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3966 #if defined(FEAT_QUICKFIX) |
2713 | 3967 if (g_do_tagpreview != 0 |
3968 && curwin != curwin_save && win_valid(curwin_save)) | |
7 | 3969 { |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3970 // Return cursor to where we were |
7 | 3971 validate_cursor(); |
3972 redraw_later(VALID); | |
3973 win_enter(curwin_save, TRUE); | |
3974 } | |
3975 #endif | |
3976 | |
3977 --RedrawingDisabled; | |
3978 } | |
3979 else | |
3980 { | |
3981 --RedrawingDisabled; | |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3982 got_int = FALSE; // don't want entering window to fail |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3983 |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3984 if (postponed_split) // close the window |
7 | 3985 { |
3986 win_close(curwin, FALSE); | |
3987 postponed_split = 0; | |
3988 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
3989 #if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP) |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3990 else if (WIN_IS_POPUP(curwin)) |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3991 { |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3992 win_T *wp = curwin; |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3993 |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3994 if (win_valid(curwin_save)) |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3995 win_enter(curwin_save, TRUE); |
20384
42ab4d40e78f
patch 8.2.0747: cannot forcefully close all popups
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
3996 popup_close(wp->w_id, FALSE); |
17632
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3997 } |
5278e5a2a4e3
patch 8.1.1813: ATTENTION prompt for a preview popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3998 #endif |
7 | 3999 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
4000 #if defined(FEAT_QUICKFIX) && defined(FEAT_PROP_POPUP) |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
4001 if (WIN_IS_POPUP(curwin)) |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
4002 // something went wrong, still in popup, but it can't have focus |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
4003 win_enter(firstwin, TRUE); |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17632
diff
changeset
|
4004 #endif |
7 | 4005 |
4006 erret: | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4007 #if defined(FEAT_QUICKFIX) |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4008 g_do_tagpreview = 0; // For next time |
7 | 4009 #endif |
12680
429bf1b9292f
patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4010 vim_free(lbuf); |
7 | 4011 vim_free(pbuf); |
4012 vim_free(tofree_fname); | |
4013 vim_free(full_fname); | |
4014 | |
4015 return retval; | |
4016 } | |
4017 | |
4018 /* | |
4019 * If "expand" is TRUE, expand wildcards in fname. | |
4020 * If 'tagrelative' option set, change fname (name of file containing tag) | |
4021 * according to tag_fname (name of tag file containing fname). | |
4022 * Returns a pointer to allocated memory (or NULL when out of memory). | |
4023 */ | |
4024 static char_u * | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4025 expand_tag_fname(char_u *fname, char_u *tag_fname, int expand) |
7 | 4026 { |
4027 char_u *p; | |
4028 char_u *retval; | |
4029 char_u *expanded_fname = NULL; | |
4030 expand_T xpc; | |
4031 | |
4032 /* | |
4033 * Expand file name (for environment variables) when needed. | |
4034 */ | |
4035 if (expand && mch_has_wildcard(fname)) | |
4036 { | |
4037 ExpandInit(&xpc); | |
4038 xpc.xp_context = EXPAND_FILES; | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
4039 expanded_fname = ExpandOne(&xpc, fname, NULL, |
7 | 4040 WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); |
4041 if (expanded_fname != NULL) | |
4042 fname = expanded_fname; | |
4043 } | |
4044 | |
4045 if ((p_tr || curbuf->b_help) | |
4046 && !vim_isAbsName(fname) | |
4047 && (p = gettail(tag_fname)) != tag_fname) | |
4048 { | |
4049 retval = alloc(MAXPATHL); | |
4050 if (retval != NULL) | |
4051 { | |
4052 STRCPY(retval, tag_fname); | |
418 | 4053 vim_strncpy(retval + (p - tag_fname), fname, |
4054 MAXPATHL - (p - tag_fname) - 1); | |
7 | 4055 /* |
4056 * Translate names like "src/a/../b/file.c" into "src/b/file.c". | |
4057 */ | |
4058 simplify_filename(retval); | |
4059 } | |
4060 } | |
4061 else | |
4062 retval = vim_strsave(fname); | |
4063 | |
4064 vim_free(expanded_fname); | |
4065 | |
4066 return retval; | |
4067 } | |
4068 | |
4069 /* | |
4070 * Check if we have a tag for the buffer with name "buf_ffname". | |
4071 * This is a bit slow, because of the full path compare in fullpathcmp(). | |
4072 * Return TRUE if tag for file "fname" if tag file "tag_fname" is for current | |
4073 * file. | |
4074 */ | |
4075 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4076 test_for_current( |
7 | 4077 #ifdef FEAT_EMACS_TAGS |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4078 int is_etag, |
7 | 4079 #endif |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4080 char_u *fname, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4081 char_u *fname_end, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4082 char_u *tag_fname, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4083 char_u *buf_ffname) |
7 | 4084 { |
4085 int c; | |
4086 int retval = FALSE; | |
4087 char_u *fullname; | |
4088 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4089 if (buf_ffname != NULL) // if the buffer has a name |
7 | 4090 { |
4091 #ifdef FEAT_EMACS_TAGS | |
4092 if (is_etag) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4093 c = 0; // to shut up GCC |
7 | 4094 else |
4095 #endif | |
4096 { | |
4097 c = *fname_end; | |
4098 *fname_end = NUL; | |
4099 } | |
4100 fullname = expand_tag_fname(fname, tag_fname, TRUE); | |
4101 if (fullname != NULL) | |
4102 { | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16511
diff
changeset
|
4103 retval = (fullpathcmp(fullname, buf_ffname, TRUE, TRUE) & FPC_SAME); |
7 | 4104 vim_free(fullname); |
4105 } | |
4106 #ifdef FEAT_EMACS_TAGS | |
4107 if (!is_etag) | |
4108 #endif | |
4109 *fname_end = c; | |
4110 } | |
4111 | |
4112 return retval; | |
4113 } | |
4114 | |
4115 /* | |
4116 * Find the end of the tagaddress. | |
4117 * Return OK if ";\"" is following, FAIL otherwise. | |
4118 */ | |
4119 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4120 find_extra(char_u **pp) |
7 | 4121 { |
4122 char_u *str = *pp; | |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
19033
diff
changeset
|
4123 char_u first_char = **pp; |
7 | 4124 |
15808
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4125 // Repeat for addresses separated with ';' |
7 | 4126 for (;;) |
4127 { | |
4128 if (VIM_ISDIGIT(*str)) | |
24665
661d15592d3c
patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents:
24594
diff
changeset
|
4129 str = skipdigits(str + 1); |
7 | 4130 else if (*str == '/' || *str == '?') |
4131 { | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
4132 str = skip_regexp(str + 1, *str, FALSE); |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
19033
diff
changeset
|
4133 if (*str != first_char) |
7 | 4134 str = NULL; |
4135 else | |
4136 ++str; | |
4137 } | |
4138 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
|
4139 { |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4140 // 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
|
4141 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
|
4142 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
|
4143 { |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4144 ++str; |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4145 break; |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4146 } |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4147 |
37d31fc37a5a
patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4148 } |
7 | 4149 if (str == NULL || *str != ';' |
4150 || !(VIM_ISDIGIT(str[1]) || str[1] == '/' || str[1] == '?')) | |
4151 break; | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4152 ++str; // skip ';' |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
19033
diff
changeset
|
4153 first_char = *str; |
7 | 4154 } |
4155 | |
4156 if (str != NULL && STRNCMP(str, ";\"", 2) == 0) | |
4157 { | |
4158 *pp = str; | |
4159 return OK; | |
4160 } | |
4161 return FAIL; | |
4162 } | |
4163 | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4164 /* |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4165 * Free a single entry in a tag stack |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4166 */ |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4167 static void |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4168 tagstack_clear_entry(taggy_T *item) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4169 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4170 VIM_CLEAR(item->tagname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4171 VIM_CLEAR(item->user_data); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4172 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4173 |
7 | 4174 int |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4175 expand_tags( |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4176 int tagnames, // expand tag names |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4177 char_u *pat, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4178 int *num_file, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4179 char_u ***file) |
7 | 4180 { |
4181 int i; | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4182 int extra_flag; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4183 char_u *name_buf; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4184 size_t name_buf_size = 100; |
7 | 4185 tagptrs_T t_p; |
4186 int ret; | |
4187 | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4188 name_buf = alloc(name_buf_size); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4189 if (name_buf == NULL) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4190 return FAIL; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4191 |
7 | 4192 if (tagnames) |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4193 extra_flag = TAG_NAMES; |
7 | 4194 else |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4195 extra_flag = 0; |
7 | 4196 if (pat[0] == '/') |
4197 ret = find_tags(pat + 1, num_file, file, | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4198 TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC, |
7 | 4199 TAG_MANY, curbuf->b_ffname); |
4200 else | |
4201 ret = find_tags(pat, num_file, file, | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4202 TAG_REGEXP | extra_flag | TAG_VERBOSE | TAG_NO_TAGFUNC | TAG_NOIC, |
7 | 4203 TAG_MANY, curbuf->b_ffname); |
4204 if (ret == OK && !tagnames) | |
4205 { | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4206 // Reorganize the tags for display and matching as strings of: |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4207 // "<tagname>\0<kind>\0<filename>\0" |
7 | 4208 for (i = 0; i < *num_file; i++) |
4209 { | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4210 size_t len; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4211 |
7 | 4212 parse_match((*file)[i], &t_p); |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4213 len = t_p.tagname_end - t_p.tagname; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4214 if (len > name_buf_size - 3) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4215 { |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4216 char_u *buf; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4217 |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4218 name_buf_size = len + 3; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4219 buf = vim_realloc(name_buf, name_buf_size); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4220 if (buf == NULL) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4221 { |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4222 vim_free(name_buf); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4223 return FAIL; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4224 } |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4225 name_buf = buf; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4226 } |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4227 |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4228 mch_memmove(name_buf, t_p.tagname, len); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4229 name_buf[len++] = 0; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4230 name_buf[len++] = (t_p.tagkind != NULL && *t_p.tagkind) |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4231 ? *t_p.tagkind : 'f'; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4232 name_buf[len++] = 0; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4233 mch_memmove((*file)[i] + len, t_p.fname, |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4234 t_p.fname_end - t_p.fname); |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4235 (*file)[i][len + (t_p.fname_end - t_p.fname)] = 0; |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4236 mch_memmove((*file)[i], name_buf, len); |
7 | 4237 } |
4238 } | |
25652
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4239 |
ca61340ac1b9
patch 8.2.3362: buffer overflow when completing long tag name
Bram Moolenaar <Bram@vim.org>
parents:
25587
diff
changeset
|
4240 vim_free(name_buf); |
7 | 4241 return ret; |
4242 } | |
179 | 4243 |
4244 #if defined(FEAT_EVAL) || defined(PROTO) | |
4245 /* | |
2185 | 4246 * Add a tag field to the dictionary "dict". |
4247 * Return OK or FAIL. | |
179 | 4248 */ |
4249 static int | |
7835
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4250 add_tag_field( |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4251 dict_T *dict, |
4d7ce6c03fda
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4252 char *field_name, |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4253 char_u *start, // start of the value |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4254 char_u *end) // after the value; can be NULL |
179 | 4255 { |
2770 | 4256 char_u *buf; |
188 | 4257 int len = 0; |
2770 | 4258 int retval; |
179 | 4259 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4260 // check that the field name doesn't exist yet |
2185 | 4261 if (dict_find(dict, (char_u *)field_name, -1) != NULL) |
4262 { | |
4263 if (p_verbose > 0) | |
4264 { | |
4265 verbose_enter(); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
4266 smsg(_("Duplicate field name: %s"), field_name); |
2185 | 4267 verbose_leave(); |
4268 } | |
4269 return FAIL; | |
4270 } | |
2770 | 4271 buf = alloc(MAXPATHL); |
4272 if (buf == NULL) | |
4273 return FAIL; | |
188 | 4274 if (start != NULL) |
4275 { | |
211 | 4276 if (end == NULL) |
4277 { | |
4278 end = start + STRLEN(start); | |
4279 while (end > start && (end[-1] == '\r' || end[-1] == '\n')) | |
4280 --end; | |
4281 } | |
835 | 4282 len = (int)(end - start); |
2770 | 4283 if (len > MAXPATHL - 1) |
4284 len = MAXPATHL - 1; | |
418 | 4285 vim_strncpy(buf, start, len); |
188 | 4286 } |
179 | 4287 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
|
4288 retval = dict_add_string(dict, field_name, buf); |
2770 | 4289 vim_free(buf); |
4290 return retval; | |
179 | 4291 } |
4292 | |
4293 /* | |
11225
d3415ec1cdaf
patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
4294 * 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
|
4295 * as a dictionary. Use "buf_fname" for priority, unless NULL. |
179 | 4296 */ |
4297 int | |
11225
d3415ec1cdaf
patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
4298 get_tags(list_T *list, char_u *pat, char_u *buf_fname) |
179 | 4299 { |
4300 int num_matches, i, ret; | |
4301 char_u **matches, *p; | |
970 | 4302 char_u *full_fname; |
179 | 4303 dict_T *dict; |
4304 tagptrs_T tp; | |
4305 long is_static; | |
4306 | |
4307 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
|
4308 TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname); |
179 | 4309 if (ret == OK && num_matches > 0) |
4310 { | |
4311 for (i = 0; i < num_matches; ++i) | |
4312 { | |
188 | 4313 parse_match(matches[i], &tp); |
4314 is_static = test_for_static(&tp); | |
4315 | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4316 // Skip pseudo-tag lines. |
188 | 4317 if (STRNCMP(tp.tagname, "!_TAG_", 6) == 0) |
19237
1a3ebc75cf39
patch 8.2.0177: memory leak in get_tags()
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4318 { |
1a3ebc75cf39
patch 8.2.0177: memory leak in get_tags()
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4319 vim_free(matches[i]); |
188 | 4320 continue; |
19237
1a3ebc75cf39
patch 8.2.0177: memory leak in get_tags()
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4321 } |
188 | 4322 |
179 | 4323 if ((dict = dict_alloc()) == NULL) |
4324 ret = FAIL; | |
4325 if (list_append_dict(list, dict) == FAIL) | |
4326 ret = FAIL; | |
4327 | |
970 | 4328 full_fname = tag_full_fname(&tp); |
179 | 4329 if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL |
970 | 4330 || add_tag_field(dict, "filename", full_fname, |
4331 NULL) == FAIL | |
179 | 4332 || add_tag_field(dict, "cmd", tp.command, |
4333 tp.command_end) == FAIL | |
4334 || add_tag_field(dict, "kind", tp.tagkind, | |
4335 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
|
4336 || dict_add_number(dict, "static", is_static) == FAIL) |
179 | 4337 ret = FAIL; |
4338 | |
970 | 4339 vim_free(full_fname); |
4340 | |
179 | 4341 if (tp.command_end != NULL) |
4342 { | |
4343 for (p = tp.command_end + 3; | |
19617
5ce724c60c4c
patch 8.2.0365: tag kind can't be a multi-byte character
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
4344 *p != NUL && *p != '\n' && *p != '\r'; MB_PTR_ADV(p)) |
179 | 4345 { |
4346 if (p == tp.tagkind || (p + 5 == tp.tagkind | |
4347 && STRNCMP(p, "kind:", 5) == 0)) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4348 // skip "kind:<kind>" and "<kind>" |
179 | 4349 p = tp.tagkind_end - 1; |
4350 else if (STRNCMP(p, "file:", 5) == 0) | |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4351 // skip "file:" (static tag) |
179 | 4352 p += 4; |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
4353 else if (!VIM_ISWHITE(*p)) |
179 | 4354 { |
4355 char_u *s, *n; | |
188 | 4356 int len; |
179 | 4357 |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4358 // Add extra field as a dict entry. Fields are |
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4359 // separated by Tabs. |
179 | 4360 n = p; |
799 | 4361 while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') |
179 | 4362 ++p; |
835 | 4363 len = (int)(p - n); |
188 | 4364 if (*p == ':' && len > 0) |
4365 { | |
4366 s = ++p; | |
836 | 4367 while (*p != NUL && *p >= ' ') |
188 | 4368 ++p; |
4369 n[len] = NUL; | |
4370 if (add_tag_field(dict, (char *)n, s, p) == FAIL) | |
4371 ret = FAIL; | |
4372 n[len] = ':'; | |
4373 } | |
836 | 4374 else |
18814
7e7ec935e7c8
patch 8.1.2395: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4375 // Skip field without colon. |
836 | 4376 while (*p != NUL && *p >= ' ') |
4377 ++p; | |
1674 | 4378 if (*p == NUL) |
4379 break; | |
179 | 4380 } |
4381 } | |
4382 } | |
4383 | |
4384 vim_free(matches[i]); | |
4385 } | |
4386 vim_free(matches); | |
4387 } | |
4388 return ret; | |
4389 } | |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4390 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4391 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4392 * 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
|
4393 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4394 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4395 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
|
4396 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4397 list_T *pos; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4398 fmark_T *fmark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4399 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4400 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
|
4401 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
|
4402 dict_add_number(retdict, "bufnr", tag->cur_fnum); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4403 if (tag->user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4404 dict_add_string(retdict, "user_data", tag->user_data); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4405 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4406 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
|
4407 return; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4408 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
|
4409 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4410 fmark = &tag->fmark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4411 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
|
4412 (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
|
4413 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
|
4414 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
|
4415 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
|
4416 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
|
4417 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4418 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4419 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4420 * 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
|
4421 * 'retdict'. |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4422 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4423 void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4424 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
|
4425 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4426 list_T *l; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4427 int i; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4428 dict_T *d; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4429 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4430 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
|
4431 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
|
4432 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
|
4433 if (l == NULL) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4434 return; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4435 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
|
4436 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4437 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
|
4438 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4439 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
|
4440 return; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4441 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
|
4442 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4443 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
|
4444 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4445 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4446 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4447 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4448 * 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
|
4449 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4450 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4451 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
|
4452 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4453 int i; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4454 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4455 // 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
|
4456 for (i = 0; i < wp->w_tagstacklen; ++i) |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4457 tagstack_clear_entry(&wp->w_tagstack[i]); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4458 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
|
4459 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
|
4460 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4461 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4462 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4463 * Remove the oldest entry from the tag stack and shift the rest of |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19055
diff
changeset
|
4464 * the entries to free up the top of the stack. |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4465 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4466 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4467 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
|
4468 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4469 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
|
4470 int i; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4471 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4472 tagstack_clear_entry(&tagstack[0]); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4473 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
|
4474 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
|
4475 wp->w_tagstacklen--; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4476 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4477 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4478 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4479 * 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
|
4480 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4481 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4482 tagstack_push_item( |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4483 win_T *wp, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4484 char_u *tagname, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4485 int cur_fnum, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4486 int cur_match, |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4487 pos_T mark, |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4488 int fnum, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4489 char_u *user_data) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4490 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4491 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
|
4492 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
|
4493 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4494 // 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
|
4495 if (idx >= TAGSTACKSIZE) |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4496 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4497 tagstack_shift(wp); |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4498 idx = TAGSTACKSIZE - 1; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4499 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4500 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4501 wp->w_tagstacklen++; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4502 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
|
4503 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
|
4504 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
|
4505 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
|
4506 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
|
4507 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
|
4508 tagstack[idx].fmark.fnum = fnum; |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4509 tagstack[idx].user_data = user_data; |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4510 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4511 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4512 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4513 * 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
|
4514 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4515 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4516 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
|
4517 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4518 listitem_T *li; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4519 dictitem_T *di; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4520 dict_T *itemdict; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4521 char_u *tagname; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4522 pos_T mark; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4523 int fnum; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4524 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4525 // Add one entry at a time to the tag stack |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19617
diff
changeset
|
4526 FOR_ALL_LIST_ITEMS(l, li) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4527 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4528 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
|
4529 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
|
4530 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
|
4531 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4532 // 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
|
4533 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
|
4534 continue; |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
4535 if (list2fpos(&di->di_tv, &mark, &fnum, NULL, FALSE) != OK) |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4536 continue; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4537 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
|
4538 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
|
4539 continue; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4540 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4541 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
|
4542 mark.col--; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4543 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
|
4544 (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
|
4545 (int)dict_get_number(itemdict, (char_u *)"matchnr") - 1, |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4546 mark, fnum, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4547 dict_get_string(itemdict, (char_u *)"user_data", TRUE)); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4548 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4549 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4550 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4551 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4552 * 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
|
4553 * 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
|
4554 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4555 static void |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4556 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
|
4557 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4558 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
|
4559 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
|
4560 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
|
4561 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
|
4562 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
|
4563 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4564 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4565 /* |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4566 * Set the tag stack entries of the specified window. |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4567 * 'action' is set to one of: |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4568 * 'a' for append |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4569 * 'r' for replace |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4570 * 't' for truncate |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4571 */ |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4572 int |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4573 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
|
4574 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4575 dictitem_T *di; |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4576 list_T *l = NULL; |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4577 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4578 #ifdef FEAT_EVAL |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4579 // not allowed to alter the tag stack entries from inside tagfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4580 if (tfu_in_use) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4581 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
4582 emsg(_(e_cannot_modify_tag_stack_within_tagfunc)); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4583 return FAIL; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4584 } |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4585 #endif |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16378
diff
changeset
|
4586 |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4587 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
|
4588 { |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4589 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
|
4590 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
4591 emsg(_(e_list_required)); |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4592 return FAIL; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4593 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4594 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
|
4595 } |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4596 |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4597 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
|
4598 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
|
4599 |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4600 if (action == 't') // truncate the stack |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4601 { |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4602 taggy_T *tagstack = wp->w_tagstack; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4603 int tagstackidx = wp->w_tagstackidx; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4604 int tagstacklen = wp->w_tagstacklen; |
19241
c53dbbf3229b
patch 8.2.0179: still a few places where range() does not work
Bram Moolenaar <Bram@vim.org>
parents:
19237
diff
changeset
|
4605 |
19033
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4606 // delete all the tag stack entries above the current entry |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4607 while (tagstackidx < tagstacklen) |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4608 tagstack_clear_entry(&tagstack[--tagstacklen]); |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4609 wp->w_tagstacklen = tagstacklen; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4610 } |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4611 |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4612 if (l != NULL) |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4613 { |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4614 if (action == 'r') // replace the stack |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4615 tagstack_clear(wp); |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4616 |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4617 tagstack_push_items(wp, l); |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4618 // set the current index after the last entry |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4619 wp->w_tagstackidx = wp->w_tagstacklen; |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4620 } |
f0312cf3c792
patch 8.2.0077: settagstack() cannot truncate at current index
Bram Moolenaar <Bram@vim.org>
parents:
18814
diff
changeset
|
4621 |
15016
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4622 return OK; |
c338c91086b9
patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
4623 } |
179 | 4624 #endif |