Mercurial > vim
annotate src/quickfix.c @ 12780:26581133b31e
Added tag v8.0.1267 for changeset 73eb8a2d7f04d8461a06e219a7fe4222391d82e8
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 04 Nov 2017 22:45:07 +0100 |
parents | c7164578e508 |
children | 888441e8fbb0 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9982
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 * quickfix.c: functions for quickfix mode, using a file with error messages | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 #if defined(FEAT_QUICKFIX) || defined(PROTO) | |
17 | |
18 struct dir_stack_T | |
19 { | |
20 struct dir_stack_T *next; | |
21 char_u *dirname; | |
22 }; | |
23 | |
24 /* | |
230 | 25 * For each error the next struct is allocated and linked in a list. |
7 | 26 */ |
230 | 27 typedef struct qfline_S qfline_T; |
28 struct qfline_S | |
7 | 29 { |
230 | 30 qfline_T *qf_next; /* pointer to next error in the list */ |
31 qfline_T *qf_prev; /* pointer to previous error in the list */ | |
32 linenr_T qf_lnum; /* line number where the error occurred */ | |
33 int qf_fnum; /* file number for the line */ | |
34 int qf_col; /* column where the error occurred */ | |
35 int qf_nr; /* error number */ | |
36 char_u *qf_pattern; /* search pattern for the error */ | |
37 char_u *qf_text; /* description of the error */ | |
38 char_u qf_viscol; /* set to TRUE if qf_col is screen column */ | |
39 char_u qf_cleared; /* set to TRUE if line has been deleted */ | |
40 char_u qf_type; /* type of the error (mostly 'E'); 1 for | |
7 | 41 :helpgrep */ |
230 | 42 char_u qf_valid; /* valid error message detected */ |
7 | 43 }; |
44 | |
45 /* | |
46 * There is a stack of error lists. | |
47 */ | |
48 #define LISTCOUNT 10 | |
49 | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
50 /* |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
51 * Quickfix/Location list definition |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
52 * Contains a list of entries (qfline_T). qf_start points to the first entry |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
53 * and qf_last points to the last entry. qf_count contains the list size. |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
54 * |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
55 * Usually the list contains one or more entries. But an empty list can be |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
56 * created using setqflist()/setloclist() with a title and/or user context |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
57 * information and entries can be added later using setqflist()/setloclist(). |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
58 */ |
644 | 59 typedef struct qf_list_S |
7 | 60 { |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
61 int_u qf_id; /* Unique identifier for this list */ |
230 | 62 qfline_T *qf_start; /* pointer to the first error */ |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
63 qfline_T *qf_last; /* pointer to the last error */ |
230 | 64 qfline_T *qf_ptr; /* pointer to the current error */ |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
65 int qf_count; /* number of errors (0 means empty list) */ |
230 | 66 int qf_index; /* current index in the error list */ |
67 int qf_nonevalid; /* TRUE if not a single valid entry found */ | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
68 char_u *qf_title; /* title derived from the command that created |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
69 * the error list or set by setqflist */ |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
70 typval_T *qf_ctx; /* context set by setqflist/setloclist */ |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
71 |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
72 struct dir_stack_T *qf_dir_stack; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
73 char_u *qf_directory; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
74 struct dir_stack_T *qf_file_stack; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
75 char_u *qf_currfile; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
76 int qf_multiline; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
77 int qf_multiignore; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
78 int qf_multiscan; |
644 | 79 } qf_list_T; |
80 | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
81 /* |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
82 * Quickfix/Location list stack definition |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
83 * Contains a list of quickfix/location lists (qf_list_T) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
84 */ |
644 | 85 struct qf_info_S |
86 { | |
87 /* | |
88 * Count of references to this list. Used only for location lists. | |
89 * When a location list window reference this list, qf_refcount | |
90 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount | |
91 * reaches 0, the list is freed. | |
92 */ | |
93 int qf_refcount; | |
94 int qf_listcount; /* current number of lists */ | |
95 int qf_curlist; /* current error list */ | |
96 qf_list_T qf_lists[LISTCOUNT]; | |
97 }; | |
98 | |
99 static qf_info_T ql_info; /* global quickfix list */ | |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
100 static int_u last_qf_id = 0; /* Last used quickfix list id */ |
7 | 101 |
230 | 102 #define FMT_PATTERNS 10 /* maximum number of % recognized */ |
7 | 103 |
104 /* | |
105 * Structure used to hold the info of one part of 'errorformat' | |
106 */ | |
789 | 107 typedef struct efm_S efm_T; |
108 struct efm_S | |
7 | 109 { |
110 regprog_T *prog; /* pre-formatted part of 'errorformat' */ | |
789 | 111 efm_T *next; /* pointer to next (NULL if last) */ |
7 | 112 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */ |
113 char_u prefix; /* prefix of this format line: */ | |
114 /* 'D' enter directory */ | |
115 /* 'X' leave directory */ | |
116 /* 'A' start of multi-line message */ | |
117 /* 'E' error message */ | |
118 /* 'W' warning message */ | |
119 /* 'I' informational message */ | |
120 /* 'C' continuation line */ | |
121 /* 'Z' end of multi-line message */ | |
122 /* 'G' general, unspecific message */ | |
123 /* 'P' push file (partial) message */ | |
124 /* 'Q' pop/quit file (partial) message */ | |
125 /* 'O' overread (partial) message */ | |
126 char_u flags; /* additional flags given in prefix */ | |
127 /* '-' do not include this line */ | |
625 | 128 /* '+' include whole line in message */ |
789 | 129 int conthere; /* %> used */ |
7 | 130 }; |
131 | |
10367
4e4e116e3689
commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
132 static efm_T *fmt_start = NULL; /* cached across qf_parse_line() calls */ |
4e4e116e3689
commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
133 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
134 static int qf_init_ext(qf_info_T *qi, int qf_idx, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title, char_u *enc); |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
135 static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
136 static void qf_new_list(qf_info_T *qi, char_u *qf_title); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
137 static void ll_free_all(qf_info_T **pqi); |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
138 static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
139 static qf_info_T *ll_new_list(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
140 static void qf_free(qf_info_T *qi, int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
141 static char_u *qf_types(int, int); |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
142 static int qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *, char_u *); |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
143 static char_u *qf_push_dir(char_u *, struct dir_stack_T **, int is_file_stack); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
144 static char_u *qf_pop_dir(struct dir_stack_T **); |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
145 static char_u *qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
146 static void qf_fmt_text(char_u *text, char_u *buf, int bufsize); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
147 static void qf_clean_dir_stack(struct dir_stack_T **); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
148 static int qf_win_pos_update(qf_info_T *qi, int old_qf_index); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
149 static int is_qf_win(win_T *win, qf_info_T *qi); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
150 static win_T *qf_find_win(qf_info_T *qi); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
151 static buf_T *qf_find_buf(qf_info_T *qi); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
152 static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
153 static void qf_set_title_var(qf_info_T *qi); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
154 static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
155 static char_u *get_mef_name(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
156 static void restore_start_dir(char_u *dirname_start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
157 static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *resulting_dir); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
158 static void wipe_dummy_buffer(buf_T *buf, char_u *dirname_start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
159 static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
160 static qf_info_T *ll_get_or_alloc_list(win_T *); |
7 | 161 |
644 | 162 /* Quickfix window check helper macro */ |
163 #define IS_QF_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL) | |
164 /* Location list window check helper macro */ | |
165 #define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL) | |
166 /* | |
167 * Return location list for window 'wp' | |
168 * For location list window, return the referenced location list | |
169 */ | |
170 #define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist) | |
171 | |
7 | 172 /* |
11443
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
173 * Looking up a buffer can be slow if there are many. Remember the last one |
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
174 * to make this a lot faster if there are multiple matches in the same file. |
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
175 */ |
11447
698ee9d4fe9f
patch 8.0.0607: after :bwipe + :new bufref might still be valid
Christian Brabandt <cb@256bit.org>
parents:
11445
diff
changeset
|
176 static char_u *qf_last_bufname = NULL; |
698ee9d4fe9f
patch 8.0.0607: after :bwipe + :new bufref might still be valid
Christian Brabandt <cb@256bit.org>
parents:
11445
diff
changeset
|
177 static bufref_T qf_last_bufref = {NULL, 0, 0}; |
11443
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
178 |
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
179 /* |
41 | 180 * Read the errorfile "efile" into memory, line by line, building the error |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
181 * list. Set the error list's title to qf_title. |
7 | 182 * Return -1 for error, number of errors for success. |
183 */ | |
184 int | |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
185 qf_init(win_T *wp, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
186 char_u *efile, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
187 char_u *errorformat, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
188 int newlist, /* TRUE: start a new error list */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
189 char_u *qf_title, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
190 char_u *enc) |
7 | 191 { |
644 | 192 qf_info_T *qi = &ql_info; |
193 | |
194 if (wp != NULL) | |
665 | 195 { |
196 qi = ll_get_or_alloc_list(wp); | |
197 if (qi == NULL) | |
198 return FAIL; | |
199 } | |
644 | 200 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
201 return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat, |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
202 newlist, (linenr_T)0, (linenr_T)0, qf_title, enc); |
41 | 203 } |
204 | |
205 /* | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
206 * Maximum number of bytes allowed per line while reading a errorfile. |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
207 */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
208 #define LINE_MAXLEN 4096 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
209 |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
210 static struct fmtpattern |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
211 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
212 char_u convchar; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
213 char *pattern; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
214 } fmt_pat[FMT_PATTERNS] = |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
215 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
216 {'f', ".\\+"}, /* only used when at end */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
217 {'n', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
218 {'l', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
219 {'c', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
220 {'t', "."}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
221 {'m', ".\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
222 {'r', ".*"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
223 {'p', "[- .]*"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
224 {'v', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
225 {'s', ".\\+"} |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
226 }; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
227 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
228 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
229 * Converts a 'errorformat' string to regular expression pattern |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
230 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
231 static int |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
232 efm_to_regpat( |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
233 char_u *efm, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
234 int len, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
235 efm_T *fmt_ptr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
236 char_u *regpat, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
237 char_u *errmsg) |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
238 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
239 char_u *ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
240 char_u *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
241 char_u *srcptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
242 int round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
243 int idx = 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
244 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
245 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
246 * Build regexp pattern from current 'errorformat' option |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
247 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
248 ptr = regpat; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
249 *ptr++ = '^'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
250 round = 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
251 for (efmp = efm; efmp < efm + len; ++efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
252 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
253 if (*efmp == '%') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
254 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
255 ++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
256 for (idx = 0; idx < FMT_PATTERNS; ++idx) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
257 if (fmt_pat[idx].convchar == *efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
258 break; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
259 if (idx < FMT_PATTERNS) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
260 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
261 if (fmt_ptr->addr[idx]) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
262 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
263 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
264 _("E372: Too many %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
265 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
266 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
267 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
268 if ((idx |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
269 && idx < 6 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
270 && vim_strchr((char_u *)"DXOPQ", |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
271 fmt_ptr->prefix) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
272 || (idx == 6 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
273 && vim_strchr((char_u *)"OPQ", |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
274 fmt_ptr->prefix) == NULL)) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
275 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
276 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
277 _("E373: Unexpected %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
278 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
279 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
280 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
281 fmt_ptr->addr[idx] = (char_u)++round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
282 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
283 *ptr++ = '('; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
284 #ifdef BACKSLASH_IN_FILENAME |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
285 if (*efmp == 'f') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
286 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
287 /* Also match "c:" in the file name, even when |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
288 * checking for a colon next: "%f:". |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
289 * "\%(\a:\)\=" */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
290 STRCPY(ptr, "\\%(\\a:\\)\\="); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
291 ptr += 10; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
292 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
293 #endif |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
294 if (*efmp == 'f' && efmp[1] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
295 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
296 if (efmp[1] != '\\' && efmp[1] != '%') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
297 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
298 /* A file name may contain spaces, but this isn't |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
299 * in "\f". For "%f:%l:%m" there may be a ":" in |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
300 * the file name. Use ".\{-1,}x" instead (x is |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
301 * the next character), the requirement that :999: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
302 * follows should work. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
303 STRCPY(ptr, ".\\{-1,}"); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
304 ptr += 7; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
305 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
306 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
307 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
308 /* File name followed by '\\' or '%': include as |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
309 * many file name chars as possible. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
310 STRCPY(ptr, "\\f\\+"); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
311 ptr += 4; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
312 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
313 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
314 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
315 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
316 srcptr = (char_u *)fmt_pat[idx].pattern; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
317 while ((*ptr = *srcptr++) != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
318 ++ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
319 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
320 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
321 *ptr++ = ')'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
322 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
323 else if (*efmp == '*') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
324 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
325 if (*++efmp == '[' || *efmp == '\\') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
326 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
327 if ((*ptr++ = *efmp) == '[') /* %*[^a-z0-9] etc. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
328 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
329 if (efmp[1] == '^') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
330 *ptr++ = *++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
331 if (efmp < efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
332 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
333 *ptr++ = *++efmp; /* could be ']' */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
334 while (efmp < efm + len |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
335 && (*ptr++ = *++efmp) != ']') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
336 /* skip */; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
337 if (efmp == efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
338 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
339 EMSG(_("E374: Missing ] in format string")); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
340 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
341 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
342 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
343 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
344 else if (efmp < efm + len) /* %*\D, %*\s etc. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
345 *ptr++ = *++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
346 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
347 *ptr++ = '+'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
348 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
349 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
350 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
351 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
352 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
353 _("E375: Unsupported %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
354 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
355 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
356 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
357 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
358 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
359 *ptr++ = *efmp; /* regexp magic characters */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
360 else if (*efmp == '#') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
361 *ptr++ = '*'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
362 else if (*efmp == '>') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
363 fmt_ptr->conthere = TRUE; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
364 else if (efmp == efm + 1) /* analyse prefix */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
365 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
366 if (vim_strchr((char_u *)"+-", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
367 fmt_ptr->flags = *efmp++; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
368 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
369 fmt_ptr->prefix = *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
370 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
371 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
372 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
373 _("E376: Invalid %%%c in format string prefix"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
374 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
375 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
376 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
377 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
378 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
379 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
380 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
381 _("E377: Invalid %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
382 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
383 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
384 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
385 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
386 else /* copy normal character */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
387 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
388 if (*efmp == '\\' && efmp + 1 < efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
389 ++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
390 else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
391 *ptr++ = '\\'; /* escape regexp atoms */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
392 if (*efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
393 *ptr++ = *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
394 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
395 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
396 *ptr++ = '$'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
397 *ptr = NUL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
398 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
399 return 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
400 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
401 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
402 static void |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
403 free_efm_list(efm_T **efm_first) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
404 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
405 efm_T *efm_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
406 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
407 for (efm_ptr = *efm_first; efm_ptr != NULL; efm_ptr = *efm_first) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
408 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
409 *efm_first = efm_ptr->next; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
410 vim_regfree(efm_ptr->prog); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
411 vim_free(efm_ptr); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
412 } |
10367
4e4e116e3689
commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
413 fmt_start = NULL; |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
414 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
415 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
416 /* Parse 'errorformat' option */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
417 static efm_T * |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
418 parse_efm_option(char_u *efm) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
419 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
420 char_u *errmsg = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
421 int errmsglen; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
422 efm_T *fmt_ptr = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
423 efm_T *fmt_first = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
424 efm_T *fmt_last = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
425 char_u *fmtstr = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
426 int len; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
427 int i; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
428 int round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
429 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
430 errmsglen = CMDBUFFSIZE + 1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
431 errmsg = alloc_id(errmsglen, aid_qf_errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
432 if (errmsg == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
433 goto parse_efm_end; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
434 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
435 /* |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
436 * Each part of the format string is copied and modified from errorformat |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
437 * to regex prog. Only a few % characters are allowed. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
438 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
439 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
440 /* |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
441 * Get some space to modify the format string into. |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
442 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
443 i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
444 for (round = FMT_PATTERNS; round > 0; ) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
445 i += (int)STRLEN(fmt_pat[--round].pattern); |
12531
c7164578e508
patch 8.0.1144: using wrong #ifdef for computing length
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
446 #ifdef BACKSLASH_IN_FILENAME |
c7164578e508
patch 8.0.1144: using wrong #ifdef for computing length
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
447 i += 12; /* "%f" can become twelve chars longer (see efm_to_regpat) */ |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
448 #else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
449 i += 2; /* "%f" can become two chars longer */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
450 #endif |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
451 if ((fmtstr = alloc(i)) == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
452 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
453 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
454 while (efm[0] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
455 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
456 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
457 * Allocate a new eformat structure and put it at the end of the list |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
458 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
459 fmt_ptr = (efm_T *)alloc_clear((unsigned)sizeof(efm_T)); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
460 if (fmt_ptr == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
461 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
462 if (fmt_first == NULL) /* first one */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
463 fmt_first = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
464 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
465 fmt_last->next = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
466 fmt_last = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
467 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
468 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
469 * Isolate one part in the 'errorformat' option |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
470 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
471 for (len = 0; efm[len] != NUL && efm[len] != ','; ++len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
472 if (efm[len] == '\\' && efm[len + 1] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
473 ++len; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
474 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
475 if (efm_to_regpat(efm, len, fmt_ptr, fmtstr, errmsg) == -1) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
476 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
477 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
478 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
479 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
480 * Advance to next part |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
481 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
482 efm = skip_to_option_part(efm + len); /* skip comma and spaces */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
483 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
484 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
485 if (fmt_first == NULL) /* nothing found */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
486 EMSG(_("E378: 'errorformat' contains no pattern")); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
487 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
488 goto parse_efm_end; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
489 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
490 parse_efm_error: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
491 free_efm_list(&fmt_first); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
492 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
493 parse_efm_end: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
494 vim_free(fmtstr); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
495 vim_free(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
496 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
497 return fmt_first; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
498 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
499 |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
500 enum { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
501 QF_FAIL = 0, |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
502 QF_OK = 1, |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
503 QF_END_OF_INPUT = 2, |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
504 QF_NOMEM = 3, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
505 QF_IGNORE_LINE = 4 |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
506 }; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
507 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
508 typedef struct { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
509 char_u *linebuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
510 int linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
511 char_u *growbuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
512 int growbufsiz; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
513 FILE *fd; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
514 typval_T *tv; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
515 char_u *p_str; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
516 listitem_T *p_li; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
517 buf_T *buf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
518 linenr_T buflnum; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
519 linenr_T lnumlast; |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
520 vimconv_T vc; |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
521 } qfstate_T; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
522 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
523 static char_u * |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
524 qf_grow_linebuf(qfstate_T *state, int newsz) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
525 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
526 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
527 * If the line exceeds LINE_MAXLEN exclude the last |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
528 * byte since it's not a NL character. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
529 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
530 state->linelen = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
531 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
532 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
533 state->growbuf = alloc(state->linelen + 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
534 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
535 return NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
536 state->growbufsiz = state->linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
537 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
538 else if (state->linelen > state->growbufsiz) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
539 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
540 state->growbuf = vim_realloc(state->growbuf, state->linelen + 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
541 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
542 return NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
543 state->growbufsiz = state->linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
544 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
545 return state->growbuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
546 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
547 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
548 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
549 * Get the next string (separated by newline) from state->p_str. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
550 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
551 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
552 qf_get_next_str_line(qfstate_T *state) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
553 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
554 /* Get the next line from the supplied string */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
555 char_u *p_str = state->p_str; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
556 char_u *p; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
557 int len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
558 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
559 if (*p_str == NUL) /* Reached the end of the string */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
560 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
561 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
562 p = vim_strchr(p_str, '\n'); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
563 if (p != NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
564 len = (int)(p - p_str) + 1; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
565 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
566 len = (int)STRLEN(p_str); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
567 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
568 if (len > IOSIZE - 2) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
569 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
570 state->linebuf = qf_grow_linebuf(state, len); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
571 if (state->linebuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
572 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
573 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
574 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
575 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
576 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
577 state->linelen = len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
578 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
579 vim_strncpy(state->linebuf, p_str, state->linelen); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
580 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
581 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
582 * Increment using len in order to discard the rest of the |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
583 * line if it exceeds LINE_MAXLEN. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
584 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
585 p_str += len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
586 state->p_str = p_str; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
587 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
588 return QF_OK; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
589 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
590 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
591 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
592 * Get the next string from state->p_Li. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
593 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
594 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
595 qf_get_next_list_line(qfstate_T *state) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
596 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
597 listitem_T *p_li = state->p_li; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
598 int len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
599 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
600 while (p_li != NULL |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
601 && (p_li->li_tv.v_type != VAR_STRING |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
602 || p_li->li_tv.vval.v_string == NULL)) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
603 p_li = p_li->li_next; /* Skip non-string items */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
604 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
605 if (p_li == NULL) /* End of the list */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
606 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
607 state->p_li = NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
608 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
609 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
610 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
611 len = (int)STRLEN(p_li->li_tv.vval.v_string); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
612 if (len > IOSIZE - 2) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
613 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
614 state->linebuf = qf_grow_linebuf(state, len); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
615 if (state->linebuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
616 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
617 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
618 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
619 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
620 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
621 state->linelen = len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
622 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
623 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
624 vim_strncpy(state->linebuf, p_li->li_tv.vval.v_string, state->linelen); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
625 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
626 state->p_li = p_li->li_next; /* next item */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
627 return QF_OK; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
628 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
629 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
630 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
631 * Get the next string from state->buf. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
632 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
633 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
634 qf_get_next_buf_line(qfstate_T *state) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
635 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
636 char_u *p_buf = NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
637 int len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
638 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
639 /* Get the next line from the supplied buffer */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
640 if (state->buflnum > state->lnumlast) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
641 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
642 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
643 p_buf = ml_get_buf(state->buf, state->buflnum, FALSE); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
644 state->buflnum += 1; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
645 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
646 len = (int)STRLEN(p_buf); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
647 if (len > IOSIZE - 2) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
648 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
649 state->linebuf = qf_grow_linebuf(state, len); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
650 if (state->linebuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
651 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
652 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
653 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
654 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
655 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
656 state->linelen = len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
657 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
658 vim_strncpy(state->linebuf, p_buf, state->linelen); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
659 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
660 return QF_OK; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
661 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
662 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
663 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
664 * Get the next string from file state->fd. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
665 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
666 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
667 qf_get_next_file_line(qfstate_T *state) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
668 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
669 int discard; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
670 int growbuflen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
671 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
672 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
673 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
674 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
675 discard = FALSE; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
676 state->linelen = (int)STRLEN(IObuff); |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
677 if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\n')) |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
678 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
679 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
680 * The current line exceeds IObuff, continue reading using |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
681 * growbuf until EOL or LINE_MAXLEN bytes is read. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
682 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
683 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
684 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
685 state->growbufsiz = 2 * (IOSIZE - 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
686 state->growbuf = alloc(state->growbufsiz); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
687 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
688 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
689 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
690 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
691 /* Copy the read part of the line, excluding null-terminator */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
692 memcpy(state->growbuf, IObuff, IOSIZE - 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
693 growbuflen = state->linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
694 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
695 for (;;) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
696 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
697 if (fgets((char *)state->growbuf + growbuflen, |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
698 state->growbufsiz - growbuflen, state->fd) == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
699 break; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
700 state->linelen = (int)STRLEN(state->growbuf + growbuflen); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
701 growbuflen += state->linelen; |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
702 if ((state->growbuf)[growbuflen - 1] == '\n') |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
703 break; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
704 if (state->growbufsiz == LINE_MAXLEN) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
705 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
706 discard = TRUE; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
707 break; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
708 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
709 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
710 state->growbufsiz = 2 * state->growbufsiz < LINE_MAXLEN |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
711 ? 2 * state->growbufsiz : LINE_MAXLEN; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
712 state->growbuf = vim_realloc(state->growbuf, state->growbufsiz); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
713 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
714 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
715 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
716 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
717 while (discard) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
718 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
719 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
720 * The current line is longer than LINE_MAXLEN, continue |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
721 * reading but discard everything until EOL or EOF is |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
722 * reached. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
723 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
724 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
725 || (int)STRLEN(IObuff) < IOSIZE - 1 |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
726 || IObuff[IOSIZE - 1] == '\n') |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
727 break; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
728 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
729 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
730 state->linebuf = state->growbuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
731 state->linelen = growbuflen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
732 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
733 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
734 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
735 |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
736 #ifdef FEAT_MBYTE |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
737 /* Convert a line if it contains a non-ASCII character. */ |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
738 if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
739 { |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
740 char_u *line; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
741 |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
742 line = string_convert(&state->vc, state->linebuf, &state->linelen); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
743 if (line != NULL) |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
744 { |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
745 if (state->linelen < IOSIZE) |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
746 { |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
747 STRCPY(state->linebuf, line); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
748 vim_free(line); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
749 } |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
750 else |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
751 { |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
752 vim_free(state->growbuf); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
753 state->linebuf = state->growbuf = line; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
754 state->growbufsiz = state->linelen < LINE_MAXLEN |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
755 ? state->linelen : LINE_MAXLEN; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
756 } |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
757 } |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
758 } |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
759 #endif |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
760 |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
761 return QF_OK; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
762 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
763 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
764 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
765 * Get the next string from a file/buffer/list/string. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
766 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
767 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
768 qf_get_nextline(qfstate_T *state) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
769 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
770 int status = QF_FAIL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
771 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
772 if (state->fd == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
773 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
774 if (state->tv != NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
775 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
776 if (state->tv->v_type == VAR_STRING) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
777 /* Get the next line from the supplied string */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
778 status = qf_get_next_str_line(state); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
779 else if (state->tv->v_type == VAR_LIST) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
780 /* Get the next line from the supplied list */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
781 status = qf_get_next_list_line(state); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
782 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
783 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
784 /* Get the next line from the supplied buffer */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
785 status = qf_get_next_buf_line(state); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
786 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
787 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
788 /* Get the next line from the supplied file */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
789 status = qf_get_next_file_line(state); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
790 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
791 if (status != QF_OK) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
792 return status; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
793 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
794 /* remove newline/CR from the line */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
795 if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\n') |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
796 { |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
797 state->linebuf[state->linelen - 1] = NUL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
798 #ifdef USE_CRNL |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
799 if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r') |
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
800 state->linebuf[state->linelen - 2] = NUL; |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
801 #endif |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
802 } |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
803 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
804 #ifdef FEAT_MBYTE |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
805 remove_bom(state->linebuf); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
806 #endif |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
807 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
808 return QF_OK; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
809 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
810 |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
811 typedef struct { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
812 char_u *namebuf; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
813 char_u *errmsg; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
814 int errmsglen; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
815 long lnum; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
816 int col; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
817 char_u use_viscol; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
818 char_u *pattern; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
819 int enr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
820 int type; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
821 int valid; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
822 } qffields_T; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
823 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
824 /* |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
825 * Parse a line and get the quickfix fields. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
826 * Return the QF_ status. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
827 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
828 static int |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
829 qf_parse_line( |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
830 qf_info_T *qi, |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
831 int qf_idx, |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
832 char_u *linebuf, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
833 int linelen, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
834 efm_T *fmt_first, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
835 qffields_T *fields) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
836 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
837 efm_T *fmt_ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
838 char_u *ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
839 int len; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
840 int i; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
841 int idx = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
842 char_u *tail = NULL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
843 regmatch_T regmatch; |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
844 qf_list_T *qfl = &qi->qf_lists[qf_idx]; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
845 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
846 /* Always ignore case when looking for a matching error. */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
847 regmatch.rm_ic = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
848 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
849 /* If there was no %> item start at the first pattern */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
850 if (fmt_start == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
851 fmt_ptr = fmt_first; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
852 else |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
853 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
854 fmt_ptr = fmt_start; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
855 fmt_start = NULL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
856 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
857 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
858 /* |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
859 * Try to match each part of 'errorformat' until we find a complete |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
860 * match or no match. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
861 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
862 fields->valid = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
863 restofline: |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
864 for ( ; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
865 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
866 int r; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
867 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
868 idx = fmt_ptr->prefix; |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
869 if (qfl->qf_multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
870 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
871 fields->namebuf[0] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
872 fields->pattern[0] = NUL; |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
873 if (!qfl->qf_multiscan) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
874 fields->errmsg[0] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
875 fields->lnum = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
876 fields->col = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
877 fields->use_viscol = FALSE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
878 fields->enr = -1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
879 fields->type = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
880 tail = NULL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
881 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
882 regmatch.regprog = fmt_ptr->prog; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
883 r = vim_regexec(®match, linebuf, (colnr_T)0); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
884 fmt_ptr->prog = regmatch.regprog; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
885 if (r) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
886 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
887 if ((idx == 'C' || idx == 'Z') && !qfl->qf_multiline) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
888 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
889 if (vim_strchr((char_u *)"EWI", idx) != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
890 fields->type = idx; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
891 else |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
892 fields->type = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
893 /* |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
894 * Extract error message data from matched line. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
895 * We check for an actual submatch, because "\[" and "\]" in |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
896 * the 'errorformat' may cause the wrong submatch to be used. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
897 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
898 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
899 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
900 int c; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
901 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
902 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
903 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
904 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
905 /* Expand ~/file and $HOME/file to full path. */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
906 c = *regmatch.endp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
907 *regmatch.endp[i] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
908 expand_env(regmatch.startp[i], fields->namebuf, CMDBUFFSIZE); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
909 *regmatch.endp[i] = c; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
910 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
911 if (vim_strchr((char_u *)"OPQ", idx) != NULL |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
912 && mch_getperm(fields->namebuf) == -1) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
913 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
914 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
915 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
916 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
917 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
918 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
919 fields->enr = (int)atol((char *)regmatch.startp[i]); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
920 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
921 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
922 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
923 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
924 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
925 fields->lnum = atol((char *)regmatch.startp[i]); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
926 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
927 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
928 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
929 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
930 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
931 fields->col = (int)atol((char *)regmatch.startp[i]); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
932 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
933 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
934 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
935 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
936 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
937 fields->type = *regmatch.startp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
938 } |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
939 if (fmt_ptr->flags == '+' && !qfl->qf_multiscan) /* %+ */ |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
940 { |
11426
3270f080bf0a
patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents:
11422
diff
changeset
|
941 if (linelen >= fields->errmsglen) |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
942 { |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
943 /* linelen + null terminator */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
944 if ((fields->errmsg = vim_realloc(fields->errmsg, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
945 linelen + 1)) == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
946 return QF_NOMEM; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
947 fields->errmsglen = linelen + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
948 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
949 vim_strncpy(fields->errmsg, linebuf, linelen); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
950 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
951 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
952 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
953 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
954 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
955 len = (int)(regmatch.endp[i] - regmatch.startp[i]); |
11426
3270f080bf0a
patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents:
11422
diff
changeset
|
956 if (len >= fields->errmsglen) |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
957 { |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
958 /* len + null terminator */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
959 if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1)) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
960 == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
961 return QF_NOMEM; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
962 fields->errmsglen = len + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
963 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
964 vim_strncpy(fields->errmsg, regmatch.startp[i], len); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
965 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
966 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
967 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
968 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
969 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
970 tail = regmatch.startp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
971 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
972 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
973 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
974 char_u *match_ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
975 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
976 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
977 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
978 fields->col = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
979 for (match_ptr = regmatch.startp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
980 match_ptr != regmatch.endp[i]; ++match_ptr) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
981 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
982 ++fields->col; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
983 if (*match_ptr == TAB) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
984 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
985 fields->col += 7; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
986 fields->col -= fields->col % 8; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
987 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
988 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
989 ++fields->col; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
990 fields->use_viscol = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
991 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
992 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
993 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
994 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
995 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
996 fields->col = (int)atol((char *)regmatch.startp[i]); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
997 fields->use_viscol = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
998 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
999 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1000 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1001 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1002 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1003 len = (int)(regmatch.endp[i] - regmatch.startp[i]); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1004 if (len > CMDBUFFSIZE - 5) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1005 len = CMDBUFFSIZE - 5; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1006 STRCPY(fields->pattern, "^\\V"); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1007 STRNCAT(fields->pattern, regmatch.startp[i], len); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1008 fields->pattern[len + 3] = '\\'; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1009 fields->pattern[len + 4] = '$'; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1010 fields->pattern[len + 5] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1011 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1012 break; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1013 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1014 } |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1015 qfl->qf_multiscan = FALSE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1016 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1017 if (fmt_ptr == NULL || idx == 'D' || idx == 'X') |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1018 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1019 if (fmt_ptr != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1020 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1021 if (idx == 'D') /* enter directory */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1022 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1023 if (*fields->namebuf == NUL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1024 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1025 EMSG(_("E379: Missing or empty directory name")); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1026 return QF_FAIL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1027 } |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1028 qfl->qf_directory = |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1029 qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE); |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1030 if (qfl->qf_directory == NULL) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1031 return QF_FAIL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1032 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1033 else if (idx == 'X') /* leave directory */ |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1034 qfl->qf_directory = qf_pop_dir(&qfl->qf_dir_stack); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1035 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1036 fields->namebuf[0] = NUL; /* no match found, remove file name */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1037 fields->lnum = 0; /* don't jump to this line */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1038 fields->valid = FALSE; |
11426
3270f080bf0a
patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents:
11422
diff
changeset
|
1039 if (linelen >= fields->errmsglen) |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
1040 { |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1041 /* linelen + null terminator */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1042 if ((fields->errmsg = vim_realloc(fields->errmsg, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1043 linelen + 1)) == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1044 return QF_NOMEM; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1045 fields->errmsglen = linelen + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1046 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1047 /* copy whole line to error message */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1048 vim_strncpy(fields->errmsg, linebuf, linelen); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1049 if (fmt_ptr == NULL) |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1050 qfl->qf_multiline = qfl->qf_multiignore = FALSE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1051 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1052 else if (fmt_ptr != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1053 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1054 /* honor %> item */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1055 if (fmt_ptr->conthere) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1056 fmt_start = fmt_ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1057 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1058 if (vim_strchr((char_u *)"AEWI", idx) != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1059 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1060 qfl->qf_multiline = TRUE; /* start of a multi-line message */ |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1061 qfl->qf_multiignore = FALSE;/* reset continuation */ |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1062 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1063 else if (vim_strchr((char_u *)"CZ", idx) != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1064 { /* continuation of multi-line msg */ |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1065 if (!qfl->qf_multiignore) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1066 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1067 qfline_T *qfprev = qfl->qf_last; |
10257
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1068 |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1069 if (qfprev == NULL) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1070 return QF_FAIL; |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1071 if (*fields->errmsg && !qfl->qf_multiignore) |
10257
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1072 { |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1073 len = (int)STRLEN(qfprev->qf_text); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1074 if ((ptr = alloc((unsigned)(len + STRLEN(fields->errmsg) + 2))) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1075 == NULL) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1076 return QF_FAIL; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1077 STRCPY(ptr, qfprev->qf_text); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1078 vim_free(qfprev->qf_text); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1079 qfprev->qf_text = ptr; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1080 *(ptr += len) = '\n'; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1081 STRCPY(++ptr, fields->errmsg); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1082 } |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1083 if (qfprev->qf_nr == -1) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1084 qfprev->qf_nr = fields->enr; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1085 if (vim_isprintc(fields->type) && !qfprev->qf_type) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1086 /* only printable chars allowed */ |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1087 qfprev->qf_type = fields->type; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1088 |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1089 if (!qfprev->qf_lnum) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1090 qfprev->qf_lnum = fields->lnum; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1091 if (!qfprev->qf_col) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1092 qfprev->qf_col = fields->col; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1093 qfprev->qf_viscol = fields->use_viscol; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1094 if (!qfprev->qf_fnum) |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1095 qfprev->qf_fnum = qf_get_fnum(qi, qf_idx, |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1096 qfl->qf_directory, |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1097 *fields->namebuf || qfl->qf_directory != NULL |
10257
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1098 ? fields->namebuf |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1099 : qfl->qf_currfile != NULL && fields->valid |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1100 ? qfl->qf_currfile : 0); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1101 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1102 if (idx == 'Z') |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1103 qfl->qf_multiline = qfl->qf_multiignore = FALSE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1104 line_breakcheck(); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1105 return QF_IGNORE_LINE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1106 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1107 else if (vim_strchr((char_u *)"OPQ", idx) != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1108 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1109 /* global file names */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1110 fields->valid = FALSE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1111 if (*fields->namebuf == NUL || mch_getperm(fields->namebuf) >= 0) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1112 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1113 if (*fields->namebuf && idx == 'P') |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1114 qfl->qf_currfile = |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1115 qf_push_dir(fields->namebuf, &qfl->qf_file_stack, TRUE); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1116 else if (idx == 'Q') |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1117 qfl->qf_currfile = qf_pop_dir(&qfl->qf_file_stack); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1118 *fields->namebuf = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1119 if (tail && *tail) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1120 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1121 STRMOVE(IObuff, skipwhite(tail)); |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1122 qfl->qf_multiscan = TRUE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1123 goto restofline; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1124 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1125 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1126 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1127 if (fmt_ptr->flags == '-') /* generally exclude this line */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1128 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1129 if (qfl->qf_multiline) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1130 /* also exclude continuation lines */ |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1131 qfl->qf_multiignore = TRUE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1132 return QF_IGNORE_LINE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1133 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1134 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1135 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1136 return QF_OK; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1137 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1138 |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1139 /* |
41 | 1140 * Read the errorfile "efile" into memory, line by line, building the error |
1141 * list. | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1142 * Alternative: when "efile" is NULL read errors from buffer "buf". |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1143 * Alternative: when "tv" is not NULL get errors from the string or list. |
41 | 1144 * Always use 'errorformat' from "buf" if there is a local value. |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1145 * Then "lnumfirst" and "lnumlast" specify the range of lines to use. |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1146 * Set the title of the list to "qf_title". |
41 | 1147 * Return -1 for error, number of errors for success. |
1148 */ | |
1149 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1150 qf_init_ext( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1151 qf_info_T *qi, |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1152 int qf_idx, |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1153 char_u *efile, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1154 buf_T *buf, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1155 typval_T *tv, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1156 char_u *errorformat, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1157 int newlist, /* TRUE: start a new error list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1158 linenr_T lnumfirst, /* first line number to use */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1159 linenr_T lnumlast, /* last line number to use */ |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1160 char_u *qf_title, |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1161 char_u *enc) |
41 | 1162 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1163 qf_list_T *qfl; |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1164 qfstate_T state; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1165 qffields_T fields; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1166 qfline_T *old_last = NULL; |
10369
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1167 int adding = FALSE; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1168 static efm_T *fmt_first = NULL; |
7 | 1169 char_u *efm; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1170 static char_u *last_efm = NULL; |
7 | 1171 int retval = -1; /* default: return error flag */ |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1172 int status; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1173 |
11443
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
1174 /* Do not used the cached buffer, it may have been wiped out. */ |
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
1175 vim_free(qf_last_bufname); |
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
1176 qf_last_bufname = NULL; |
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
1177 |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1178 vim_memset(&state, 0, sizeof(state)); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1179 vim_memset(&fields, 0, sizeof(fields)); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1180 #ifdef FEAT_MBYTE |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1181 state.vc.vc_type = CONV_NONE; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1182 if (enc != NULL && *enc != NUL) |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1183 convert_setup(&state.vc, enc, p_enc); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1184 #endif |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1185 fields.namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1186 fields.errmsglen = CMDBUFFSIZE + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1187 fields.errmsg = alloc_id(fields.errmsglen, aid_qf_errmsg); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1188 fields.pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern); |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
1189 if (fields.namebuf == NULL || fields.errmsg == NULL || fields.pattern == NULL) |
7 | 1190 goto qf_init_end; |
1191 | |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1192 if (efile != NULL && (state.fd = mch_fopen((char *)efile, "r")) == NULL) |
7 | 1193 { |
1194 EMSG2(_(e_openerrf), efile); | |
1195 goto qf_init_end; | |
1196 } | |
1197 | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1198 if (newlist || qf_idx == qi->qf_listcount) |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1199 { |
7 | 1200 /* make place for a new list */ |
3965 | 1201 qf_new_list(qi, qf_title); |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1202 qf_idx = qi->qf_curlist; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1203 } |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
1204 else |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1205 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1206 /* Adding to existing list, use last entry. */ |
10369
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1207 adding = TRUE; |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1208 if (qi->qf_lists[qf_idx].qf_count > 0) |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1209 old_last = qi->qf_lists[qf_idx].qf_last; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1210 } |
7 | 1211 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1212 qfl = &qi->qf_lists[qf_idx]; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1213 |
7 | 1214 /* Use the local value of 'errorformat' if it's set. */ |
446 | 1215 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) |
41 | 1216 efm = buf->b_p_efm; |
7 | 1217 else |
1218 efm = errorformat; | |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
1219 |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1220 /* |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1221 * If the errorformat didn't change between calls, then reuse the |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1222 * previously parsed values. |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1223 */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1224 if (last_efm == NULL || (STRCMP(last_efm, efm) != 0)) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1225 { |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1226 /* free the previously parsed data */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1227 vim_free(last_efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1228 last_efm = NULL; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1229 free_efm_list(&fmt_first); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1230 |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1231 /* parse the current 'efm' */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1232 fmt_first = parse_efm_option(efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1233 if (fmt_first != NULL) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1234 last_efm = vim_strsave(efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1235 } |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1236 |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
1237 if (fmt_first == NULL) /* nothing found */ |
7 | 1238 goto error2; |
1239 | |
1240 /* | |
1241 * got_int is reset here, because it was probably set when killing the | |
1242 * ":make" command, but we still want to read the errorfile then. | |
1243 */ | |
1244 got_int = FALSE; | |
1245 | |
446 | 1246 if (tv != NULL) |
1247 { | |
1248 if (tv->v_type == VAR_STRING) | |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1249 state.p_str = tv->vval.v_string; |
446 | 1250 else if (tv->v_type == VAR_LIST) |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1251 state.p_li = tv->vval.v_list->lv_first; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1252 state.tv = tv; |
446 | 1253 } |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1254 state.buf = buf; |
9534
340106787852
commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents:
9531
diff
changeset
|
1255 state.buflnum = lnumfirst; |
340106787852
commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents:
9531
diff
changeset
|
1256 state.lnumlast = lnumlast; |
446 | 1257 |
7 | 1258 /* |
1259 * Read the lines in the error file one by one. | |
1260 * Try to recognize one of the error formats in each line. | |
1261 */ | |
41 | 1262 while (!got_int) |
7 | 1263 { |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1264 /* Get the next line from a file/buffer/list/string */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1265 status = qf_get_nextline(&state); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1266 if (status == QF_NOMEM) /* memory alloc failure */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1267 goto qf_init_end; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1268 if (status == QF_END_OF_INPUT) /* end of input */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1269 break; |
7 | 1270 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1271 status = qf_parse_line(qi, qf_idx, state.linebuf, state.linelen, |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1272 fmt_first, &fields); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1273 if (status == QF_FAIL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1274 goto error2; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1275 if (status == QF_NOMEM) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1276 goto qf_init_end; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1277 if (status == QF_IGNORE_LINE) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1278 continue; |
7 | 1279 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1280 if (qf_add_entry(qi, |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1281 qf_idx, |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1282 qfl->qf_directory, |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1283 (*fields.namebuf || qfl->qf_directory != NULL) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1284 ? fields.namebuf |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1285 : ((qfl->qf_currfile != NULL && fields.valid) |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1286 ? qfl->qf_currfile : (char_u *)NULL), |
1065 | 1287 0, |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1288 fields.errmsg, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1289 fields.lnum, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1290 fields.col, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1291 fields.use_viscol, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1292 fields.pattern, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1293 fields.enr, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1294 fields.type, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1295 fields.valid) == FAIL) |
7 | 1296 goto error2; |
1297 line_breakcheck(); | |
1298 } | |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1299 if (state.fd == NULL || !ferror(state.fd)) |
7 | 1300 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1301 if (qfl->qf_index == 0) |
7 | 1302 { |
644 | 1303 /* no valid entry found */ |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1304 qfl->qf_ptr = qfl->qf_start; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1305 qfl->qf_index = 1; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1306 qfl->qf_nonevalid = TRUE; |
7 | 1307 } |
1308 else | |
1309 { | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1310 qfl->qf_nonevalid = FALSE; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1311 if (qfl->qf_ptr == NULL) |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1312 qfl->qf_ptr = qfl->qf_start; |
7 | 1313 } |
644 | 1314 /* return number of matches */ |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1315 retval = qfl->qf_count; |
9369
ce5b79b005ec
commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents:
9365
diff
changeset
|
1316 goto qf_init_end; |
7 | 1317 } |
1318 EMSG(_(e_readerrf)); | |
1319 error2: | |
10369
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1320 if (!adding) |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1321 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1322 /* Error when creating a new list. Free the new list */ |
10369
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1323 qf_free(qi, qi->qf_curlist); |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1324 qi->qf_listcount--; |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1325 if (qi->qf_curlist > 0) |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1326 --qi->qf_curlist; |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1327 } |
9369
ce5b79b005ec
commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents:
9365
diff
changeset
|
1328 qf_init_end: |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1329 if (state.fd != NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1330 fclose(state.fd); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1331 vim_free(fields.namebuf); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1332 vim_free(fields.errmsg); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1333 vim_free(fields.pattern); |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1334 vim_free(state.growbuf); |
7 | 1335 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1336 if (qf_idx == qi->qf_curlist) |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1337 qf_update_buffer(qi, old_last); |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1338 #ifdef FEAT_MBYTE |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1339 if (state.vc.vc_type != CONV_NONE) |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1340 convert_setup(&state.vc, NULL, NULL); |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1341 #endif |
7 | 1342 |
1343 return retval; | |
1344 } | |
1345 | |
6079 | 1346 static void |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1347 qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) |
6079 | 1348 { |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1349 vim_free(qi->qf_lists[qf_idx].qf_title); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1350 qi->qf_lists[qf_idx].qf_title = NULL; |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1351 |
6079 | 1352 if (title != NULL) |
1353 { | |
1354 char_u *p = alloc((int)STRLEN(title) + 2); | |
1355 | |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1356 qi->qf_lists[qf_idx].qf_title = p; |
6079 | 1357 if (p != NULL) |
1358 sprintf((char *)p, ":%s", (char *)title); | |
1359 } | |
1360 } | |
1361 | |
7 | 1362 /* |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
1363 * Prepare for adding a new quickfix list. If the current list is in the |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
1364 * middle of the stack, then all the following lists are freed and then |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
1365 * the new list is added. |
7 | 1366 */ |
1367 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1368 qf_new_list(qf_info_T *qi, char_u *qf_title) |
7 | 1369 { |
1370 int i; | |
1371 | |
1372 /* | |
6079 | 1373 * If the current entry is not the last entry, delete entries beyond |
7 | 1374 * the current entry. This makes it possible to browse in a tree-like |
1375 * way with ":grep'. | |
1376 */ | |
644 | 1377 while (qi->qf_listcount > qi->qf_curlist + 1) |
1378 qf_free(qi, --qi->qf_listcount); | |
7 | 1379 |
1380 /* | |
1381 * When the stack is full, remove to oldest entry | |
1382 * Otherwise, add a new entry. | |
1383 */ | |
644 | 1384 if (qi->qf_listcount == LISTCOUNT) |
7 | 1385 { |
644 | 1386 qf_free(qi, 0); |
7 | 1387 for (i = 1; i < LISTCOUNT; ++i) |
644 | 1388 qi->qf_lists[i - 1] = qi->qf_lists[i]; |
1389 qi->qf_curlist = LISTCOUNT - 1; | |
7 | 1390 } |
1391 else | |
644 | 1392 qi->qf_curlist = qi->qf_listcount++; |
3259 | 1393 vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T))); |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1394 qf_store_title(qi, qi->qf_curlist, qf_title); |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
1395 qi->qf_lists[qi->qf_curlist].qf_id = ++last_qf_id; |
7 | 1396 } |
1397 | |
644 | 1398 /* |
1399 * Free a location list | |
1400 */ | |
1401 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1402 ll_free_all(qf_info_T **pqi) |
359 | 1403 { |
1404 int i; | |
644 | 1405 qf_info_T *qi; |
1406 | |
1407 qi = *pqi; | |
1408 if (qi == NULL) | |
1409 return; | |
1410 *pqi = NULL; /* Remove reference to this list */ | |
1411 | |
1412 qi->qf_refcount--; | |
1413 if (qi->qf_refcount < 1) | |
1414 { | |
1415 /* No references to this location list */ | |
1416 for (i = 0; i < qi->qf_listcount; ++i) | |
1417 qf_free(qi, i); | |
1418 vim_free(qi); | |
1419 } | |
359 | 1420 } |
644 | 1421 |
1422 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1423 qf_free_all(win_T *wp) |
644 | 1424 { |
1425 int i; | |
1426 qf_info_T *qi = &ql_info; | |
1427 | |
1428 if (wp != NULL) | |
1429 { | |
1430 /* location list */ | |
1431 ll_free_all(&wp->w_llist); | |
1432 ll_free_all(&wp->w_llist_ref); | |
1433 } | |
1434 else | |
1435 /* quickfix list */ | |
1436 for (i = 0; i < qi->qf_listcount; ++i) | |
1437 qf_free(qi, i); | |
1438 } | |
359 | 1439 |
7 | 1440 /* |
1441 * Add an entry to the end of the list of errors. | |
1442 * Returns OK or FAIL. | |
1443 */ | |
1444 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1445 qf_add_entry( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1446 qf_info_T *qi, /* quickfix list */ |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1447 int qf_idx, /* list index */ |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1448 char_u *dir, /* optional directory name */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1449 char_u *fname, /* file name or NULL */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1450 int bufnum, /* buffer number or zero */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1451 char_u *mesg, /* message */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1452 long lnum, /* line number */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1453 int col, /* column */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1454 int vis_col, /* using visual column */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1455 char_u *pattern, /* search pattern */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1456 int nr, /* error number */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1457 int type, /* type character */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1458 int valid) /* valid entry */ |
7 | 1459 { |
230 | 1460 qfline_T *qfp; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1461 qfline_T **lastp; /* pointer to qf_last or NULL */ |
7 | 1462 |
230 | 1463 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) |
7 | 1464 return FAIL; |
1065 | 1465 if (bufnum != 0) |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1466 { |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1467 buf_T *buf = buflist_findnr(bufnum); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1468 |
1065 | 1469 qfp->qf_fnum = bufnum; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1470 if (buf != NULL) |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1471 buf->b_has_qf_entry |= |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1472 (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1473 } |
1065 | 1474 else |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1475 qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname); |
7 | 1476 if ((qfp->qf_text = vim_strsave(mesg)) == NULL) |
1477 { | |
1478 vim_free(qfp); | |
1479 return FAIL; | |
1480 } | |
1481 qfp->qf_lnum = lnum; | |
1482 qfp->qf_col = col; | |
170 | 1483 qfp->qf_viscol = vis_col; |
230 | 1484 if (pattern == NULL || *pattern == NUL) |
1485 qfp->qf_pattern = NULL; | |
1486 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) | |
1487 { | |
1488 vim_free(qfp->qf_text); | |
1489 vim_free(qfp); | |
1490 return FAIL; | |
1491 } | |
7 | 1492 qfp->qf_nr = nr; |
1493 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */ | |
1494 type = 0; | |
1495 qfp->qf_type = type; | |
1496 qfp->qf_valid = valid; | |
1497 | |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1498 lastp = &qi->qf_lists[qf_idx].qf_last; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1499 if (qi->qf_lists[qf_idx].qf_count == 0) |
644 | 1500 /* first element in the list */ |
7 | 1501 { |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1502 qi->qf_lists[qf_idx].qf_start = qfp; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1503 qi->qf_lists[qf_idx].qf_ptr = qfp; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1504 qi->qf_lists[qf_idx].qf_index = 0; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1505 qfp->qf_prev = NULL; |
7 | 1506 } |
1507 else | |
1508 { | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1509 qfp->qf_prev = *lastp; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1510 (*lastp)->qf_next = qfp; |
7 | 1511 } |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1512 qfp->qf_next = NULL; |
7 | 1513 qfp->qf_cleared = FALSE; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1514 *lastp = qfp; |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1515 ++qi->qf_lists[qf_idx].qf_count; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1516 if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid) |
644 | 1517 /* first valid entry */ |
7 | 1518 { |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1519 qi->qf_lists[qf_idx].qf_index = |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1520 qi->qf_lists[qf_idx].qf_count; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1521 qi->qf_lists[qf_idx].qf_ptr = qfp; |
7 | 1522 } |
1523 | |
1524 return OK; | |
1525 } | |
1526 | |
1527 /* | |
659 | 1528 * Allocate a new location list |
644 | 1529 */ |
659 | 1530 static qf_info_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1531 ll_new_list(void) |
644 | 1532 { |
659 | 1533 qf_info_T *qi; |
1534 | |
1535 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T)); | |
1536 if (qi != NULL) | |
1537 { | |
1538 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T))); | |
1539 qi->qf_refcount++; | |
1540 } | |
1541 | |
1542 return qi; | |
644 | 1543 } |
1544 | |
1545 /* | |
1546 * Return the location list for window 'wp'. | |
1547 * If not present, allocate a location list | |
1548 */ | |
1549 static qf_info_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1550 ll_get_or_alloc_list(win_T *wp) |
644 | 1551 { |
1552 if (IS_LL_WINDOW(wp)) | |
1553 /* For a location list window, use the referenced location list */ | |
1554 return wp->w_llist_ref; | |
1555 | |
1556 /* | |
1557 * For a non-location list window, w_llist_ref should not point to a | |
1558 * location list. | |
1559 */ | |
1560 ll_free_all(&wp->w_llist_ref); | |
1561 | |
1562 if (wp->w_llist == NULL) | |
659 | 1563 wp->w_llist = ll_new_list(); /* new location list */ |
644 | 1564 return wp->w_llist; |
1565 } | |
1566 | |
1567 /* | |
1568 * Copy the location list from window "from" to window "to". | |
1569 */ | |
1570 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1571 copy_loclist(win_T *from, win_T *to) |
644 | 1572 { |
1573 qf_info_T *qi; | |
1574 int idx; | |
1575 int i; | |
1576 | |
1577 /* | |
1578 * When copying from a location list window, copy the referenced | |
1579 * location list. For other windows, copy the location list for | |
1580 * that window. | |
1581 */ | |
1582 if (IS_LL_WINDOW(from)) | |
1583 qi = from->w_llist_ref; | |
1584 else | |
1585 qi = from->w_llist; | |
1586 | |
1587 if (qi == NULL) /* no location list to copy */ | |
1588 return; | |
1589 | |
659 | 1590 /* allocate a new location list */ |
1591 if ((to->w_llist = ll_new_list()) == NULL) | |
644 | 1592 return; |
1593 | |
1594 to->w_llist->qf_listcount = qi->qf_listcount; | |
1595 | |
1596 /* Copy the location lists one at a time */ | |
1597 for (idx = 0; idx < qi->qf_listcount; idx++) | |
1598 { | |
1599 qf_list_T *from_qfl; | |
1600 qf_list_T *to_qfl; | |
1601 | |
1602 to->w_llist->qf_curlist = idx; | |
1603 | |
1604 from_qfl = &qi->qf_lists[idx]; | |
1605 to_qfl = &to->w_llist->qf_lists[idx]; | |
1606 | |
1607 /* Some of the fields are populated by qf_add_entry() */ | |
1608 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid; | |
1609 to_qfl->qf_count = 0; | |
1610 to_qfl->qf_index = 0; | |
1611 to_qfl->qf_start = NULL; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1612 to_qfl->qf_last = NULL; |
644 | 1613 to_qfl->qf_ptr = NULL; |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1614 if (from_qfl->qf_title != NULL) |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1615 to_qfl->qf_title = vim_strsave(from_qfl->qf_title); |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1616 else |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1617 to_qfl->qf_title = NULL; |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1618 if (from_qfl->qf_ctx != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1619 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1620 to_qfl->qf_ctx = alloc_tv(); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1621 if (to_qfl->qf_ctx != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1622 copy_tv(from_qfl->qf_ctx, to_qfl->qf_ctx); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1623 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1624 else |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1625 to_qfl->qf_ctx = NULL; |
644 | 1626 |
1627 if (from_qfl->qf_count) | |
1628 { | |
1629 qfline_T *from_qfp; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1630 qfline_T *prevp; |
644 | 1631 |
1632 /* copy all the location entries in this list */ | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1633 for (i = 0, from_qfp = from_qfl->qf_start; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1634 i < from_qfl->qf_count && from_qfp != NULL; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1635 ++i, from_qfp = from_qfp->qf_next) |
644 | 1636 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1637 if (qf_add_entry(to->w_llist, |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1638 to->w_llist->qf_curlist, |
644 | 1639 NULL, |
1640 NULL, | |
1065 | 1641 0, |
644 | 1642 from_qfp->qf_text, |
1643 from_qfp->qf_lnum, | |
1644 from_qfp->qf_col, | |
1645 from_qfp->qf_viscol, | |
1646 from_qfp->qf_pattern, | |
1647 from_qfp->qf_nr, | |
1648 0, | |
1649 from_qfp->qf_valid) == FAIL) | |
1650 { | |
1651 qf_free_all(to); | |
1652 return; | |
1653 } | |
1654 /* | |
1655 * qf_add_entry() will not set the qf_num field, as the | |
1656 * directory and file names are not supplied. So the qf_fnum | |
1657 * field is copied here. | |
1658 */ | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1659 prevp = to->w_llist->qf_lists[to->w_llist->qf_curlist].qf_last; |
644 | 1660 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */ |
1661 prevp->qf_type = from_qfp->qf_type; /* error type */ | |
1662 if (from_qfl->qf_ptr == from_qfp) | |
1663 to_qfl->qf_ptr = prevp; /* current location */ | |
1664 } | |
1665 } | |
1666 | |
1667 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */ | |
1668 | |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
1669 /* Assign a new ID for the location list */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
1670 to_qfl->qf_id = ++last_qf_id; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
1671 |
644 | 1672 /* When no valid entries are present in the list, qf_ptr points to |
1673 * the first item in the list */ | |
2795 | 1674 if (to_qfl->qf_nonevalid) |
5060
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1675 { |
644 | 1676 to_qfl->qf_ptr = to_qfl->qf_start; |
5060
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1677 to_qfl->qf_index = 1; |
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1678 } |
644 | 1679 } |
1680 | |
1681 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */ | |
1682 } | |
1683 | |
1684 /* | |
10379
73e2a7abe2a3
commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents:
10369
diff
changeset
|
1685 * Get buffer number for file "directory/fname". |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1686 * Also sets the b_has_qf_entry flag. |
7 | 1687 */ |
1688 static int | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1689 qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory, char_u *fname) |
7 | 1690 { |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1691 char_u *ptr = NULL; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1692 buf_T *buf; |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1693 char_u *bufname; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1694 |
7 | 1695 if (fname == NULL || *fname == NUL) /* no file name */ |
1696 return 0; | |
1697 | |
2823 | 1698 #ifdef VMS |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1699 vms_remove_version(fname); |
2823 | 1700 #endif |
1701 #ifdef BACKSLASH_IN_FILENAME | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1702 if (directory != NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1703 slash_adjust(directory); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1704 slash_adjust(fname); |
2823 | 1705 #endif |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1706 if (directory != NULL && !vim_isAbsName(fname) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1707 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1708 { |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1709 /* |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1710 * Here we check if the file really exists. |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1711 * This should normally be true, but if make works without |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1712 * "leaving directory"-messages we might have missed a |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1713 * directory change. |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1714 */ |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1715 if (mch_getperm(ptr) < 0) |
7 | 1716 { |
1717 vim_free(ptr); | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1718 directory = qf_guess_filepath(qi, qf_idx, fname); |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1719 if (directory) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1720 ptr = concat_fnames(directory, fname, TRUE); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1721 else |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1722 ptr = vim_strsave(fname); |
7 | 1723 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1724 /* Use concatenated directory name and file name */ |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1725 bufname = ptr; |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1726 } |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1727 else |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1728 bufname = fname; |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1729 |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1730 if (qf_last_bufname != NULL && STRCMP(bufname, qf_last_bufname) == 0 |
9475
4d8f7f8da90c
commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents:
9473
diff
changeset
|
1731 && bufref_valid(&qf_last_bufref)) |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1732 { |
9475
4d8f7f8da90c
commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents:
9473
diff
changeset
|
1733 buf = qf_last_bufref.br_buf; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1734 vim_free(ptr); |
7 | 1735 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1736 else |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1737 { |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1738 vim_free(qf_last_bufname); |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1739 buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT); |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1740 if (bufname == ptr) |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1741 qf_last_bufname = bufname; |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1742 else |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1743 qf_last_bufname = vim_strsave(bufname); |
9475
4d8f7f8da90c
commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents:
9473
diff
changeset
|
1744 set_bufref(&qf_last_bufref, buf); |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1745 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1746 if (buf == NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1747 return 0; |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1748 |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1749 buf->b_has_qf_entry = |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1750 (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1751 return buf->b_fnum; |
7 | 1752 } |
1753 | |
1754 /* | |
9334
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
1755 * Push dirbuf onto the directory stack and return pointer to actual dir or |
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
1756 * NULL on error. |
7 | 1757 */ |
1758 static char_u * | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1759 qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) |
7 | 1760 { |
1761 struct dir_stack_T *ds_new; | |
1762 struct dir_stack_T *ds_ptr; | |
1763 | |
1764 /* allocate new stack element and hook it in */ | |
1765 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T)); | |
1766 if (ds_new == NULL) | |
1767 return NULL; | |
1768 | |
1769 ds_new->next = *stackptr; | |
1770 *stackptr = ds_new; | |
1771 | |
1772 /* store directory on the stack */ | |
1773 if (vim_isAbsName(dirbuf) | |
1774 || (*stackptr)->next == NULL | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1775 || (*stackptr && is_file_stack)) |
7 | 1776 (*stackptr)->dirname = vim_strsave(dirbuf); |
1777 else | |
1778 { | |
1779 /* Okay we don't have an absolute path. | |
1780 * dirbuf must be a subdir of one of the directories on the stack. | |
1781 * Let's search... | |
1782 */ | |
1783 ds_new = (*stackptr)->next; | |
1784 (*stackptr)->dirname = NULL; | |
1785 while (ds_new) | |
1786 { | |
1787 vim_free((*stackptr)->dirname); | |
1788 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, | |
1789 TRUE); | |
1790 if (mch_isdir((*stackptr)->dirname) == TRUE) | |
1791 break; | |
1792 | |
1793 ds_new = ds_new->next; | |
1794 } | |
1795 | |
1796 /* clean up all dirs we already left */ | |
1797 while ((*stackptr)->next != ds_new) | |
1798 { | |
1799 ds_ptr = (*stackptr)->next; | |
1800 (*stackptr)->next = (*stackptr)->next->next; | |
1801 vim_free(ds_ptr->dirname); | |
1802 vim_free(ds_ptr); | |
1803 } | |
1804 | |
1805 /* Nothing found -> it must be on top level */ | |
1806 if (ds_new == NULL) | |
1807 { | |
1808 vim_free((*stackptr)->dirname); | |
1809 (*stackptr)->dirname = vim_strsave(dirbuf); | |
1810 } | |
1811 } | |
1812 | |
1813 if ((*stackptr)->dirname != NULL) | |
1814 return (*stackptr)->dirname; | |
1815 else | |
1816 { | |
1817 ds_ptr = *stackptr; | |
1818 *stackptr = (*stackptr)->next; | |
1819 vim_free(ds_ptr); | |
1820 return NULL; | |
1821 } | |
1822 } | |
1823 | |
1824 | |
1825 /* | |
1826 * pop dirbuf from the directory stack and return previous directory or NULL if | |
1827 * stack is empty | |
1828 */ | |
1829 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1830 qf_pop_dir(struct dir_stack_T **stackptr) |
7 | 1831 { |
1832 struct dir_stack_T *ds_ptr; | |
1833 | |
1834 /* TODO: Should we check if dirbuf is the directory on top of the stack? | |
1835 * What to do if it isn't? */ | |
1836 | |
1837 /* pop top element and free it */ | |
1838 if (*stackptr != NULL) | |
1839 { | |
1840 ds_ptr = *stackptr; | |
1841 *stackptr = (*stackptr)->next; | |
1842 vim_free(ds_ptr->dirname); | |
1843 vim_free(ds_ptr); | |
1844 } | |
1845 | |
1846 /* return NEW top element as current dir or NULL if stack is empty*/ | |
1847 return *stackptr ? (*stackptr)->dirname : NULL; | |
1848 } | |
1849 | |
1850 /* | |
1851 * clean up directory stack | |
1852 */ | |
1853 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1854 qf_clean_dir_stack(struct dir_stack_T **stackptr) |
7 | 1855 { |
1856 struct dir_stack_T *ds_ptr; | |
1857 | |
1858 while ((ds_ptr = *stackptr) != NULL) | |
1859 { | |
1860 *stackptr = (*stackptr)->next; | |
1861 vim_free(ds_ptr->dirname); | |
1862 vim_free(ds_ptr); | |
1863 } | |
1864 } | |
1865 | |
1866 /* | |
1867 * Check in which directory of the directory stack the given file can be | |
1868 * found. | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
1869 * Returns a pointer to the directory name or NULL if not found. |
7 | 1870 * Cleans up intermediate directory entries. |
1871 * | |
1872 * TODO: How to solve the following problem? | |
1873 * If we have the this directory tree: | |
1874 * ./ | |
1875 * ./aa | |
1876 * ./aa/bb | |
1877 * ./bb | |
1878 * ./bb/x.c | |
1879 * and make says: | |
1880 * making all in aa | |
1881 * making all in bb | |
1882 * x.c:9: Error | |
1883 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb. | |
1884 * qf_guess_filepath will return NULL. | |
1885 */ | |
1886 static char_u * | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1887 qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *filename) |
7 | 1888 { |
1889 struct dir_stack_T *ds_ptr; | |
1890 struct dir_stack_T *ds_tmp; | |
1891 char_u *fullname; | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1892 qf_list_T *qfl = &qi->qf_lists[qf_idx]; |
7 | 1893 |
1894 /* no dirs on the stack - there's nothing we can do */ | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1895 if (qfl->qf_dir_stack == NULL) |
7 | 1896 return NULL; |
1897 | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1898 ds_ptr = qfl->qf_dir_stack->next; |
7 | 1899 fullname = NULL; |
1900 while (ds_ptr) | |
1901 { | |
1902 vim_free(fullname); | |
1903 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE); | |
1904 | |
1905 /* If concat_fnames failed, just go on. The worst thing that can happen | |
1906 * is that we delete the entire stack. | |
1907 */ | |
1908 if ((fullname != NULL) && (mch_getperm(fullname) >= 0)) | |
1909 break; | |
1910 | |
1911 ds_ptr = ds_ptr->next; | |
1912 } | |
1913 | |
1914 vim_free(fullname); | |
1915 | |
1916 /* clean up all dirs we already left */ | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1917 while (qfl->qf_dir_stack->next != ds_ptr) |
7 | 1918 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1919 ds_tmp = qfl->qf_dir_stack->next; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
1920 qfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next; |
7 | 1921 vim_free(ds_tmp->dirname); |
1922 vim_free(ds_tmp); | |
1923 } | |
1924 | |
1925 return ds_ptr==NULL? NULL: ds_ptr->dirname; | |
1926 } | |
1927 | |
1928 /* | |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1929 * When loading a file from the quickfix, the auto commands may modify it. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1930 * This may invalidate the current quickfix entry. This function checks |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1931 * whether a entry is still present in the quickfix. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1932 * Similar to location list. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1933 */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1934 static int |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1935 is_qf_entry_present(qf_info_T *qi, qfline_T *qf_ptr) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1936 { |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1937 qf_list_T *qfl; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1938 qfline_T *qfp; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1939 int i; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1940 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1941 qfl = &qi->qf_lists[qi->qf_curlist]; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1942 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1943 /* Search for the entry in the current list */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1944 for (i = 0, qfp = qfl->qf_start; i < qfl->qf_count; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1945 ++i, qfp = qfp->qf_next) |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1946 if (qfp == NULL || qfp == qf_ptr) |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1947 break; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1948 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1949 if (i == qfl->qf_count) /* Entry is not found */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1950 return FALSE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1951 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1952 return TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1953 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1954 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1955 /* |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1956 * Get the next valid entry in the current quickfix/location list. The search |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1957 * starts from the current entry. Returns NULL on failure. |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1958 */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1959 static qfline_T * |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1960 get_next_valid_entry( |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1961 qf_info_T *qi, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1962 qfline_T *qf_ptr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1963 int *qf_index, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1964 int dir) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1965 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1966 int idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1967 int old_qf_fnum; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1968 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1969 idx = *qf_index; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1970 old_qf_fnum = qf_ptr->qf_fnum; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1971 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1972 do |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1973 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1974 if (idx == qi->qf_lists[qi->qf_curlist].qf_count |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1975 || qf_ptr->qf_next == NULL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1976 return NULL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1977 ++idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1978 qf_ptr = qf_ptr->qf_next; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1979 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1980 && !qf_ptr->qf_valid) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1981 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1982 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1983 *qf_index = idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1984 return qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1985 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1986 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1987 /* |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1988 * Get the previous valid entry in the current quickfix/location list. The |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
1989 * search starts from the current entry. Returns NULL on failure. |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1990 */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1991 static qfline_T * |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1992 get_prev_valid_entry( |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1993 qf_info_T *qi, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1994 qfline_T *qf_ptr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1995 int *qf_index, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1996 int dir) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1997 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1998 int idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
1999 int old_qf_fnum; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2000 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2001 idx = *qf_index; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2002 old_qf_fnum = qf_ptr->qf_fnum; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2003 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2004 do |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2005 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2006 if (idx == 1 || qf_ptr->qf_prev == NULL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2007 return NULL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2008 --idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2009 qf_ptr = qf_ptr->qf_prev; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2010 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2011 && !qf_ptr->qf_valid) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2012 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2013 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2014 *qf_index = idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2015 return qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2016 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2017 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2018 /* |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2019 * Get the n'th (errornr) previous/next valid entry from the current entry in |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2020 * the quickfix list. |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2021 * dir == FORWARD or FORWARD_FILE: next valid entry |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2022 * dir == BACKWARD or BACKWARD_FILE: previous valid entry |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2023 */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2024 static qfline_T * |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2025 get_nth_valid_entry( |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2026 qf_info_T *qi, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2027 int errornr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2028 qfline_T *qf_ptr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2029 int *qf_index, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2030 int dir) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2031 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2032 qfline_T *prev_qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2033 int prev_index; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2034 static char_u *e_no_more_items = (char_u *)N_("E553: No more items"); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2035 char_u *err = e_no_more_items; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2036 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2037 while (errornr--) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2038 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2039 prev_qf_ptr = qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2040 prev_index = *qf_index; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2041 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2042 if (dir == FORWARD || dir == FORWARD_FILE) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2043 qf_ptr = get_next_valid_entry(qi, qf_ptr, qf_index, dir); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2044 else |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2045 qf_ptr = get_prev_valid_entry(qi, qf_ptr, qf_index, dir); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2046 if (qf_ptr == NULL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2047 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2048 qf_ptr = prev_qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2049 *qf_index = prev_index; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2050 if (err != NULL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2051 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2052 EMSG(_(err)); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2053 return NULL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2054 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2055 break; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2056 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2057 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2058 err = NULL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2059 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2060 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2061 return qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2062 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2063 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2064 /* |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2065 * Get n'th (errornr) quickfix entry |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2066 */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2067 static qfline_T * |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2068 get_nth_entry( |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2069 qf_info_T *qi, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2070 int errornr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2071 qfline_T *qf_ptr, |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2072 int *cur_qfidx) |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2073 { |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2074 int qf_idx = *cur_qfidx; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2075 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2076 /* New error number is less than the current error number */ |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2077 while (errornr < qf_idx && qf_idx > 1 && qf_ptr->qf_prev != NULL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2078 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2079 --qf_idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2080 qf_ptr = qf_ptr->qf_prev; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2081 } |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2082 /* New error number is greater than the current error number */ |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2083 while (errornr > qf_idx && |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2084 qf_idx < qi->qf_lists[qi->qf_curlist].qf_count && |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2085 qf_ptr->qf_next != NULL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2086 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2087 ++qf_idx; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2088 qf_ptr = qf_ptr->qf_next; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2089 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2090 |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2091 *cur_qfidx = qf_idx; |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2092 return qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2093 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2094 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2095 /* |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2096 * Find a help window or open one. |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2097 */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2098 static int |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2099 jump_to_help_window(qf_info_T *qi, int *opened_window) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2100 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2101 win_T *wp; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2102 int flags; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2103 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2104 if (cmdmod.tab != 0) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2105 wp = NULL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2106 else |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2107 FOR_ALL_WINDOWS(wp) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2108 if (bt_help(wp->w_buffer)) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2109 break; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2110 if (wp != NULL && wp->w_buffer->b_nwindows > 0) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2111 win_enter(wp, TRUE); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2112 else |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2113 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2114 /* |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2115 * Split off help window; put it at far top if no position |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2116 * specified, the current window is vertically split and narrow. |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2117 */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2118 flags = WSP_HELP; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2119 if (cmdmod.split == 0 && curwin->w_width != Columns |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2120 && curwin->w_width < 80) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2121 flags |= WSP_TOP; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2122 if (qi != &ql_info) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2123 flags |= WSP_NEWLOC; /* don't copy the location list */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2124 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2125 if (win_split(0, flags) == FAIL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2126 return FAIL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2127 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2128 *opened_window = TRUE; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2129 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2130 if (curwin->w_height < p_hh) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2131 win_setheight((int)p_hh); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2132 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2133 if (qi != &ql_info) /* not a quickfix list */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2134 { |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2135 /* The new window should use the supplied location list */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2136 curwin->w_llist = qi; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2137 qi->qf_refcount++; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2138 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2139 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2140 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2141 if (!p_im) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2142 restart_edit = 0; /* don't want insert mode in help file */ |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2143 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2144 return OK; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2145 } |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2146 |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2147 /* |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2148 * Find a suitable window for opening a file (qf_fnum) and jump to it. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2149 * If the file is already opened in a window, jump to it. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2150 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2151 static int |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2152 qf_jump_to_usable_window(int qf_fnum, int *opened_window) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2153 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2154 win_T *usable_win_ptr = NULL; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2155 int usable_win; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2156 qf_info_T *ll_ref; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2157 int flags; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2158 win_T *win; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2159 win_T *altwin; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2160 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2161 usable_win = 0; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2162 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2163 ll_ref = curwin->w_llist_ref; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2164 if (ll_ref != NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2165 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2166 /* Find a window using the same location list that is not a |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2167 * quickfix window. */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2168 FOR_ALL_WINDOWS(usable_win_ptr) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2169 if (usable_win_ptr->w_llist == ll_ref |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2170 && !bt_quickfix(usable_win_ptr->w_buffer)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2171 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2172 usable_win = 1; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2173 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2174 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2175 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2176 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2177 if (!usable_win) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2178 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2179 /* Locate a window showing a normal buffer */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2180 FOR_ALL_WINDOWS(win) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2181 if (win->w_buffer->b_p_bt[0] == NUL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2182 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2183 usable_win = 1; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2184 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2185 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2186 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2187 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2188 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2189 * If no usable window is found and 'switchbuf' contains "usetab" |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2190 * then search in other tabs. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2191 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2192 if (!usable_win && (swb_flags & SWB_USETAB)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2193 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2194 tabpage_T *tp; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2195 win_T *wp; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2196 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2197 FOR_ALL_TAB_WINDOWS(tp, wp) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2198 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2199 if (wp->w_buffer->b_fnum == qf_fnum) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2200 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2201 goto_tabpage_win(tp, wp); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2202 usable_win = 1; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2203 goto win_found; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2204 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2205 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2206 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2207 win_found: |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2208 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2209 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2210 * If there is only one window and it is the quickfix window, create a |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2211 * new one above the quickfix window. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2212 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2213 if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2214 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2215 flags = WSP_ABOVE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2216 if (ll_ref != NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2217 flags |= WSP_NEWLOC; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2218 if (win_split(0, flags) == FAIL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2219 return FAIL; /* not enough room for window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2220 *opened_window = TRUE; /* close it when fail */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2221 p_swb = empty_option; /* don't split again */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2222 swb_flags = 0; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2223 RESET_BINDING(curwin); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2224 if (ll_ref != NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2225 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2226 /* The new window should use the location list from the |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2227 * location list window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2228 curwin->w_llist = ll_ref; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2229 ll_ref->qf_refcount++; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2230 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2231 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2232 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2233 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2234 if (curwin->w_llist_ref != NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2235 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2236 /* In a location window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2237 win = usable_win_ptr; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2238 if (win == NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2239 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2240 /* Find the window showing the selected file */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2241 FOR_ALL_WINDOWS(win) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2242 if (win->w_buffer->b_fnum == qf_fnum) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2243 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2244 if (win == NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2245 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2246 /* Find a previous usable window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2247 win = curwin; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2248 do |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2249 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2250 if (win->w_buffer->b_p_bt[0] == NUL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2251 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2252 if (win->w_prev == NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2253 win = lastwin; /* wrap around the top */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2254 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2255 win = win->w_prev; /* go to previous window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2256 } while (win != curwin); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2257 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2258 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2259 win_goto(win); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2260 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2261 /* If the location list for the window is not set, then set it |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2262 * to the location list from the location window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2263 if (win->w_llist == NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2264 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2265 win->w_llist = ll_ref; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2266 ll_ref->qf_refcount++; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2267 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2268 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2269 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2270 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2271 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2272 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2273 * Try to find a window that shows the right buffer. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2274 * Default to the window just above the quickfix buffer. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2275 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2276 win = curwin; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2277 altwin = NULL; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2278 for (;;) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2279 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2280 if (win->w_buffer->b_fnum == qf_fnum) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2281 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2282 if (win->w_prev == NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2283 win = lastwin; /* wrap around the top */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2284 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2285 win = win->w_prev; /* go to previous window */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2286 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2287 if (IS_QF_WINDOW(win)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2288 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2289 /* Didn't find it, go to the window before the quickfix |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2290 * window. */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2291 if (altwin != NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2292 win = altwin; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2293 else if (curwin->w_prev != NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2294 win = curwin->w_prev; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2295 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2296 win = curwin->w_next; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2297 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2298 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2299 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2300 /* Remember a usable window. */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2301 if (altwin == NULL && !win->w_p_pvw |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2302 && win->w_buffer->b_p_bt[0] == NUL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2303 altwin = win; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2304 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2305 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2306 win_goto(win); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2307 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2308 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2309 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2310 return OK; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2311 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2312 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2313 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2314 * Edit the selected file or help file. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2315 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2316 static int |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2317 qf_jump_edit_buffer( |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2318 qf_info_T *qi, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2319 qfline_T *qf_ptr, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2320 int forceit, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2321 win_T *oldwin, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2322 int *opened_window, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2323 int *abort) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2324 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2325 int retval = OK; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2326 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2327 if (qf_ptr->qf_type == 1) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2328 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2329 /* Open help file (do_ecmd() will set b_help flag, readfile() will |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2330 * set b_p_ro flag). */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2331 if (!can_abandon(curbuf, forceit)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2332 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2333 no_write_message(); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2334 retval = FALSE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2335 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2336 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2337 retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2338 ECMD_HIDE + ECMD_SET_HELP, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2339 oldwin == curwin ? curwin : NULL); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2340 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2341 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2342 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2343 int old_qf_curlist = qi->qf_curlist; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2344 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2345 retval = buflist_getfile(qf_ptr->qf_fnum, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2346 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2347 if (qi != &ql_info && !win_valid_any_tab(oldwin)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2348 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2349 EMSG(_("E924: Current window was closed")); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2350 *abort = TRUE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2351 *opened_window = FALSE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2352 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2353 else if (old_qf_curlist != qi->qf_curlist |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2354 || !is_qf_entry_present(qi, qf_ptr)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2355 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2356 if (qi == &ql_info) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2357 EMSG(_("E925: Current quickfix was changed")); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2358 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2359 EMSG(_("E926: Current location list was changed")); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2360 *abort = TRUE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2361 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2362 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2363 if (*abort) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2364 retval = FALSE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2365 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2366 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2367 return retval; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2368 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2369 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2370 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2371 * Goto the error line in the current file using either line/column number or a |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2372 * search pattern. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2373 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2374 static void |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2375 qf_jump_goto_line( |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2376 linenr_T qf_lnum, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2377 int qf_col, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2378 char_u qf_viscol, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2379 char_u *qf_pattern) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2380 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2381 linenr_T i; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2382 char_u *line; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2383 colnr_T screen_col; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2384 colnr_T char_col; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2385 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2386 if (qf_pattern == NULL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2387 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2388 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2389 * Go to line with error, unless qf_lnum is 0. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2390 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2391 i = qf_lnum; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2392 if (i > 0) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2393 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2394 if (i > curbuf->b_ml.ml_line_count) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2395 i = curbuf->b_ml.ml_line_count; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2396 curwin->w_cursor.lnum = i; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2397 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2398 if (qf_col > 0) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2399 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2400 curwin->w_cursor.col = qf_col - 1; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2401 #ifdef FEAT_VIRTUALEDIT |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2402 curwin->w_cursor.coladd = 0; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2403 #endif |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2404 if (qf_viscol == TRUE) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2405 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2406 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2407 * Check each character from the beginning of the error |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2408 * line up to the error column. For each tab character |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2409 * found, reduce the error column value by the length of |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2410 * a tab character. |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2411 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2412 line = ml_get_curline(); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2413 screen_col = 0; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2414 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2415 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2416 if (*line == NUL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2417 break; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2418 if (*line++ == '\t') |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2419 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2420 curwin->w_cursor.col -= 7 - (screen_col % 8); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2421 screen_col += 8 - (screen_col % 8); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2422 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2423 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2424 ++screen_col; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2425 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2426 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2427 check_cursor(); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2428 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2429 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2430 beginline(BL_WHITE | BL_FIX); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2431 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2432 else |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2433 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2434 pos_T save_cursor; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2435 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2436 /* Move the cursor to the first line in the buffer */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2437 save_cursor = curwin->w_cursor; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2438 curwin->w_cursor.lnum = 0; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2439 if (!do_search(NULL, '/', qf_pattern, (long)1, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2440 SEARCH_KEEP, NULL, NULL)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2441 curwin->w_cursor = save_cursor; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2442 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2443 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2444 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2445 /* |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2446 * Display quickfix list index and size message |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2447 */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2448 static void |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2449 qf_jump_print_msg( |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2450 qf_info_T *qi, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2451 int qf_index, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2452 qfline_T *qf_ptr, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2453 buf_T *old_curbuf, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2454 linenr_T old_lnum) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2455 { |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2456 linenr_T i; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2457 int len; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2458 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2459 /* Update the screen before showing the message, unless the screen |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2460 * scrolled up. */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2461 if (!msg_scrolled) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2462 update_topline_redraw(); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2463 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2464 qi->qf_lists[qi->qf_curlist].qf_count, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2465 qf_ptr->qf_cleared ? _(" (line deleted)") : "", |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2466 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr)); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2467 /* Add the message, skipping leading whitespace and newlines. */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2468 len = (int)STRLEN(IObuff); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2469 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2470 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2471 /* Output the message. Overwrite to avoid scrolling when the 'O' |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2472 * flag is present in 'shortmess'; But when not jumping, print the |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2473 * whole message. */ |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2474 i = msg_scroll; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2475 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2476 msg_scroll = TRUE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2477 else if (!msg_scrolled && shortmess(SHM_OVERALL)) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2478 msg_scroll = FALSE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2479 msg_attr_keep(IObuff, 0, TRUE); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2480 msg_scroll = i; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2481 } |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2482 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2483 /* |
7 | 2484 * jump to a quickfix line |
2485 * if dir == FORWARD go "errornr" valid entries forward | |
2486 * if dir == BACKWARD go "errornr" valid entries backward | |
2487 * if dir == FORWARD_FILE go "errornr" valid entries files backward | |
2488 * if dir == BACKWARD_FILE go "errornr" valid entries files backward | |
2489 * else if "errornr" is zero, redisplay the same line | |
2490 * else go to entry "errornr" | |
2491 */ | |
2492 void | |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2493 qf_jump(qf_info_T *qi, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2494 int dir, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2495 int errornr, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2496 int forceit) |
7 | 2497 { |
230 | 2498 qfline_T *qf_ptr; |
2499 qfline_T *old_qf_ptr; | |
7 | 2500 int qf_index; |
2501 int old_qf_index; | |
2502 buf_T *old_curbuf; | |
2503 linenr_T old_lnum; | |
639 | 2504 char_u *old_swb = p_swb; |
1621 | 2505 unsigned old_swb_flags = swb_flags; |
7 | 2506 int opened_window = FALSE; |
1743 | 2507 win_T *oldwin = curwin; |
7 | 2508 int print_message = TRUE; |
2509 #ifdef FEAT_FOLDING | |
2510 int old_KeyTyped = KeyTyped; /* getting file may reset it */ | |
2511 #endif | |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2512 int retval = OK; |
644 | 2513 |
659 | 2514 if (qi == NULL) |
2515 qi = &ql_info; | |
644 | 2516 |
2517 if (qi->qf_curlist >= qi->qf_listcount | |
2518 || qi->qf_lists[qi->qf_curlist].qf_count == 0) | |
7 | 2519 { |
2520 EMSG(_(e_quickfix)); | |
2521 return; | |
2522 } | |
2523 | |
644 | 2524 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr; |
7 | 2525 old_qf_ptr = qf_ptr; |
644 | 2526 qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
7 | 2527 old_qf_index = qf_index; |
12465
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
2528 if (dir != 0) /* next/prev valid entry */ |
7 | 2529 { |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2530 qf_ptr = get_nth_valid_entry(qi, errornr, qf_ptr, &qf_index, dir); |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2531 if (qf_ptr == NULL) |
7 | 2532 { |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2533 qf_ptr = old_qf_ptr; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2534 qf_index = old_qf_index; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2535 goto theend; |
7 | 2536 } |
2537 } | |
2538 else if (errornr != 0) /* go to specified number */ | |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2539 qf_ptr = get_nth_entry(qi, errornr, qf_ptr, &qf_index); |
7 | 2540 |
644 | 2541 qi->qf_lists[qi->qf_curlist].qf_index = qf_index; |
2542 if (qf_win_pos_update(qi, old_qf_index)) | |
7 | 2543 /* No need to print the error message if it's visible in the error |
2544 * window */ | |
2545 print_message = FALSE; | |
2546 | |
2547 /* | |
9 | 2548 * For ":helpgrep" find a help window or open one. |
2549 */ | |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
2550 if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) || cmdmod.tab != 0)) |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2551 if (jump_to_help_window(qi, &opened_window) == FAIL) |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2552 goto theend; |
9 | 2553 |
2554 /* | |
7 | 2555 * If currently in the quickfix window, find another window to show the |
2556 * file in. | |
2557 */ | |
26 | 2558 if (bt_quickfix(curbuf) && !opened_window) |
7 | 2559 { |
2560 /* | |
2561 * If there is no file specified, we don't know where to go. | |
2562 * But do advance, otherwise ":cn" gets stuck. | |
2563 */ | |
2564 if (qf_ptr->qf_fnum == 0) | |
2565 goto theend; | |
2566 | |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2567 if (qf_jump_to_usable_window(qf_ptr->qf_fnum, &opened_window) == FAIL) |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2568 goto failed; |
7 | 2569 } |
2570 | |
2571 /* | |
2572 * If there is a file name, | |
2573 * read the wanted file if needed, and check autowrite etc. | |
2574 */ | |
2575 old_curbuf = curbuf; | |
2576 old_lnum = curwin->w_cursor.lnum; | |
9 | 2577 |
2578 if (qf_ptr->qf_fnum != 0) | |
2579 { | |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2580 int abort = FALSE; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2581 |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2582 retval = qf_jump_edit_buffer(qi, qf_ptr, forceit, oldwin, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2583 &opened_window, &abort); |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2584 if (abort) |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2585 { |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2586 qi = NULL; |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2587 qf_ptr = NULL; |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2588 } |
9 | 2589 } |
2590 | |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2591 if (retval == OK) |
7 | 2592 { |
2593 /* When not switched to another buffer, still need to set pc mark */ | |
2594 if (curbuf == old_curbuf) | |
2595 setpcmark(); | |
2596 | |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2597 qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol, |
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2598 qf_ptr->qf_pattern); |
7 | 2599 |
2600 #ifdef FEAT_FOLDING | |
2601 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped) | |
2602 foldOpenCursor(); | |
2603 #endif | |
2604 if (print_message) | |
12503
4d40b2644e92
patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2605 qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum); |
7 | 2606 } |
2607 else | |
2608 { | |
2609 if (opened_window) | |
2610 win_close(curwin, TRUE); /* Close opened window */ | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2611 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) |
7 | 2612 { |
2613 /* | |
2614 * Couldn't open file, so put index back where it was. This could | |
2615 * happen if the file was readonly and we changed something. | |
2616 */ | |
2617 failed: | |
2618 qf_ptr = old_qf_ptr; | |
2619 qf_index = old_qf_index; | |
2620 } | |
2621 } | |
2622 theend: | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2623 if (qi != NULL) |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2624 { |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2625 qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2626 qi->qf_lists[qi->qf_curlist].qf_index = qf_index; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2627 } |
7 | 2628 if (p_swb != old_swb && opened_window) |
2629 { | |
2630 /* Restore old 'switchbuf' value, but not when an autocommand or | |
2631 * modeline has changed the value. */ | |
2632 if (p_swb == empty_option) | |
1621 | 2633 { |
7 | 2634 p_swb = old_swb; |
1621 | 2635 swb_flags = old_swb_flags; |
2636 } | |
7 | 2637 else |
2638 free_string_option(old_swb); | |
2639 } | |
2640 } | |
2641 | |
2642 /* | |
2643 * ":clist": list all errors | |
644 | 2644 * ":llist": list all locations |
7 | 2645 */ |
2646 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2647 qf_list(exarg_T *eap) |
7 | 2648 { |
230 | 2649 buf_T *buf; |
2650 char_u *fname; | |
2651 qfline_T *qfp; | |
2652 int i; | |
2653 int idx1 = 1; | |
2654 int idx2 = -1; | |
2655 char_u *arg = eap->arg; | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2656 int plus = FALSE; |
230 | 2657 int all = eap->forceit; /* if not :cl!, only show |
7 | 2658 recognised errors */ |
644 | 2659 qf_info_T *qi = &ql_info; |
2660 | |
2661 if (eap->cmdidx == CMD_llist) | |
2662 { | |
2663 qi = GET_LOC_LIST(curwin); | |
2664 if (qi == NULL) | |
2665 { | |
2666 EMSG(_(e_loclist)); | |
2667 return; | |
2668 } | |
2669 } | |
2670 | |
2671 if (qi->qf_curlist >= qi->qf_listcount | |
2672 || qi->qf_lists[qi->qf_curlist].qf_count == 0) | |
7 | 2673 { |
2674 EMSG(_(e_quickfix)); | |
2675 return; | |
2676 } | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2677 if (*arg == '+') |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2678 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2679 ++arg; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2680 plus = TRUE; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2681 } |
7 | 2682 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) |
2683 { | |
2684 EMSG(_(e_trailing)); | |
2685 return; | |
2686 } | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2687 if (plus) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2688 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2689 i = qi->qf_lists[qi->qf_curlist].qf_index; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2690 idx2 = i + idx1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2691 idx1 = i; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2692 } |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2693 else |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2694 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2695 i = qi->qf_lists[qi->qf_curlist].qf_count; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2696 if (idx1 < 0) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2697 idx1 = (-idx1 > i) ? 0 : idx1 + i + 1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2698 if (idx2 < 0) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2699 idx2 = (-idx2 > i) ? 0 : idx2 + i + 1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2700 } |
7 | 2701 |
644 | 2702 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid) |
7 | 2703 all = TRUE; |
644 | 2704 qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
2705 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ) | |
7 | 2706 { |
2707 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2) | |
2708 { | |
2047
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2709 msg_putchar('\n'); |
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2710 if (got_int) |
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2711 break; |
446 | 2712 |
2713 fname = NULL; | |
2714 if (qfp->qf_fnum != 0 | |
7 | 2715 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) |
446 | 2716 { |
2717 fname = buf->b_fname; | |
2718 if (qfp->qf_type == 1) /* :helpgrep */ | |
2719 fname = gettail(fname); | |
2720 } | |
2721 if (fname == NULL) | |
2722 sprintf((char *)IObuff, "%2d", i); | |
2723 else | |
2724 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", | |
273 | 2725 i, (char *)fname); |
644 | 2726 msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index |
11516
80491a71c716
patch 8.0.0641: cannot set a separate highlighting for the quickfix line
Christian Brabandt <cb@256bit.org>
parents:
11502
diff
changeset
|
2727 ? HL_ATTR(HLF_QFL) : HL_ATTR(HLF_D)); |
446 | 2728 if (qfp->qf_lnum == 0) |
2729 IObuff[0] = NUL; | |
2730 else if (qfp->qf_col == 0) | |
2731 sprintf((char *)IObuff, ":%ld", qfp->qf_lnum); | |
2732 else | |
2733 sprintf((char *)IObuff, ":%ld col %d", | |
7 | 2734 qfp->qf_lnum, qfp->qf_col); |
446 | 2735 sprintf((char *)IObuff + STRLEN(IObuff), "%s:", |
7 | 2736 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
2737 msg_puts_attr(IObuff, HL_ATTR(HLF_N)); |
446 | 2738 if (qfp->qf_pattern != NULL) |
2739 { | |
2740 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE); | |
2741 STRCAT(IObuff, ":"); | |
2742 msg_puts(IObuff); | |
2743 } | |
2744 msg_puts((char_u *)" "); | |
230 | 2745 |
446 | 2746 /* Remove newlines and leading whitespace from the text. For an |
2747 * unrecognized line keep the indent, the compiler may mark a word | |
2748 * with ^^^^. */ | |
2749 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0) | |
7 | 2750 ? skipwhite(qfp->qf_text) : qfp->qf_text, |
2751 IObuff, IOSIZE); | |
446 | 2752 msg_prt_line(IObuff, FALSE); |
2753 out_flush(); /* show one line at a time */ | |
7 | 2754 } |
446 | 2755 |
2756 qfp = qfp->qf_next; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2757 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2758 break; |
446 | 2759 ++i; |
7 | 2760 ui_breakcheck(); |
2761 } | |
2762 } | |
2763 | |
2764 /* | |
2765 * Remove newlines and leading whitespace from an error message. | |
2766 * Put the result in "buf[bufsize]". | |
2767 */ | |
2768 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2769 qf_fmt_text(char_u *text, char_u *buf, int bufsize) |
7 | 2770 { |
2771 int i; | |
2772 char_u *p = text; | |
2773 | |
2774 for (i = 0; *p != NUL && i < bufsize - 1; ++i) | |
2775 { | |
2776 if (*p == '\n') | |
2777 { | |
2778 buf[i] = ' '; | |
2779 while (*++p != NUL) | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
2780 if (!VIM_ISWHITE(*p) && *p != '\n') |
7 | 2781 break; |
2782 } | |
2783 else | |
2784 buf[i] = *p++; | |
2785 } | |
2786 buf[i] = NUL; | |
2787 } | |
2788 | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2789 static void |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2790 qf_msg(qf_info_T *qi, int which, char *lead) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2791 { |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2792 char *title = (char *)qi->qf_lists[which].qf_title; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2793 int count = qi->qf_lists[which].qf_count; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2794 char_u buf[IOSIZE]; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2795 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2796 vim_snprintf((char *)buf, IOSIZE, _("%serror list %d of %d; %d errors "), |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2797 lead, |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2798 which + 1, |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2799 qi->qf_listcount, |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2800 count); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2801 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2802 if (title != NULL) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2803 { |
9579
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2804 size_t len = STRLEN(buf); |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2805 |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2806 if (len < 34) |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2807 { |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2808 vim_memset(buf + len, ' ', 34 - len); |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2809 buf[34] = NUL; |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2810 } |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2811 vim_strcat(buf, (char_u *)title, IOSIZE); |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2812 } |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2813 trunc_string(buf, buf, Columns - 1, IOSIZE); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2814 msg(buf); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2815 } |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2816 |
7 | 2817 /* |
2818 * ":colder [count]": Up in the quickfix stack. | |
2819 * ":cnewer [count]": Down in the quickfix stack. | |
644 | 2820 * ":lolder [count]": Up in the location list stack. |
2821 * ":lnewer [count]": Down in the location list stack. | |
7 | 2822 */ |
2823 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2824 qf_age(exarg_T *eap) |
7 | 2825 { |
644 | 2826 qf_info_T *qi = &ql_info; |
7 | 2827 int count; |
2828 | |
644 | 2829 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer) |
2830 { | |
2831 qi = GET_LOC_LIST(curwin); | |
2832 if (qi == NULL) | |
2833 { | |
2834 EMSG(_(e_loclist)); | |
2835 return; | |
2836 } | |
2837 } | |
2838 | |
7 | 2839 if (eap->addr_count != 0) |
2840 count = eap->line2; | |
2841 else | |
2842 count = 1; | |
2843 while (count--) | |
2844 { | |
644 | 2845 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder) |
7 | 2846 { |
644 | 2847 if (qi->qf_curlist == 0) |
7 | 2848 { |
2849 EMSG(_("E380: At bottom of quickfix stack")); | |
4371 | 2850 break; |
7 | 2851 } |
644 | 2852 --qi->qf_curlist; |
7 | 2853 } |
2854 else | |
2855 { | |
644 | 2856 if (qi->qf_curlist >= qi->qf_listcount - 1) |
7 | 2857 { |
2858 EMSG(_("E381: At top of quickfix stack")); | |
4371 | 2859 break; |
7 | 2860 } |
644 | 2861 ++qi->qf_curlist; |
7 | 2862 } |
2863 } | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2864 qf_msg(qi, qi->qf_curlist, ""); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2865 qf_update_buffer(qi, NULL); |
7 | 2866 } |
2867 | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2868 void |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2869 qf_history(exarg_T *eap) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2870 { |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2871 qf_info_T *qi = &ql_info; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2872 int i; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2873 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2874 if (eap->cmdidx == CMD_lhistory) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2875 qi = GET_LOC_LIST(curwin); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2876 if (qi == NULL || (qi->qf_listcount == 0 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2877 && qi->qf_lists[qi->qf_curlist].qf_count == 0)) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2878 MSG(_("No entries")); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2879 else |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2880 for (i = 0; i < qi->qf_listcount; ++i) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2881 qf_msg(qi, i, i == qi->qf_curlist ? "> " : " "); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2882 } |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2883 |
7 | 2884 /* |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2885 * Free all the entries in the error list "idx". Note that other information |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2886 * associated with the list like context and title are not freed. |
7 | 2887 */ |
2888 static void | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2889 qf_free_items(qf_info_T *qi, int idx) |
7 | 2890 { |
230 | 2891 qfline_T *qfp; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2892 qfline_T *qfpnext; |
3982 | 2893 int stop = FALSE; |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2894 qf_list_T *qfl = &qi->qf_lists[idx]; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2895 |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2896 while (qfl->qf_count && qfl->qf_start != NULL) |
7 | 2897 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2898 qfp = qfl->qf_start; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2899 qfpnext = qfp->qf_next; |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
2900 if (!stop) |
3949 | 2901 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2902 vim_free(qfp->qf_text); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2903 stop = (qfp == qfpnext); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2904 vim_free(qfp->qf_pattern); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2905 vim_free(qfp); |
3982 | 2906 if (stop) |
2907 /* Somehow qf_count may have an incorrect value, set it to 1 | |
2908 * to avoid crashing when it's wrong. | |
2909 * TODO: Avoid qf_count being incorrect. */ | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2910 qfl->qf_count = 1; |
3949 | 2911 } |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2912 qfl->qf_start = qfpnext; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2913 --qfl->qf_count; |
7 | 2914 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2915 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2916 qfl->qf_index = 0; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2917 qfl->qf_start = NULL; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2918 qfl->qf_last = NULL; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2919 qfl->qf_ptr = NULL; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2920 qfl->qf_nonevalid = TRUE; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2921 |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2922 qf_clean_dir_stack(&qfl->qf_dir_stack); |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2923 qfl->qf_directory = NULL; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2924 qf_clean_dir_stack(&qfl->qf_file_stack); |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2925 qfl->qf_currfile = NULL; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2926 qfl->qf_multiline = FALSE; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2927 qfl->qf_multiignore = FALSE; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2928 qfl->qf_multiscan = FALSE; |
7 | 2929 } |
2930 | |
2931 /* | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2932 * Free error list "idx". Frees all the entries in the quickfix list, |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2933 * associated context information and the title. |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2934 */ |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2935 static void |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2936 qf_free(qf_info_T *qi, int idx) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2937 { |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2938 qf_list_T *qfl = &qi->qf_lists[idx]; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2939 |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2940 qf_free_items(qi, idx); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2941 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2942 vim_free(qfl->qf_title); |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2943 qfl->qf_title = NULL; |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2944 free_tv(qfl->qf_ctx); |
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
2945 qfl->qf_ctx = NULL; |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
2946 qfl->qf_id = 0; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2947 } |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2948 |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2949 /* |
7 | 2950 * qf_mark_adjust: adjust marks |
2951 */ | |
2952 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2953 qf_mark_adjust( |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2954 win_T *wp, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2955 linenr_T line1, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2956 linenr_T line2, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2957 long amount, |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2958 long amount_after) |
7 | 2959 { |
230 | 2960 int i; |
2961 qfline_T *qfp; | |
2962 int idx; | |
644 | 2963 qf_info_T *qi = &ql_info; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2964 int found_one = FALSE; |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2965 int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2966 |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2967 if (!(curbuf->b_has_qf_entry & buf_has_flag)) |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2968 return; |
644 | 2969 if (wp != NULL) |
2970 { | |
2971 if (wp->w_llist == NULL) | |
2972 return; | |
2973 qi = wp->w_llist; | |
2974 } | |
2975 | |
2976 for (idx = 0; idx < qi->qf_listcount; ++idx) | |
2977 if (qi->qf_lists[idx].qf_count) | |
2978 for (i = 0, qfp = qi->qf_lists[idx].qf_start; | |
12449
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2979 i < qi->qf_lists[idx].qf_count && qfp != NULL; |
7a743053dfd6
patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents:
12427
diff
changeset
|
2980 ++i, qfp = qfp->qf_next) |
7 | 2981 if (qfp->qf_fnum == curbuf->b_fnum) |
2982 { | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2983 found_one = TRUE; |
7 | 2984 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) |
2985 { | |
2986 if (amount == MAXLNUM) | |
2987 qfp->qf_cleared = TRUE; | |
2988 else | |
2989 qfp->qf_lnum += amount; | |
2990 } | |
2991 else if (amount_after && qfp->qf_lnum > line2) | |
2992 qfp->qf_lnum += amount_after; | |
2993 } | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2994 |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2995 if (!found_one) |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2996 curbuf->b_has_qf_entry &= ~buf_has_flag; |
7 | 2997 } |
2998 | |
2999 /* | |
3000 * Make a nice message out of the error character and the error number: | |
3001 * char number message | |
3002 * e or E 0 " error" | |
3003 * w or W 0 " warning" | |
3004 * i or I 0 " info" | |
3005 * 0 0 "" | |
3006 * other 0 " c" | |
3007 * e or E n " error n" | |
3008 * w or W n " warning n" | |
3009 * i or I n " info n" | |
3010 * 0 n " error n" | |
3011 * other n " c n" | |
3012 * 1 x "" :helpgrep | |
3013 */ | |
3014 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3015 qf_types(int c, int nr) |
7 | 3016 { |
3017 static char_u buf[20]; | |
3018 static char_u cc[3]; | |
3019 char_u *p; | |
3020 | |
3021 if (c == 'W' || c == 'w') | |
3022 p = (char_u *)" warning"; | |
3023 else if (c == 'I' || c == 'i') | |
3024 p = (char_u *)" info"; | |
3025 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0)) | |
3026 p = (char_u *)" error"; | |
3027 else if (c == 0 || c == 1) | |
3028 p = (char_u *)""; | |
3029 else | |
3030 { | |
3031 cc[0] = ' '; | |
3032 cc[1] = c; | |
3033 cc[2] = NUL; | |
3034 p = cc; | |
3035 } | |
3036 | |
3037 if (nr <= 0) | |
3038 return p; | |
3039 | |
3040 sprintf((char *)buf, "%s %3d", (char *)p, nr); | |
3041 return buf; | |
3042 } | |
3043 | |
3044 /* | |
3045 * ":cwindow": open the quickfix window if we have errors to display, | |
3046 * close it if not. | |
644 | 3047 * ":lwindow": open the location list window if we have locations to display, |
3048 * close it if not. | |
7 | 3049 */ |
3050 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3051 ex_cwindow(exarg_T *eap) |
7 | 3052 { |
644 | 3053 qf_info_T *qi = &ql_info; |
7 | 3054 win_T *win; |
3055 | |
644 | 3056 if (eap->cmdidx == CMD_lwindow) |
3057 { | |
3058 qi = GET_LOC_LIST(curwin); | |
3059 if (qi == NULL) | |
3060 return; | |
3061 } | |
3062 | |
3063 /* Look for an existing quickfix window. */ | |
3064 win = qf_find_win(qi); | |
7 | 3065 |
3066 /* | |
3067 * If a quickfix window is open but we have no errors to display, | |
3068 * close the window. If a quickfix window is not open, then open | |
3069 * it if we have errors; otherwise, leave it closed. | |
3070 */ | |
644 | 3071 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid |
2795 | 3072 || qi->qf_lists[qi->qf_curlist].qf_count == 0 |
857 | 3073 || qi->qf_curlist >= qi->qf_listcount) |
7 | 3074 { |
3075 if (win != NULL) | |
3076 ex_cclose(eap); | |
3077 } | |
3078 else if (win == NULL) | |
3079 ex_copen(eap); | |
3080 } | |
3081 | |
3082 /* | |
3083 * ":cclose": close the window showing the list of errors. | |
644 | 3084 * ":lclose": close the window showing the location list |
7 | 3085 */ |
3086 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3087 ex_cclose(exarg_T *eap) |
7 | 3088 { |
644 | 3089 win_T *win = NULL; |
3090 qf_info_T *qi = &ql_info; | |
3091 | |
3092 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow) | |
3093 { | |
3094 qi = GET_LOC_LIST(curwin); | |
3095 if (qi == NULL) | |
3096 return; | |
3097 } | |
3098 | |
3099 /* Find existing quickfix window and close it. */ | |
3100 win = qf_find_win(qi); | |
7 | 3101 if (win != NULL) |
3102 win_close(win, FALSE); | |
3103 } | |
3104 | |
3105 /* | |
3106 * ":copen": open a window that shows the list of errors. | |
644 | 3107 * ":lopen": open a window that shows the location list. |
7 | 3108 */ |
3109 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3110 ex_copen(exarg_T *eap) |
7 | 3111 { |
644 | 3112 qf_info_T *qi = &ql_info; |
7 | 3113 int height; |
3114 win_T *win; | |
682 | 3115 tabpage_T *prevtab = curtab; |
859 | 3116 buf_T *qf_buf; |
1743 | 3117 win_T *oldwin = curwin; |
7 | 3118 |
644 | 3119 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
3120 { | |
3121 qi = GET_LOC_LIST(curwin); | |
3122 if (qi == NULL) | |
3123 { | |
3124 EMSG(_(e_loclist)); | |
3125 return; | |
3126 } | |
3127 } | |
3128 | |
7 | 3129 if (eap->addr_count != 0) |
3130 height = eap->line2; | |
3131 else | |
3132 height = QF_WINHEIGHT; | |
3133 | |
3134 reset_VIsual_and_resel(); /* stop Visual mode */ | |
3135 #ifdef FEAT_GUI | |
3136 need_mouse_correct = TRUE; | |
3137 #endif | |
3138 | |
3139 /* | |
3140 * Find existing quickfix window, or open a new one. | |
3141 */ | |
644 | 3142 win = qf_find_win(qi); |
3143 | |
682 | 3144 if (win != NULL && cmdmod.tab == 0) |
5753 | 3145 { |
7 | 3146 win_goto(win); |
5753 | 3147 if (eap->addr_count != 0) |
3148 { | |
3149 if (cmdmod.split & WSP_VERT) | |
3150 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12503
diff
changeset
|
3151 if (height != win->w_width) |
5753 | 3152 win_setwidth(height); |
3153 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8605
diff
changeset
|
3154 else if (height != win->w_height) |
5753 | 3155 win_setheight(height); |
3156 } | |
3157 } | |
7 | 3158 else |
3159 { | |
859 | 3160 qf_buf = qf_find_buf(qi); |
3161 | |
7 | 3162 /* The current window becomes the previous window afterwards. */ |
3163 win = curwin; | |
3164 | |
3939 | 3165 if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow) |
3166 && cmdmod.split == 0) | |
3167 /* Create the new window at the very bottom, except when | |
3168 * :belowright or :aboveleft is used. */ | |
644 | 3169 win_goto(lastwin); |
1822 | 3170 if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL) |
7 | 3171 return; /* not enough room for window */ |
2583 | 3172 RESET_BINDING(curwin); |
7 | 3173 |
644 | 3174 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
7 | 3175 { |
644 | 3176 /* |
3177 * For the location list window, create a reference to the | |
3178 * location list from the window 'win'. | |
3179 */ | |
3180 curwin->w_llist_ref = win->w_llist; | |
3181 win->w_llist->qf_refcount++; | |
7 | 3182 } |
644 | 3183 |
1743 | 3184 if (oldwin != curwin) |
3185 oldwin = NULL; /* don't store info when in another window */ | |
859 | 3186 if (qf_buf != NULL) |
3187 /* Use the existing quickfix buffer */ | |
3188 (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, | |
1743 | 3189 ECMD_HIDE + ECMD_OLDBUF, oldwin); |
859 | 3190 else |
3191 { | |
3192 /* Create a new quickfix buffer */ | |
1743 | 3193 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin); |
859 | 3194 /* switch off 'swapfile' */ |
3195 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); | |
3196 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", | |
729 | 3197 OPT_LOCAL); |
859 | 3198 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); |
2651 | 3199 RESET_BINDING(curwin); |
1864 | 3200 #ifdef FEAT_DIFF |
3201 curwin->w_p_diff = FALSE; | |
3202 #endif | |
3203 #ifdef FEAT_FOLDING | |
3204 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual", | |
3205 OPT_LOCAL); | |
3206 #endif | |
859 | 3207 } |
7 | 3208 |
682 | 3209 /* Only set the height when still in the same tab page and there is no |
3210 * window to the side. */ | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8605
diff
changeset
|
3211 if (curtab == prevtab && curwin->w_width == Columns) |
7 | 3212 win_setheight(height); |
3213 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */ | |
3214 if (win_valid(win)) | |
3215 prevwin = win; | |
3216 } | |
3217 | |
6793 | 3218 qf_set_title_var(qi); |
3219 | |
7 | 3220 /* |
3221 * Fill the buffer with the quickfix list. | |
3222 */ | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3223 qf_fill_buffer(qi, curbuf, NULL); |
644 | 3224 |
3225 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; | |
7 | 3226 curwin->w_cursor.col = 0; |
3227 check_cursor(); | |
3228 update_topline(); /* scroll to show the line */ | |
3229 } | |
3230 | |
3231 /* | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3232 * Move the cursor in the quickfix window to "lnum". |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3233 */ |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3234 static void |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3235 qf_win_goto(win_T *win, linenr_T lnum) |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3236 { |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3237 win_T *old_curwin = curwin; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3238 |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3239 curwin = win; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3240 curbuf = win->w_buffer; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3241 curwin->w_cursor.lnum = lnum; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3242 curwin->w_cursor.col = 0; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3243 #ifdef FEAT_VIRTUALEDIT |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3244 curwin->w_cursor.coladd = 0; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3245 #endif |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3246 curwin->w_curswant = 0; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3247 update_topline(); /* scroll to show the line */ |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3248 redraw_later(VALID); |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3249 curwin->w_redr_status = TRUE; /* update ruler */ |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3250 curwin = old_curwin; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3251 curbuf = curwin->w_buffer; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3252 } |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3253 |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3254 /* |
9458
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3255 * :cbottom/:lbottom commands. |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3256 */ |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3257 void |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3258 ex_cbottom(exarg_T *eap UNUSED) |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3259 { |
9458
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3260 qf_info_T *qi = &ql_info; |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3261 win_T *win; |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3262 |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3263 if (eap->cmdidx == CMD_lbottom) |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3264 { |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3265 qi = GET_LOC_LIST(curwin); |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3266 if (qi == NULL) |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3267 { |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3268 EMSG(_(e_loclist)); |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3269 return; |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3270 } |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3271 } |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3272 |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3273 win = qf_find_win(qi); |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3274 if (win != NULL && win->w_cursor.lnum != win->w_buffer->b_ml.ml_line_count) |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3275 qf_win_goto(win, win->w_buffer->b_ml.ml_line_count); |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3276 } |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3277 |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3278 /* |
7 | 3279 * Return the number of the current entry (line number in the quickfix |
3280 * window). | |
3281 */ | |
3282 linenr_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3283 qf_current_entry(win_T *wp) |
7 | 3284 { |
644 | 3285 qf_info_T *qi = &ql_info; |
3286 | |
3287 if (IS_LL_WINDOW(wp)) | |
3288 /* In the location list window, use the referenced location list */ | |
3289 qi = wp->w_llist_ref; | |
3290 | |
3291 return qi->qf_lists[qi->qf_curlist].qf_index; | |
7 | 3292 } |
3293 | |
3294 /* | |
3295 * Update the cursor position in the quickfix window to the current error. | |
3296 * Return TRUE if there is a quickfix window. | |
3297 */ | |
3298 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3299 qf_win_pos_update( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3300 qf_info_T *qi, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3301 int old_qf_index) /* previous qf_index or zero */ |
7 | 3302 { |
3303 win_T *win; | |
644 | 3304 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
7 | 3305 |
3306 /* | |
3307 * Put the cursor on the current error in the quickfix window, so that | |
3308 * it's viewable. | |
3309 */ | |
644 | 3310 win = qf_find_win(qi); |
7 | 3311 if (win != NULL |
3312 && qf_index <= win->w_buffer->b_ml.ml_line_count | |
3313 && old_qf_index != qf_index) | |
3314 { | |
3315 if (qf_index > old_qf_index) | |
3316 { | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3317 win->w_redraw_top = old_qf_index; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3318 win->w_redraw_bot = qf_index; |
7 | 3319 } |
3320 else | |
3321 { | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3322 win->w_redraw_top = qf_index; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3323 win->w_redraw_bot = old_qf_index; |
7 | 3324 } |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3325 qf_win_goto(win, qf_index); |
7 | 3326 } |
3327 return win != NULL; | |
3328 } | |
3329 | |
3330 /* | |
859 | 3331 * Check whether the given window is displaying the specified quickfix/location |
3332 * list buffer | |
3333 */ | |
3334 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3335 is_qf_win(win_T *win, qf_info_T *qi) |
859 | 3336 { |
3337 /* | |
3338 * A window displaying the quickfix buffer will have the w_llist_ref field | |
3339 * set to NULL. | |
3340 * A window displaying a location list buffer will have the w_llist_ref | |
3341 * pointing to the location list. | |
3342 */ | |
3343 if (bt_quickfix(win->w_buffer)) | |
3344 if ((qi == &ql_info && win->w_llist_ref == NULL) | |
3345 || (qi != &ql_info && win->w_llist_ref == qi)) | |
3346 return TRUE; | |
3347 | |
3348 return FALSE; | |
3349 } | |
3350 | |
3351 /* | |
644 | 3352 * Find a window displaying the quickfix/location list 'qi' |
859 | 3353 * Searches in only the windows opened in the current tab. |
644 | 3354 */ |
3355 static win_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3356 qf_find_win(qf_info_T *qi) |
644 | 3357 { |
3358 win_T *win; | |
3359 | |
3360 FOR_ALL_WINDOWS(win) | |
859 | 3361 if (is_qf_win(win, qi)) |
3362 break; | |
644 | 3363 |
3364 return win; | |
3365 } | |
3366 | |
3367 /* | |
859 | 3368 * Find a quickfix buffer. |
3369 * Searches in windows opened in all the tabs. | |
7 | 3370 */ |
3371 static buf_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3372 qf_find_buf(qf_info_T *qi) |
7 | 3373 { |
859 | 3374 tabpage_T *tp; |
644 | 3375 win_T *win; |
3376 | |
859 | 3377 FOR_ALL_TAB_WINDOWS(tp, win) |
3378 if (is_qf_win(win, qi)) | |
3379 return win->w_buffer; | |
3380 | |
3381 return NULL; | |
7 | 3382 } |
3383 | |
3384 /* | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3385 * Update the w:quickfix_title variable in the quickfix/location list window |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3386 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3387 static void |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3388 qf_update_win_titlevar(qf_info_T *qi) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3389 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3390 win_T *win; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3391 win_T *curwin_save; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3392 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3393 if ((win = qf_find_win(qi)) != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3394 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3395 curwin_save = curwin; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3396 curwin = win; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3397 qf_set_title_var(qi); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3398 curwin = curwin_save; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3399 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3400 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3401 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3402 /* |
7 | 3403 * Find the quickfix buffer. If it exists, update the contents. |
3404 */ | |
3405 static void | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3406 qf_update_buffer(qf_info_T *qi, qfline_T *old_last) |
7 | 3407 { |
3408 buf_T *buf; | |
3016 | 3409 win_T *win; |
7 | 3410 aco_save_T aco; |
3411 | |
3412 /* Check if a buffer for the quickfix list exists. Update it. */ | |
644 | 3413 buf = qf_find_buf(qi); |
7 | 3414 if (buf != NULL) |
3415 { | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3416 linenr_T old_line_count = buf->b_ml.ml_line_count; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3417 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3418 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3419 /* set curwin/curbuf to buf and save a few things */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3420 aucmd_prepbuf(&aco, buf); |
7 | 3421 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3422 qf_update_win_titlevar(qi); |
3016 | 3423 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3424 qf_fill_buffer(qi, buf, old_last); |
11705
c43118ecb0a3
patch 8.0.0735: no indication that the quickfix window/buffer changed
Christian Brabandt <cb@256bit.org>
parents:
11700
diff
changeset
|
3425 ++CHANGEDTICK(buf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3426 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3427 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3428 { |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
3429 (void)qf_win_pos_update(qi, 0); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3430 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3431 /* restore curwin/curbuf and a few other things */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3432 aucmd_restbuf(&aco); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3433 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3434 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3435 /* Only redraw when added lines are visible. This avoids flickering |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3436 * when the added lines are not visible. */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3437 if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3438 redraw_buf_later(buf, NOT_VALID); |
7 | 3439 } |
3440 } | |
3441 | |
6793 | 3442 /* |
3443 * Set "w:quickfix_title" if "qi" has a title. | |
3444 */ | |
3016 | 3445 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3446 qf_set_title_var(qf_info_T *qi) |
3016 | 3447 { |
6793 | 3448 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) |
3449 set_internal_string_var((char_u *)"w:quickfix_title", | |
3016 | 3450 qi->qf_lists[qi->qf_curlist].qf_title); |
3451 } | |
3452 | |
7 | 3453 /* |
3454 * Fill current buffer with quickfix errors, replacing any previous contents. | |
3455 * curbuf must be the quickfix buffer! | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3456 * If "old_last" is not NULL append the items after this one. |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3457 * When "old_last" is NULL then "buf" must equal "curbuf"! Because |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3458 * ml_delete() is used and autocommands will be triggered. |
7 | 3459 */ |
3460 static void | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3461 qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) |
7 | 3462 { |
230 | 3463 linenr_T lnum; |
3464 qfline_T *qfp; | |
3465 buf_T *errbuf; | |
3466 int len; | |
3467 int old_KeyTyped = KeyTyped; | |
7 | 3468 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3469 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3470 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3471 if (buf != curbuf) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3472 { |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
3473 internal_error("qf_fill_buffer()"); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3474 return; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3475 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3476 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3477 /* delete all existing lines */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3478 while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3479 (void)ml_delete((linenr_T)1, FALSE); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3480 } |
7 | 3481 |
3482 /* Check if there is anything to display */ | |
644 | 3483 if (qi->qf_curlist < qi->qf_listcount) |
7 | 3484 { |
3485 /* Add one line for each error */ | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3486 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3487 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3488 qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3489 lnum = 0; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3490 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3491 else |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3492 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3493 qfp = old_last->qf_next; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3494 lnum = buf->b_ml.ml_line_count; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3495 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3496 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count) |
7 | 3497 { |
3498 if (qfp->qf_fnum != 0 | |
3499 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL | |
3500 && errbuf->b_fname != NULL) | |
3501 { | |
3502 if (qfp->qf_type == 1) /* :helpgrep */ | |
3503 STRCPY(IObuff, gettail(errbuf->b_fname)); | |
3504 else | |
3505 STRCPY(IObuff, errbuf->b_fname); | |
3506 len = (int)STRLEN(IObuff); | |
3507 } | |
3508 else | |
3509 len = 0; | |
3510 IObuff[len++] = '|'; | |
3511 | |
3512 if (qfp->qf_lnum > 0) | |
3513 { | |
3514 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum); | |
3515 len += (int)STRLEN(IObuff + len); | |
3516 | |
3517 if (qfp->qf_col > 0) | |
3518 { | |
3519 sprintf((char *)IObuff + len, " col %d", qfp->qf_col); | |
3520 len += (int)STRLEN(IObuff + len); | |
3521 } | |
3522 | |
3523 sprintf((char *)IObuff + len, "%s", | |
3524 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); | |
3525 len += (int)STRLEN(IObuff + len); | |
3526 } | |
230 | 3527 else if (qfp->qf_pattern != NULL) |
3528 { | |
3529 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); | |
3530 len += (int)STRLEN(IObuff + len); | |
3531 } | |
7 | 3532 IObuff[len++] = '|'; |
3533 IObuff[len++] = ' '; | |
3534 | |
3535 /* Remove newlines and leading whitespace from the text. | |
3536 * For an unrecognized line keep the indent, the compiler may | |
3537 * mark a word with ^^^^. */ | |
3538 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, | |
3539 IObuff + len, IOSIZE - len); | |
3540 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3541 if (ml_append_buf(buf, lnum, IObuff, |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3542 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL) |
7 | 3543 break; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3544 ++lnum; |
7 | 3545 qfp = qfp->qf_next; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3546 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3547 break; |
7 | 3548 } |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3549 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3550 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3551 /* Delete the empty line which is now at the end */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3552 (void)ml_delete(lnum + 1, FALSE); |
7 | 3553 } |
3554 | |
3555 /* correct cursor position */ | |
3556 check_lnums(TRUE); | |
3557 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3558 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3559 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3560 /* Set the 'filetype' to "qf" each time after filling the buffer. |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3561 * This resembles reading a file into a buffer, it's more logical when |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3562 * using autocommands. */ |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3563 #ifdef FEAT_AUTOCMD |
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3564 ++curbuf_lock; |
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3565 #endif |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3566 set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3567 curbuf->b_p_ma = FALSE; |
7 | 3568 |
3569 #ifdef FEAT_AUTOCMD | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3570 keep_filetype = TRUE; /* don't detect 'filetype' */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3571 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, |
7 | 3572 FALSE, curbuf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3573 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL, |
7 | 3574 FALSE, curbuf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3575 keep_filetype = FALSE; |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3576 --curbuf_lock; |
7 | 3577 #endif |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3578 /* make sure it will be redrawn */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3579 redraw_curbuf_later(NOT_VALID); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3580 } |
7 | 3581 |
3582 /* Restore KeyTyped, setting 'filetype' may reset it. */ | |
3583 KeyTyped = old_KeyTyped; | |
3584 } | |
3585 | |
3586 /* | |
41 | 3587 * Return TRUE when using ":vimgrep" for ":grep". |
3588 */ | |
3589 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3590 grep_internal(cmdidx_T cmdidx) |
41 | 3591 { |
661 | 3592 return ((cmdidx == CMD_grep |
3593 || cmdidx == CMD_lgrep | |
3594 || cmdidx == CMD_grepadd | |
3595 || cmdidx == CMD_lgrepadd) | |
41 | 3596 && STRCMP("internal", |
3597 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0); | |
3598 } | |
3599 | |
3600 /* | |
657 | 3601 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd" |
7 | 3602 */ |
3603 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3604 ex_make(exarg_T *eap) |
7 | 3605 { |
161 | 3606 char_u *fname; |
7 | 3607 char_u *cmd; |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
3608 char_u *enc = NULL; |
7 | 3609 unsigned len; |
657 | 3610 win_T *wp = NULL; |
659 | 3611 qf_info_T *qi = &ql_info; |
842 | 3612 int res; |
161 | 3613 #ifdef FEAT_AUTOCMD |
3614 char_u *au_name = NULL; | |
3615 | |
2782 | 3616 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */ |
3617 if (grep_internal(eap->cmdidx)) | |
3618 { | |
3619 ex_vimgrep(eap); | |
3620 return; | |
3621 } | |
3622 | |
161 | 3623 switch (eap->cmdidx) |
3624 { | |
661 | 3625 case CMD_make: au_name = (char_u *)"make"; break; |
3626 case CMD_lmake: au_name = (char_u *)"lmake"; break; | |
3627 case CMD_grep: au_name = (char_u *)"grep"; break; | |
3628 case CMD_lgrep: au_name = (char_u *)"lgrep"; break; | |
3629 case CMD_grepadd: au_name = (char_u *)"grepadd"; break; | |
3630 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break; | |
161 | 3631 default: break; |
3632 } | |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
3633 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
3634 curbuf->b_fname, TRUE, curbuf)) |
161 | 3635 { |
532 | 3636 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
3637 if (aborting()) |
161 | 3638 return; |
532 | 3639 # endif |
161 | 3640 } |
3641 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
3642 #ifdef FEAT_MBYTE |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
3643 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
3644 #endif |
7 | 3645 |
657 | 3646 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep |
3647 || eap->cmdidx == CMD_lgrepadd) | |
3648 wp = curwin; | |
3649 | |
7 | 3650 autowrite_all(); |
161 | 3651 fname = get_mef_name(); |
3652 if (fname == NULL) | |
7 | 3653 return; |
161 | 3654 mch_remove(fname); /* in case it's not unique */ |
7 | 3655 |
3656 /* | |
3657 * If 'shellpipe' empty: don't redirect to 'errorfile'. | |
3658 */ | |
3659 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1; | |
3660 if (*p_sp != NUL) | |
161 | 3661 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3; |
7 | 3662 cmd = alloc(len); |
3663 if (cmd == NULL) | |
3664 return; | |
3665 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg, | |
3666 (char *)p_shq); | |
3667 if (*p_sp != NUL) | |
1872 | 3668 append_redir(cmd, len, p_sp, fname); |
7 | 3669 /* |
3670 * Output a newline if there's something else than the :make command that | |
3671 * was typed (in which case the cursor is in column 0). | |
3672 */ | |
3673 if (msg_col == 0) | |
3674 msg_didout = FALSE; | |
3675 msg_start(); | |
3676 MSG_PUTS(":!"); | |
3677 msg_outtrans(cmd); /* show what we are doing */ | |
3678 | |
3679 /* let the shell know if we are redirecting output or not */ | |
3680 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0); | |
3681 | |
3682 #ifdef AMIGA | |
3683 out_flush(); | |
3684 /* read window status report and redraw before message */ | |
3685 (void)char_avail(); | |
3686 #endif | |
3687 | |
842 | 3688 res = qf_init(wp, fname, (eap->cmdidx != CMD_make |
657 | 3689 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, |
3690 (eap->cmdidx != CMD_grepadd | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
3691 && eap->cmdidx != CMD_lgrepadd), |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
3692 *eap->cmdlinep, enc); |
2847 | 3693 if (wp != NULL) |
3694 qi = GET_LOC_LIST(wp); | |
842 | 3695 #ifdef FEAT_AUTOCMD |
3696 if (au_name != NULL) | |
2847 | 3697 { |
842 | 3698 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
3699 curbuf->b_fname, TRUE, curbuf); | |
2847 | 3700 if (qi->qf_curlist < qi->qf_listcount) |
3701 res = qi->qf_lists[qi->qf_curlist].qf_count; | |
3702 else | |
3703 res = 0; | |
3704 } | |
842 | 3705 #endif |
3706 if (res > 0 && !eap->forceit) | |
659 | 3707 qf_jump(qi, 0, 0, FALSE); /* display first error */ |
7 | 3708 |
161 | 3709 mch_remove(fname); |
3710 vim_free(fname); | |
7 | 3711 vim_free(cmd); |
3712 } | |
3713 | |
3714 /* | |
3715 * Return the name for the errorfile, in allocated memory. | |
3716 * Find a new unique name when 'makeef' contains "##". | |
3717 * Returns NULL for error. | |
3718 */ | |
3719 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3720 get_mef_name(void) |
7 | 3721 { |
3722 char_u *p; | |
3723 char_u *name; | |
3724 static int start = -1; | |
3725 static int off = 0; | |
3726 #ifdef HAVE_LSTAT | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
3727 stat_T sb; |
7 | 3728 #endif |
3729 | |
3730 if (*p_mef == NUL) | |
3731 { | |
6721 | 3732 name = vim_tempname('e', FALSE); |
7 | 3733 if (name == NULL) |
3734 EMSG(_(e_notmp)); | |
3735 return name; | |
3736 } | |
3737 | |
3738 for (p = p_mef; *p; ++p) | |
3739 if (p[0] == '#' && p[1] == '#') | |
3740 break; | |
3741 | |
3742 if (*p == NUL) | |
3743 return vim_strsave(p_mef); | |
3744 | |
3745 /* Keep trying until the name doesn't exist yet. */ | |
3746 for (;;) | |
3747 { | |
3748 if (start == -1) | |
3749 start = mch_get_pid(); | |
3750 else | |
3751 off += 19; | |
3752 | |
3753 name = alloc((unsigned)STRLEN(p_mef) + 30); | |
3754 if (name == NULL) | |
3755 break; | |
3756 STRCPY(name, p_mef); | |
3757 sprintf((char *)name + (p - p_mef), "%d%d", start, off); | |
3758 STRCAT(name, p + 2); | |
3759 if (mch_getperm(name) < 0 | |
3760 #ifdef HAVE_LSTAT | |
10226
7a4fb555c83a
commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents:
10056
diff
changeset
|
3761 /* Don't accept a symbolic link, it's a security risk. */ |
7 | 3762 && mch_lstat((char *)name, &sb) < 0 |
3763 #endif | |
3764 ) | |
3765 break; | |
3766 vim_free(name); | |
3767 } | |
3768 return name; | |
3769 } | |
3770 | |
3771 /* | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3772 * Returns the number of valid entries in the current quickfix/location list. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3773 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3774 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3775 qf_get_size(exarg_T *eap) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3776 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3777 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3778 qfline_T *qfp; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3779 int i, sz = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3780 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3781 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3782 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3783 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3784 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3785 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3786 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3787 return 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3788 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3789 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3790 for (i = 0, qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3791 i < qi->qf_lists[qi->qf_curlist].qf_count && qfp != NULL; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3792 ++i, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3793 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3794 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3795 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3796 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3797 sz++; /* Count all valid entries */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3798 else if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3799 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3800 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3801 sz++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3802 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3803 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3804 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3805 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3806 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3807 return sz; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3808 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3809 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3810 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3811 * Returns the current index of the quickfix/location list. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3812 * Returns 0 if there is an error. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3813 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3814 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3815 qf_get_cur_idx(exarg_T *eap) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3816 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3817 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3818 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3819 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3820 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3821 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3822 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3823 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3824 return 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3825 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3826 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3827 return qi->qf_lists[qi->qf_curlist].qf_index; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3828 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3829 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3830 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3831 * Returns the current index in the quickfix/location list (counting only valid |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3832 * entries). If no valid entries are in the list, then returns 1. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3833 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3834 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3835 qf_get_cur_valid_idx(exarg_T *eap) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3836 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3837 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3838 qf_list_T *qfl; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3839 qfline_T *qfp; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3840 int i, eidx = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3841 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3842 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3843 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3844 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3845 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3846 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3847 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3848 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3849 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3850 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3851 qfl = &qi->qf_lists[qi->qf_curlist]; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3852 qfp = qfl->qf_start; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3853 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3854 /* check if the list has valid errors */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3855 if (qfl->qf_count <= 0 || qfl->qf_nonevalid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3856 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3857 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3858 for (i = 1; i <= qfl->qf_index && qfp!= NULL; i++, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3859 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3860 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3861 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3862 if (eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3863 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3864 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3865 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3866 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3867 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3868 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3869 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3870 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3871 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3872 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3873 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3874 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3875 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3876 return eidx ? eidx : 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3877 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3878 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3879 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3880 * Get the 'n'th valid error entry in the quickfix or location list. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3881 * Used by :cdo, :ldo, :cfdo and :lfdo commands. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3882 * For :cdo and :ldo returns the 'n'th valid error entry. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3883 * For :cfdo and :lfdo returns the 'n'th valid file entry. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3884 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3885 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3886 qf_get_nth_valid_entry(qf_info_T *qi, int n, int fdo) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3887 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3888 qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist]; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3889 qfline_T *qfp = qfl->qf_start; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3890 int i, eidx; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3891 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3892 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3893 /* check if the list has valid errors */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3894 if (qfl->qf_count <= 0 || qfl->qf_nonevalid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3895 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3896 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3897 for (i = 1, eidx = 0; i <= qfl->qf_count && qfp != NULL; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3898 i++, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3899 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3900 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3901 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3902 if (fdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3903 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3904 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3905 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3906 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3907 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3908 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3909 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3910 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3911 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3912 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3913 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3914 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3915 if (eidx == n) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3916 break; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3917 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3918 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3919 if (i <= qfl->qf_count) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3920 return i; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3921 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3922 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3923 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3924 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3925 /* |
7 | 3926 * ":cc", ":crewind", ":cfirst" and ":clast". |
644 | 3927 * ":ll", ":lrewind", ":lfirst" and ":llast". |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3928 * ":cdo", ":ldo", ":cfdo" and ":lfdo" |
7 | 3929 */ |
3930 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3931 ex_cc(exarg_T *eap) |
7 | 3932 { |
659 | 3933 qf_info_T *qi = &ql_info; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3934 int errornr; |
659 | 3935 |
3936 if (eap->cmdidx == CMD_ll | |
3937 || eap->cmdidx == CMD_lrewind | |
3938 || eap->cmdidx == CMD_lfirst | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3939 || eap->cmdidx == CMD_llast |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3940 || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3941 || eap->cmdidx == CMD_lfdo) |
644 | 3942 { |
3943 qi = GET_LOC_LIST(curwin); | |
3944 if (qi == NULL) | |
3945 { | |
3946 EMSG(_(e_loclist)); | |
3947 return; | |
3948 } | |
3949 } | |
3950 | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3951 if (eap->addr_count > 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3952 errornr = (int)eap->line2; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3953 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3954 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3955 if (eap->cmdidx == CMD_cc || eap->cmdidx == CMD_ll) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3956 errornr = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3957 else if (eap->cmdidx == CMD_crewind || eap->cmdidx == CMD_lrewind |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3958 || eap->cmdidx == CMD_cfirst || eap->cmdidx == CMD_lfirst) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3959 errornr = 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3960 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3961 errornr = 32767; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3962 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3963 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3964 /* For cdo and ldo commands, jump to the nth valid error. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3965 * For cfdo and lfdo commands, jump to the nth valid file entry. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3966 */ |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
3967 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
3968 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3969 errornr = qf_get_nth_valid_entry(qi, |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3970 eap->addr_count > 0 ? (int)eap->line1 : 1, |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3971 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3972 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3973 qf_jump(qi, 0, errornr, eap->forceit); |
7 | 3974 } |
3975 | |
3976 /* | |
3977 * ":cnext", ":cnfile", ":cNext" and ":cprevious". | |
644 | 3978 * ":lnext", ":lNext", ":lprevious", ":lnfile", ":lNfile" and ":lpfile". |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3979 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands. |
7 | 3980 */ |
3981 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3982 ex_cnext(exarg_T *eap) |
7 | 3983 { |
659 | 3984 qf_info_T *qi = &ql_info; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3985 int errornr; |
659 | 3986 |
3987 if (eap->cmdidx == CMD_lnext | |
3988 || eap->cmdidx == CMD_lNext | |
3989 || eap->cmdidx == CMD_lprevious | |
3990 || eap->cmdidx == CMD_lnfile | |
3991 || eap->cmdidx == CMD_lNfile | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3992 || eap->cmdidx == CMD_lpfile |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3993 || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3994 || eap->cmdidx == CMD_lfdo) |
644 | 3995 { |
3996 qi = GET_LOC_LIST(curwin); | |
3997 if (qi == NULL) | |
3998 { | |
3999 EMSG(_(e_loclist)); | |
4000 return; | |
4001 } | |
4002 } | |
4003 | |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4004 if (eap->addr_count > 0 |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4005 && (eap->cmdidx != CMD_cdo && eap->cmdidx != CMD_ldo |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4006 && eap->cmdidx != CMD_cfdo && eap->cmdidx != CMD_lfdo)) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4007 errornr = (int)eap->line2; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4008 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4009 errornr = 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4010 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4011 qf_jump(qi, (eap->cmdidx == CMD_cnext || eap->cmdidx == CMD_lnext |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4012 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
7 | 4013 ? FORWARD |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4014 : (eap->cmdidx == CMD_cnfile || eap->cmdidx == CMD_lnfile |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4015 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
7 | 4016 ? FORWARD_FILE |
644 | 4017 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile |
4018 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile) | |
7 | 4019 ? BACKWARD_FILE |
4020 : BACKWARD, | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
4021 errornr, eap->forceit); |
7 | 4022 } |
4023 | |
4024 /* | |
446 | 4025 * ":cfile"/":cgetfile"/":caddfile" commands. |
644 | 4026 * ":lfile"/":lgetfile"/":laddfile" commands. |
7 | 4027 */ |
4028 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4029 ex_cfile(exarg_T *eap) |
7 | 4030 { |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
4031 char_u *enc = NULL; |
644 | 4032 win_T *wp = NULL; |
659 | 4033 qf_info_T *qi = &ql_info; |
3404 | 4034 #ifdef FEAT_AUTOCMD |
4035 char_u *au_name = NULL; | |
4036 #endif | |
644 | 4037 |
4038 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile | |
3404 | 4039 || eap->cmdidx == CMD_laddfile) |
644 | 4040 wp = curwin; |
4041 | |
3404 | 4042 #ifdef FEAT_AUTOCMD |
4043 switch (eap->cmdidx) | |
4044 { | |
4045 case CMD_cfile: au_name = (char_u *)"cfile"; break; | |
4046 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break; | |
4047 case CMD_caddfile: au_name = (char_u *)"caddfile"; break; | |
4048 case CMD_lfile: au_name = (char_u *)"lfile"; break; | |
4049 case CMD_lgetfile: au_name = (char_u *)"lgetfile"; break; | |
4050 case CMD_laddfile: au_name = (char_u *)"laddfile"; break; | |
4051 default: break; | |
4052 } | |
4053 if (au_name != NULL) | |
4054 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); | |
4055 #endif | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
4056 #ifdef FEAT_MBYTE |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
4057 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
4058 #endif |
2296
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4059 #ifdef FEAT_BROWSE |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4060 if (cmdmod.browse) |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4061 { |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4062 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg, |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4063 NULL, NULL, BROWSE_FILTER_ALL_FILES, NULL); |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4064 if (browse_file == NULL) |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4065 return; |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4066 set_string_option_direct((char_u *)"ef", -1, browse_file, OPT_FREE, 0); |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4067 vim_free(browse_file); |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4068 } |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4069 else |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
4070 #endif |
7 | 4071 if (*eap->arg != NUL) |
694 | 4072 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); |
446 | 4073 |
4074 /* | |
4075 * This function is used by the :cfile, :cgetfile and :caddfile | |
4076 * commands. | |
4077 * :cfile always creates a new quickfix list and jumps to the | |
4078 * first error. | |
4079 * :cgetfile creates a new quickfix list but doesn't jump to the | |
4080 * first error. | |
4081 * :caddfile adds to an existing quickfix list. If there is no | |
4082 * quickfix list then a new list is created. | |
4083 */ | |
644 | 4084 if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4085 && eap->cmdidx != CMD_laddfile), |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
4086 *eap->cmdlinep, enc) > 0 |
644 | 4087 && (eap->cmdidx == CMD_cfile |
4088 || eap->cmdidx == CMD_lfile)) | |
665 | 4089 { |
3404 | 4090 #ifdef FEAT_AUTOCMD |
4091 if (au_name != NULL) | |
4092 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | |
4093 #endif | |
665 | 4094 if (wp != NULL) |
4095 qi = GET_LOC_LIST(wp); | |
659 | 4096 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
665 | 4097 } |
3404 | 4098 |
4099 else | |
4100 { | |
4101 #ifdef FEAT_AUTOCMD | |
4102 if (au_name != NULL) | |
4103 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | |
4104 #endif | |
4105 } | |
7 | 4106 } |
4107 | |
4108 /* | |
41 | 4109 * ":vimgrep {pattern} file(s)" |
657 | 4110 * ":vimgrepadd {pattern} file(s)" |
4111 * ":lvimgrep {pattern} file(s)" | |
4112 * ":lvimgrepadd {pattern} file(s)" | |
41 | 4113 */ |
4114 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4115 ex_vimgrep(exarg_T *eap) |
41 | 4116 { |
42 | 4117 regmmatch_T regmatch; |
153 | 4118 int fcount; |
41 | 4119 char_u **fnames; |
1411 | 4120 char_u *fname; |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4121 char_u *title; |
153 | 4122 char_u *s; |
4123 char_u *p; | |
4124 int fi; | |
657 | 4125 qf_info_T *qi = &ql_info; |
4003 | 4126 #ifdef FEAT_AUTOCMD |
4127 qfline_T *cur_qf_start; | |
4128 #endif | |
41 | 4129 long lnum; |
42 | 4130 buf_T *buf; |
4131 int duplicate_name = FALSE; | |
4132 int using_dummy; | |
1396 | 4133 int redraw_for_dummy = FALSE; |
42 | 4134 int found_match; |
123 | 4135 buf_T *first_match_buf = NULL; |
4136 time_t seconds = 0; | |
677 | 4137 int save_mls; |
123 | 4138 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
4139 char_u *save_ei = NULL; | |
677 | 4140 #endif |
123 | 4141 aco_save_T aco; |
170 | 4142 int flags = 0; |
4143 colnr_T col; | |
716 | 4144 long tomatch; |
2770 | 4145 char_u *dirname_start = NULL; |
4146 char_u *dirname_now = NULL; | |
1411 | 4147 char_u *target_dir = NULL; |
1683 | 4148 #ifdef FEAT_AUTOCMD |
4149 char_u *au_name = NULL; | |
161 | 4150 |
4151 switch (eap->cmdidx) | |
4152 { | |
2782 | 4153 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break; |
4154 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break; | |
4155 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break; | |
657 | 4156 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break; |
2782 | 4157 case CMD_grep: au_name = (char_u *)"grep"; break; |
4158 case CMD_lgrep: au_name = (char_u *)"lgrep"; break; | |
4159 case CMD_grepadd: au_name = (char_u *)"grepadd"; break; | |
4160 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break; | |
161 | 4161 default: break; |
4162 } | |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4163 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4164 curbuf->b_fname, TRUE, curbuf)) |
161 | 4165 { |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4166 # ifdef FEAT_EVAL |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4167 if (aborting()) |
161 | 4168 return; |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4169 # endif |
161 | 4170 } |
4171 #endif | |
41 | 4172 |
661 | 4173 if (eap->cmdidx == CMD_lgrep |
659 | 4174 || eap->cmdidx == CMD_lvimgrep |
4175 || eap->cmdidx == CMD_lgrepadd | |
4176 || eap->cmdidx == CMD_lvimgrepadd) | |
657 | 4177 { |
4178 qi = ll_get_or_alloc_list(curwin); | |
4179 if (qi == NULL) | |
4180 return; | |
4181 } | |
4182 | |
716 | 4183 if (eap->addr_count > 0) |
4184 tomatch = eap->line2; | |
4185 else | |
4186 tomatch = MAXLNUM; | |
4187 | |
42 | 4188 /* Get the search pattern: either white-separated or enclosed in // */ |
41 | 4189 regmatch.regprog = NULL; |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4190 title = vim_strsave(*eap->cmdlinep); |
170 | 4191 p = skip_vimgrep_pat(eap->arg, &s, &flags); |
153 | 4192 if (p == NULL) |
41 | 4193 { |
282 | 4194 EMSG(_(e_invalpat)); |
153 | 4195 goto theend; |
41 | 4196 } |
4197 | 4197 |
4198 if (s != NULL && *s == NUL) | |
4199 { | |
4200 /* Pattern is empty, use last search pattern. */ | |
4201 if (last_search_pat() == NULL) | |
4202 { | |
4203 EMSG(_(e_noprevre)); | |
4204 goto theend; | |
4205 } | |
4206 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); | |
4207 } | |
4208 else | |
4209 regmatch.regprog = vim_regcomp(s, RE_MAGIC); | |
4210 | |
41 | 4211 if (regmatch.regprog == NULL) |
4212 goto theend; | |
95 | 4213 regmatch.rmm_ic = p_ic; |
410 | 4214 regmatch.rmm_maxcol = 0; |
41 | 4215 |
4216 p = skipwhite(p); | |
4217 if (*p == NUL) | |
4218 { | |
4219 EMSG(_("E683: File name missing or invalid pattern")); | |
4220 goto theend; | |
4221 } | |
4222 | |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4223 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4224 && eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd) |
644 | 4225 || qi->qf_curlist == qi->qf_listcount) |
41 | 4226 /* make place for a new list */ |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4227 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep); |
41 | 4228 |
4229 /* parse the list of arguments */ | |
3620 | 4230 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) |
41 | 4231 goto theend; |
4232 if (fcount == 0) | |
4233 { | |
4234 EMSG(_(e_nomatch)); | |
4235 goto theend; | |
4236 } | |
4237 | |
7558
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
4238 dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start); |
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
4239 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now); |
2770 | 4240 if (dirname_start == NULL || dirname_now == NULL) |
7662
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
4241 { |
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
4242 FreeWild(fcount, fnames); |
2770 | 4243 goto theend; |
7662
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
4244 } |
2770 | 4245 |
1411 | 4246 /* Remember the current directory, because a BufRead autocommand that does |
4247 * ":lcd %:p:h" changes the meaning of short path names. */ | |
4248 mch_dirname(dirname_start, MAXPATHL); | |
4249 | |
4003 | 4250 #ifdef FEAT_AUTOCMD |
4352 | 4251 /* Remember the value of qf_start, so that we can check for autocommands |
4003 | 4252 * changing the current quickfix list. */ |
4253 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
4254 #endif | |
4255 | |
123 | 4256 seconds = (time_t)0; |
716 | 4257 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi) |
41 | 4258 { |
1411 | 4259 fname = shorten_fname1(fnames[fi]); |
123 | 4260 if (time(NULL) > seconds) |
4261 { | |
1411 | 4262 /* Display the file name every second or so, show the user we are |
4263 * working on it. */ | |
123 | 4264 seconds = time(NULL); |
4265 msg_start(); | |
1411 | 4266 p = msg_strtrunc(fname, TRUE); |
123 | 4267 if (p == NULL) |
1411 | 4268 msg_outtrans(fname); |
123 | 4269 else |
4270 { | |
4271 msg_outtrans(p); | |
4272 vim_free(p); | |
4273 } | |
4274 msg_clr_eos(); | |
4275 msg_didout = FALSE; /* overwrite this message */ | |
4276 msg_nowait = TRUE; /* don't wait for this message */ | |
4277 msg_col = 0; | |
4278 out_flush(); | |
4279 } | |
4280 | |
42 | 4281 buf = buflist_findname_exp(fnames[fi]); |
4282 if (buf == NULL || buf->b_ml.ml_mfp == NULL) | |
4283 { | |
4284 /* Remember that a buffer with this name already exists. */ | |
4285 duplicate_name = (buf != NULL); | |
123 | 4286 using_dummy = TRUE; |
1396 | 4287 redraw_for_dummy = TRUE; |
123 | 4288 |
4289 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) | |
4290 /* Don't do Filetype autocommands to avoid loading syntax and | |
4291 * indent scripts, a great speed improvement. */ | |
4292 save_ei = au_event_disable(",Filetype"); | |
4293 #endif | |
677 | 4294 /* Don't use modelines here, it's useless. */ |
4295 save_mls = p_mls; | |
4296 p_mls = 0; | |
42 | 4297 |
4298 /* Load file into a buffer, so that 'fileencoding' is detected, | |
4299 * autocommands applied, etc. */ | |
3490 | 4300 buf = load_dummy_buffer(fname, dirname_start, dirname_now); |
123 | 4301 |
677 | 4302 p_mls = save_mls; |
123 | 4303 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
4304 au_event_restore(save_ei); | |
4305 #endif | |
42 | 4306 } |
4307 else | |
4308 /* Use existing, loaded buffer. */ | |
4309 using_dummy = FALSE; | |
123 | 4310 |
4003 | 4311 #ifdef FEAT_AUTOCMD |
4312 if (cur_qf_start != qi->qf_lists[qi->qf_curlist].qf_start) | |
4313 { | |
4314 int idx; | |
4315 | |
4316 /* Autocommands changed the quickfix list. Find the one we were | |
4317 * using and restore it. */ | |
4318 for (idx = 0; idx < LISTCOUNT; ++idx) | |
4319 if (cur_qf_start == qi->qf_lists[idx].qf_start) | |
4320 { | |
4321 qi->qf_curlist = idx; | |
4322 break; | |
4323 } | |
4324 if (idx == LISTCOUNT) | |
4325 { | |
4326 /* List cannot be found, create a new one. */ | |
4327 qf_new_list(qi, *eap->cmdlinep); | |
4328 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
4329 } | |
4330 } | |
4331 #endif | |
4332 | |
42 | 4333 if (buf == NULL) |
123 | 4334 { |
4335 if (!got_int) | |
1411 | 4336 smsg((char_u *)_("Cannot open file \"%s\""), fname); |
123 | 4337 } |
41 | 4338 else |
4339 { | |
717 | 4340 /* Try for a match in all lines of the buffer. |
4341 * For ":1vimgrep" look for first match only. */ | |
42 | 4342 found_match = FALSE; |
716 | 4343 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; |
4344 ++lnum) | |
41 | 4345 { |
170 | 4346 col = 0; |
4347 while (vim_regexec_multi(®match, curwin, buf, lnum, | |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
4348 col, NULL, NULL) > 0) |
41 | 4349 { |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4350 /* Pass the buffer number so that it gets used even for a |
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4351 * dummy buffer, unless duplicate_name is set, then the |
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4352 * buffer will be wiped out below. */ |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4353 if (qf_add_entry(qi, |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
4354 qi->qf_curlist, |
41 | 4355 NULL, /* dir */ |
1411 | 4356 fname, |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4357 duplicate_name ? 0 : buf->b_fnum, |
42 | 4358 ml_get_buf(buf, |
4359 regmatch.startpos[0].lnum + lnum, FALSE), | |
4360 regmatch.startpos[0].lnum + lnum, | |
4361 regmatch.startpos[0].col + 1, | |
170 | 4362 FALSE, /* vis_col */ |
230 | 4363 NULL, /* search pattern */ |
856 | 4364 0, /* nr */ |
4365 0, /* type */ | |
4366 TRUE /* valid */ | |
41 | 4367 ) == FAIL) |
4368 { | |
4369 got_int = TRUE; | |
4370 break; | |
4371 } | |
716 | 4372 found_match = TRUE; |
4373 if (--tomatch == 0) | |
4374 break; | |
170 | 4375 if ((flags & VGR_GLOBAL) == 0 |
4376 || regmatch.endpos[0].lnum > 0) | |
4377 break; | |
4378 col = regmatch.endpos[0].col | |
4379 + (col == regmatch.endpos[0].col); | |
1883 | 4380 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE))) |
170 | 4381 break; |
41 | 4382 } |
4383 line_breakcheck(); | |
42 | 4384 if (got_int) |
4385 break; | |
41 | 4386 } |
4003 | 4387 #ifdef FEAT_AUTOCMD |
4388 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
4389 #endif | |
42 | 4390 |
4391 if (using_dummy) | |
4392 { | |
123 | 4393 if (found_match && first_match_buf == NULL) |
4394 first_match_buf = buf; | |
42 | 4395 if (duplicate_name) |
123 | 4396 { |
42 | 4397 /* Never keep a dummy buffer if there is another buffer |
4398 * with the same name. */ | |
3490 | 4399 wipe_dummy_buffer(buf, dirname_start); |
123 | 4400 buf = NULL; |
4401 } | |
717 | 4402 else if (!cmdmod.hide |
4403 || buf->b_p_bh[0] == 'u' /* "unload" */ | |
4404 || buf->b_p_bh[0] == 'w' /* "wipe" */ | |
4405 || buf->b_p_bh[0] == 'd') /* "delete" */ | |
42 | 4406 { |
717 | 4407 /* When no match was found we don't need to remember the |
4408 * buffer, wipe it out. If there was a match and it | |
4409 * wasn't the first one or we won't jump there: only | |
4410 * unload the buffer. | |
4411 * Ignore 'hidden' here, because it may lead to having too | |
4412 * many swap files. */ | |
42 | 4413 if (!found_match) |
123 | 4414 { |
3490 | 4415 wipe_dummy_buffer(buf, dirname_start); |
123 | 4416 buf = NULL; |
4417 } | |
170 | 4418 else if (buf != first_match_buf || (flags & VGR_NOJUMP)) |
123 | 4419 { |
3490 | 4420 unload_dummy_buffer(buf, dirname_start); |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4421 /* Keeping the buffer, remove the dummy flag. */ |
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4422 buf->b_flags &= ~BF_DUMMY; |
123 | 4423 buf = NULL; |
4424 } | |
42 | 4425 } |
123 | 4426 |
4427 if (buf != NULL) | |
4428 { | |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4429 /* Keeping the buffer, remove the dummy flag. */ |
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4430 buf->b_flags &= ~BF_DUMMY; |
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4431 |
1411 | 4432 /* If the buffer is still loaded we need to use the |
4433 * directory we jumped to below. */ | |
4434 if (buf == first_match_buf | |
4435 && target_dir == NULL | |
4436 && STRCMP(dirname_start, dirname_now) != 0) | |
4437 target_dir = vim_strsave(dirname_now); | |
4438 | |
123 | 4439 /* The buffer is still loaded, the Filetype autocommands |
677 | 4440 * need to be done now, in that buffer. And the modelines |
717 | 4441 * need to be done (again). But not the window-local |
4442 * options! */ | |
123 | 4443 aucmd_prepbuf(&aco, buf); |
677 | 4444 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
123 | 4445 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, |
4446 buf->b_fname, TRUE, buf); | |
677 | 4447 #endif |
717 | 4448 do_modelines(OPT_NOWIN); |
123 | 4449 aucmd_restbuf(&aco); |
4450 } | |
42 | 4451 } |
41 | 4452 } |
4453 } | |
4454 | |
4455 FreeWild(fcount, fnames); | |
4456 | |
644 | 4457 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
4458 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; | |
4459 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
41 | 4460 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4461 qf_update_buffer(qi, NULL); |
41 | 4462 |
842 | 4463 #ifdef FEAT_AUTOCMD |
4464 if (au_name != NULL) | |
4465 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | |
4466 curbuf->b_fname, TRUE, curbuf); | |
4467 #endif | |
4468 | |
41 | 4469 /* Jump to first match. */ |
644 | 4470 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
170 | 4471 { |
4472 if ((flags & VGR_NOJUMP) == 0) | |
1396 | 4473 { |
4474 buf = curbuf; | |
659 | 4475 qf_jump(qi, 0, 0, eap->forceit); |
1396 | 4476 if (buf != curbuf) |
4477 /* If we jumped to another buffer redrawing will already be | |
4478 * taken care of. */ | |
4479 redraw_for_dummy = FALSE; | |
1411 | 4480 |
4481 /* Jump to the directory used after loading the buffer. */ | |
4482 if (curbuf == first_match_buf && target_dir != NULL) | |
4483 { | |
4484 exarg_T ea; | |
4485 | |
4486 ea.arg = target_dir; | |
4487 ea.cmdidx = CMD_lcd; | |
4488 ex_cd(&ea); | |
4489 } | |
1396 | 4490 } |
170 | 4491 } |
42 | 4492 else |
4493 EMSG2(_(e_nomatch2), s); | |
41 | 4494 |
1396 | 4495 /* If we loaded a dummy buffer into the current window, the autocommands |
4496 * may have messed up things, need to redraw and recompute folds. */ | |
4497 if (redraw_for_dummy) | |
4498 { | |
4499 #ifdef FEAT_FOLDING | |
4500 foldUpdateAll(curwin); | |
4501 #else | |
4502 redraw_later(NOT_VALID); | |
4503 #endif | |
4504 } | |
4505 | |
41 | 4506 theend: |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4507 vim_free(title); |
2770 | 4508 vim_free(dirname_now); |
4509 vim_free(dirname_start); | |
1411 | 4510 vim_free(target_dir); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4371
diff
changeset
|
4511 vim_regfree(regmatch.regprog); |
41 | 4512 } |
4513 | |
4514 /* | |
3490 | 4515 * Restore current working directory to "dirname_start" if they differ, taking |
4516 * into account whether it is set locally or globally. | |
4517 */ | |
4518 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4519 restore_start_dir(char_u *dirname_start) |
3490 | 4520 { |
4521 char_u *dirname_now = alloc(MAXPATHL); | |
4522 | |
4523 if (NULL != dirname_now) | |
4524 { | |
4525 mch_dirname(dirname_now, MAXPATHL); | |
4526 if (STRCMP(dirname_start, dirname_now) != 0) | |
4527 { | |
4528 /* If the directory has changed, change it back by building up an | |
4529 * appropriate ex command and executing it. */ | |
4530 exarg_T ea; | |
4531 | |
4532 ea.arg = dirname_start; | |
4533 ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd; | |
4534 ex_cd(&ea); | |
4535 } | |
3974 | 4536 vim_free(dirname_now); |
3490 | 4537 } |
4538 } | |
4539 | |
4540 /* | |
4541 * Load file "fname" into a dummy buffer and return the buffer pointer, | |
4542 * placing the directory resulting from the buffer load into the | |
4543 * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller | |
4544 * prior to calling this function. Restores directory to "dirname_start" prior | |
4545 * to returning, if autocmds or the 'autochdir' option have changed it. | |
4546 * | |
4547 * If creating the dummy buffer does not fail, must call unload_dummy_buffer() | |
4548 * or wipe_dummy_buffer() later! | |
4549 * | |
42 | 4550 * Returns NULL if it fails. |
4551 */ | |
4552 static buf_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4553 load_dummy_buffer( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4554 char_u *fname, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4555 char_u *dirname_start, /* in: old directory */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4556 char_u *resulting_dir) /* out: new directory */ |
42 | 4557 { |
4558 buf_T *newbuf; | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4559 bufref_T newbufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4560 bufref_T newbuf_to_wipe; |
42 | 4561 int failed = TRUE; |
4562 aco_save_T aco; | |
4563 | |
4564 /* Allocate a buffer without putting it in the buffer list. */ | |
4565 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); | |
4566 if (newbuf == NULL) | |
4567 return NULL; | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4568 set_bufref(&newbufref, newbuf); |
42 | 4569 |
177 | 4570 /* Init the options. */ |
4571 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP); | |
4572 | |
1918 | 4573 /* need to open the memfile before putting the buffer in a window */ |
4574 if (ml_open(newbuf) == OK) | |
42 | 4575 { |
1918 | 4576 /* set curwin/curbuf to buf and save a few things */ |
4577 aucmd_prepbuf(&aco, newbuf); | |
4578 | |
4579 /* Need to set the filename for autocommands. */ | |
4580 (void)setfname(curbuf, fname, NULL, FALSE); | |
4581 | |
42 | 4582 /* Create swap file now to avoid the ATTENTION message. */ |
4583 check_need_swap(TRUE); | |
4584 | |
4585 /* Remove the "dummy" flag, otherwise autocommands may not | |
4586 * work. */ | |
4587 curbuf->b_flags &= ~BF_DUMMY; | |
4588 | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4589 newbuf_to_wipe.br_buf = NULL; |
42 | 4590 if (readfile(fname, NULL, |
4591 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, | |
4592 NULL, READ_NEW | READ_DUMMY) == OK | |
857 | 4593 && !got_int |
42 | 4594 && !(curbuf->b_flags & BF_NEW)) |
4595 { | |
4596 failed = FALSE; | |
4597 if (curbuf != newbuf) | |
4598 { | |
2646 | 4599 /* Bloody autocommands changed the buffer! Can happen when |
4600 * using netrw and editing a remote file. Use the current | |
4601 * buffer instead, delete the dummy one after restoring the | |
4602 * window stuff. */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4603 set_bufref(&newbuf_to_wipe, newbuf); |
42 | 4604 newbuf = curbuf; |
4605 } | |
4606 } | |
1918 | 4607 |
4608 /* restore curwin/curbuf and a few other things */ | |
4609 aucmd_restbuf(&aco); | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4610 if (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe)) |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4611 wipe_buffer(newbuf_to_wipe.br_buf, FALSE); |
9485
c16e207dc465
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents:
9475
diff
changeset
|
4612 |
c16e207dc465
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents:
9475
diff
changeset
|
4613 /* Add back the "dummy" flag, otherwise buflist_findname_stat() won't |
c16e207dc465
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents:
9475
diff
changeset
|
4614 * skip it. */ |
c16e207dc465
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents:
9475
diff
changeset
|
4615 newbuf->b_flags |= BF_DUMMY; |
42 | 4616 } |
4617 | |
3490 | 4618 /* |
4619 * When autocommands/'autochdir' option changed directory: go back. | |
4620 * Let the caller know what the resulting dir was first, in case it is | |
4621 * important. | |
4622 */ | |
4623 mch_dirname(resulting_dir, MAXPATHL); | |
4624 restore_start_dir(dirname_start); | |
4625 | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4626 if (!bufref_valid(&newbufref)) |
42 | 4627 return NULL; |
4628 if (failed) | |
4629 { | |
3490 | 4630 wipe_dummy_buffer(newbuf, dirname_start); |
42 | 4631 return NULL; |
4632 } | |
4633 return newbuf; | |
4634 } | |
4635 | |
4636 /* | |
3490 | 4637 * Wipe out the dummy buffer that load_dummy_buffer() created. Restores |
4638 * directory to "dirname_start" prior to returning, if autocmds or the | |
4639 * 'autochdir' option have changed it. | |
42 | 4640 */ |
4641 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4642 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) |
42 | 4643 { |
4644 if (curbuf != buf) /* safety check */ | |
857 | 4645 { |
4646 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | |
4647 cleanup_T cs; | |
4648 | |
4649 /* Reset the error/interrupt/exception state here so that aborting() | |
4650 * returns FALSE when wiping out the buffer. Otherwise it doesn't | |
4651 * work when got_int is set. */ | |
4652 enter_cleanup(&cs); | |
4653 #endif | |
4654 | |
42 | 4655 wipe_buffer(buf, FALSE); |
857 | 4656 |
4657 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | |
4658 /* Restore the error/interrupt/exception state if not discarded by a | |
4659 * new aborting error, interrupt, or uncaught exception. */ | |
4660 leave_cleanup(&cs); | |
4661 #endif | |
3490 | 4662 /* When autocommands/'autochdir' option changed directory: go back. */ |
4663 restore_start_dir(dirname_start); | |
857 | 4664 } |
42 | 4665 } |
4666 | |
4667 /* | |
3490 | 4668 * Unload the dummy buffer that load_dummy_buffer() created. Restores |
4669 * directory to "dirname_start" prior to returning, if autocmds or the | |
4670 * 'autochdir' option have changed it. | |
42 | 4671 */ |
4672 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4673 unload_dummy_buffer(buf_T *buf, char_u *dirname_start) |
42 | 4674 { |
4675 if (curbuf != buf) /* safety check */ | |
3490 | 4676 { |
3365 | 4677 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE); |
3490 | 4678 |
4679 /* When autocommands/'autochdir' option changed directory: go back. */ | |
4680 restore_start_dir(dirname_start); | |
4681 } | |
42 | 4682 } |
4683 | |
170 | 4684 #if defined(FEAT_EVAL) || defined(PROTO) |
4685 /* | |
4686 * Add each quickfix error to list "list" as a dictionary. | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4687 * If qf_idx is -1, use the current list. Otherwise, use the specified list. |
170 | 4688 */ |
4689 int | |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4690 get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list) |
170 | 4691 { |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4692 qf_info_T *qi = qi_arg; |
230 | 4693 dict_T *dict; |
4694 char_u buf[2]; | |
4695 qfline_T *qfp; | |
4696 int i; | |
1065 | 4697 int bufnum; |
170 | 4698 |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4699 if (qi == NULL) |
647 | 4700 { |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4701 qi = &ql_info; |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4702 if (wp != NULL) |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4703 { |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4704 qi = GET_LOC_LIST(wp); |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4705 if (qi == NULL) |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4706 return FAIL; |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4707 } |
647 | 4708 } |
4709 | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4710 if (qf_idx == -1) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4711 qf_idx = qi->qf_curlist; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4712 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4713 if (qf_idx >= qi->qf_listcount |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4714 || qi->qf_lists[qf_idx].qf_count == 0) |
170 | 4715 return FAIL; |
4716 | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4717 qfp = qi->qf_lists[qf_idx].qf_start; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4718 for (i = 1; !got_int && i <= qi->qf_lists[qf_idx].qf_count; ++i) |
170 | 4719 { |
1065 | 4720 /* Handle entries with a non-existing buffer number. */ |
4721 bufnum = qfp->qf_fnum; | |
4722 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
4723 bufnum = 0; | |
4724 | |
170 | 4725 if ((dict = dict_alloc()) == NULL) |
4726 return FAIL; | |
4727 if (list_append_dict(list, dict) == FAIL) | |
4728 return FAIL; | |
4729 | |
4730 buf[0] = qfp->qf_type; | |
4731 buf[1] = NUL; | |
1065 | 4732 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL |
170 | 4733 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL |
4734 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL | |
4735 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL | |
4736 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL | |
960 | 4737 || dict_add_nr_str(dict, "pattern", 0L, |
4738 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL | |
4739 || dict_add_nr_str(dict, "text", 0L, | |
4740 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL | |
170 | 4741 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL |
4742 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL) | |
4743 return FAIL; | |
4744 | |
4745 qfp = qfp->qf_next; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4746 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4747 break; |
170 | 4748 } |
4749 return OK; | |
4750 } | |
230 | 4751 |
4752 /* | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4753 * Flags used by getqflist()/getloclist() to determine which fields to return. |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4754 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4755 enum { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4756 QF_GETLIST_NONE = 0x0, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4757 QF_GETLIST_TITLE = 0x1, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4758 QF_GETLIST_ITEMS = 0x2, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4759 QF_GETLIST_NR = 0x4, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4760 QF_GETLIST_WINID = 0x8, |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4761 QF_GETLIST_CONTEXT = 0x10, |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4762 QF_GETLIST_ID = 0x20, |
12465
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4763 QF_GETLIST_IDX = 0x40, |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4764 QF_GETLIST_SIZE = 0x80, |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4765 QF_GETLIST_ALL = 0xFF |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4766 }; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4767 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4768 /* |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4769 * Parse text from 'di' and return the quickfix list items |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4770 */ |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4771 static int |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4772 qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict) |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4773 { |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4774 int status = FAIL; |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4775 qf_info_T *qi; |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4776 char_u *errorformat = p_efm; |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4777 dictitem_T *efm_di; |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4778 list_T *l; |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4779 |
12303
ec7a4fd21dd5
patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12299
diff
changeset
|
4780 /* Only a List value is supported */ |
ec7a4fd21dd5
patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12299
diff
changeset
|
4781 if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL) |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4782 { |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4783 /* If errorformat is supplied then use it, otherwise use the 'efm' |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4784 * option setting |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4785 */ |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4786 if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL) |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4787 { |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4788 if (efm_di->di_tv.v_type != VAR_STRING || |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4789 efm_di->di_tv.vval.v_string == NULL) |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4790 return FAIL; |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4791 errorformat = efm_di->di_tv.vval.v_string; |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4792 } |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4793 |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4794 l = list_alloc(); |
12299
f4d00472e617
patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
12287
diff
changeset
|
4795 if (l == NULL) |
f4d00472e617
patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
12287
diff
changeset
|
4796 return FAIL; |
f4d00472e617
patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
12287
diff
changeset
|
4797 |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4798 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T)); |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4799 if (qi != NULL) |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4800 { |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4801 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T))); |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4802 qi->qf_refcount++; |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4803 |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4804 if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat, |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4805 TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0) |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4806 { |
12299
f4d00472e617
patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
12287
diff
changeset
|
4807 (void)get_errorlist(qi, NULL, 0, l); |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4808 qf_free(qi, 0); |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4809 } |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4810 free(qi); |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4811 } |
12299
f4d00472e617
patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
12287
diff
changeset
|
4812 dict_add_list(retdict, "items", l); |
f4d00472e617
patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
12287
diff
changeset
|
4813 status = OK; |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4814 } |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4815 |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4816 return status; |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4817 } |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4818 |
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4819 /* |
12427
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4820 * Return the quickfix/location list number with the given identifier. |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4821 * Returns -1 if list is not found. |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4822 */ |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4823 static int |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4824 qf_id2nr(qf_info_T *qi, int_u qfid) |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4825 { |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4826 int qf_idx; |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4827 |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4828 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4829 if (qi->qf_lists[qf_idx].qf_id == qfid) |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4830 return qf_idx; |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4831 return -1; |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4832 } |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4833 |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4834 /* |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4835 * Return quickfix/location list details (title) as a |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4836 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4837 * then current list is used. Otherwise the specified list is used. |
230 | 4838 */ |
4839 int | |
12427
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4840 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4841 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4842 qf_info_T *qi = &ql_info; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4843 int status = OK; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4844 int qf_idx; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4845 dictitem_T *di; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4846 int flags = QF_GETLIST_NONE; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4847 |
12303
ec7a4fd21dd5
patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12299
diff
changeset
|
4848 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
4849 return qf_get_list_from_lines(what, di, retdict); |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4850 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4851 if (wp != NULL) |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4852 qi = GET_LOC_LIST(wp); |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4853 |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4854 /* List is not present or is empty */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4855 if (qi == NULL || qi->qf_listcount == 0) |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4856 { |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4857 /* If querying for the size of the list, return 0 */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4858 if (((di = dict_find(what, (char_u *)"nr", -1)) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4859 && (di->di_tv.v_type == VAR_STRING) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4860 && (STRCMP(di->di_tv.vval.v_string, "$") == 0)) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4861 return dict_add_nr_str(retdict, "nr", 0, NULL); |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4862 return FAIL; |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4863 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4864 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4865 qf_idx = qi->qf_curlist; /* default is the current list */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4866 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4867 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4868 /* Use the specified quickfix/location list */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4869 if (di->di_tv.v_type == VAR_NUMBER) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4870 { |
10237
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4871 /* for zero use the current list */ |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4872 if (di->di_tv.vval.v_number != 0) |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4873 { |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4874 qf_idx = di->di_tv.vval.v_number - 1; |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4875 if (qf_idx < 0 || qf_idx >= qi->qf_listcount) |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4876 return FAIL; |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4877 } |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4878 } |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4879 else if ((di->di_tv.v_type == VAR_STRING) |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
4880 && (STRCMP(di->di_tv.vval.v_string, "$") == 0)) |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4881 /* Get the last quickfix list number */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4882 qf_idx = qi->qf_listcount - 1; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4883 else |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4884 return FAIL; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4885 flags |= QF_GETLIST_NR; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4886 } |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4887 |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4888 if ((di = dict_find(what, (char_u *)"id", -1)) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4889 { |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4890 /* Look for a list with the specified id */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4891 if (di->di_tv.v_type == VAR_NUMBER) |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4892 { |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4893 /* For zero, use the current list or the list specifed by 'nr' */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4894 if (di->di_tv.vval.v_number != 0) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4895 { |
12427
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4896 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number); |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
4897 if (qf_idx == -1) |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4898 return FAIL; /* List not found */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4899 } |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4900 flags |= QF_GETLIST_ID; |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4901 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4902 else |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4903 return FAIL; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4904 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4905 |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4906 if (dict_find(what, (char_u *)"all", -1) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4907 flags |= QF_GETLIST_ALL; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4908 |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4909 if (dict_find(what, (char_u *)"title", -1) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4910 flags |= QF_GETLIST_TITLE; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4911 |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4912 if (dict_find(what, (char_u *)"winid", -1) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4913 flags |= QF_GETLIST_WINID; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4914 |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4915 if (dict_find(what, (char_u *)"context", -1) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4916 flags |= QF_GETLIST_CONTEXT; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4917 |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4918 if (dict_find(what, (char_u *)"items", -1) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4919 flags |= QF_GETLIST_ITEMS; |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4920 |
12465
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4921 if (dict_find(what, (char_u *)"idx", -1) != NULL) |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4922 flags |= QF_GETLIST_IDX; |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4923 |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4924 if (dict_find(what, (char_u *)"size", -1) != NULL) |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4925 flags |= QF_GETLIST_SIZE; |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4926 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4927 if (flags & QF_GETLIST_TITLE) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4928 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4929 char_u *t; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4930 t = qi->qf_lists[qf_idx].qf_title; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4931 if (t == NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4932 t = (char_u *)""; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4933 status = dict_add_nr_str(retdict, "title", 0L, t); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4934 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4935 if ((status == OK) && (flags & QF_GETLIST_NR)) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4936 status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4937 if ((status == OK) && (flags & QF_GETLIST_WINID)) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4938 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4939 win_T *win; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4940 win = qf_find_win(qi); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4941 if (win != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4942 status = dict_add_nr_str(retdict, "winid", win->w_id, NULL); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4943 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4944 if ((status == OK) && (flags & QF_GETLIST_ITEMS)) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4945 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4946 list_T *l = list_alloc(); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4947 if (l != NULL) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4948 { |
12252
3d0e042ec13c
patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
4949 (void)get_errorlist(qi, NULL, qf_idx, l); |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4950 dict_add_list(retdict, "items", l); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4951 } |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4952 else |
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4953 status = FAIL; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4954 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4955 |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4956 if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4957 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4958 if (qi->qf_lists[qf_idx].qf_ctx != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4959 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4960 di = dictitem_alloc((char_u *)"context"); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4961 if (di != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4962 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4963 copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv); |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4964 status = dict_add(retdict, di); |
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4965 if (status == FAIL) |
11422
ad4b56939140
patch 8.0.0595: Coverity warning for not checking return value
Christian Brabandt <cb@256bit.org>
parents:
11412
diff
changeset
|
4966 dictitem_free(di); |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4967 } |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4968 else |
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4969 status = FAIL; |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4970 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4971 else |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4972 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)""); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4973 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4974 |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4975 if ((status == OK) && (flags & QF_GETLIST_ID)) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4976 status = dict_add_nr_str(retdict, "id", qi->qf_lists[qf_idx].qf_id, |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4977 NULL); |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
4978 |
12465
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4979 if ((status == OK) && (flags & QF_GETLIST_IDX)) |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4980 { |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4981 int idx = qi->qf_lists[qf_idx].qf_index; |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4982 if (qi->qf_lists[qf_idx].qf_count == 0) |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4983 /* For empty lists, qf_index is set to 1 */ |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4984 idx = 0; |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4985 status = dict_add_nr_str(retdict, "idx", idx, NULL); |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4986 } |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4987 |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4988 if ((status == OK) && (flags & QF_GETLIST_SIZE)) |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4989 status = dict_add_nr_str(retdict, "size", |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4990 qi->qf_lists[qf_idx].qf_count, NULL); |
805f7fd40e0d
patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12449
diff
changeset
|
4991 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4992 return status; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4993 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4994 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4995 /* |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4996 * Add list of entries to quickfix/location list. Each list entry is |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4997 * a dictionary with item information. |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4998 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4999 static int |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5000 qf_add_entries( |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5001 qf_info_T *qi, |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5002 int qf_idx, |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5003 list_T *list, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5004 char_u *title, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5005 int action) |
230 | 5006 { |
5007 listitem_T *li; | |
5008 dict_T *d; | |
5009 char_u *filename, *pattern, *text, *type; | |
1065 | 5010 int bufnum; |
230 | 5011 long lnum; |
5012 int col, nr; | |
5013 int vcol; | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
5014 qfline_T *old_last = NULL; |
230 | 5015 int valid, status; |
5016 int retval = OK; | |
1065 | 5017 int did_bufnr_emsg = FALSE; |
644 | 5018 |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5019 if (action == ' ' || qf_idx == qi->qf_listcount) |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5020 { |
277 | 5021 /* make place for a new list */ |
3965 | 5022 qf_new_list(qi, title); |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5023 qf_idx = qi->qf_curlist; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5024 } |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5025 else if (action == 'a' && qi->qf_lists[qf_idx].qf_count > 0) |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
5026 /* Adding to existing list, use last entry. */ |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5027 old_last = qi->qf_lists[qf_idx].qf_last; |
277 | 5028 else if (action == 'r') |
6079 | 5029 { |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5030 qf_free_items(qi, qf_idx); |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5031 qf_store_title(qi, qf_idx, title); |
6079 | 5032 } |
230 | 5033 |
5034 for (li = list->lv_first; li != NULL; li = li->li_next) | |
5035 { | |
5036 if (li->li_tv.v_type != VAR_DICT) | |
5037 continue; /* Skip non-dict items */ | |
5038 | |
5039 d = li->li_tv.vval.v_dict; | |
5040 if (d == NULL) | |
5041 continue; | |
5042 | |
659 | 5043 filename = get_dict_string(d, (char_u *)"filename", TRUE); |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
5044 bufnum = (int)get_dict_number(d, (char_u *)"bufnr"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
5045 lnum = (int)get_dict_number(d, (char_u *)"lnum"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
5046 col = (int)get_dict_number(d, (char_u *)"col"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
5047 vcol = (int)get_dict_number(d, (char_u *)"vcol"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
5048 nr = (int)get_dict_number(d, (char_u *)"nr"); |
659 | 5049 type = get_dict_string(d, (char_u *)"type", TRUE); |
5050 pattern = get_dict_string(d, (char_u *)"pattern", TRUE); | |
5051 text = get_dict_string(d, (char_u *)"text", TRUE); | |
230 | 5052 if (text == NULL) |
5053 text = vim_strsave((char_u *)""); | |
5054 | |
5055 valid = TRUE; | |
1065 | 5056 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL)) |
230 | 5057 valid = FALSE; |
5058 | |
1065 | 5059 /* Mark entries with non-existing buffer number as not valid. Give the |
5060 * error message only once. */ | |
5061 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
5062 { | |
5063 if (!did_bufnr_emsg) | |
5064 { | |
5065 did_bufnr_emsg = TRUE; | |
5066 EMSGN(_("E92: Buffer %ld not found"), bufnum); | |
5067 } | |
5068 valid = FALSE; | |
5069 bufnum = 0; | |
5070 } | |
5071 | |
11390
73cfcf11d983
patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents:
11378
diff
changeset
|
5072 /* If the 'valid' field is present it overrules the detected value. */ |
73cfcf11d983
patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents:
11378
diff
changeset
|
5073 if ((dict_find(d, (char_u *)"valid", -1)) != NULL) |
73cfcf11d983
patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents:
11378
diff
changeset
|
5074 valid = (int)get_dict_number(d, (char_u *)"valid"); |
73cfcf11d983
patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents:
11378
diff
changeset
|
5075 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
5076 status = qf_add_entry(qi, |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5077 qf_idx, |
230 | 5078 NULL, /* dir */ |
5079 filename, | |
1065 | 5080 bufnum, |
230 | 5081 text, |
5082 lnum, | |
5083 col, | |
5084 vcol, /* vis_col */ | |
5085 pattern, /* search pattern */ | |
5086 nr, | |
5087 type == NULL ? NUL : *type, | |
5088 valid); | |
5089 | |
5090 vim_free(filename); | |
5091 vim_free(pattern); | |
5092 vim_free(text); | |
5093 vim_free(type); | |
5094 | |
5095 if (status == FAIL) | |
5096 { | |
5097 retval = FAIL; | |
5098 break; | |
5099 } | |
5100 } | |
5101 | |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5102 if (qi->qf_lists[qf_idx].qf_index == 0) |
2795 | 5103 /* no valid entry */ |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5104 qi->qf_lists[qf_idx].qf_nonevalid = TRUE; |
2146
c17a42da3920
updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
5105 else |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5106 qi->qf_lists[qf_idx].qf_nonevalid = FALSE; |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5107 if (action != 'a') |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5108 { |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5109 qi->qf_lists[qf_idx].qf_ptr = |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5110 qi->qf_lists[qf_idx].qf_start; |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5111 if (qi->qf_lists[qf_idx].qf_count > 0) |
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5112 qi->qf_lists[qf_idx].qf_index = 1; |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
5113 } |
230 | 5114 |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
5115 /* Don't update the cursor in quickfix window when appending entries */ |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
5116 qf_update_buffer(qi, old_last); |
230 | 5117 |
5118 return retval; | |
5119 } | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5120 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5121 static int |
12048
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5122 qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title) |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5123 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5124 dictitem_T *di; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5125 int retval = FAIL; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5126 int qf_idx; |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5127 int newlist = FALSE; |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5128 char_u *errorformat = p_efm; |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5129 |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5130 if (action == ' ' || qi->qf_curlist == qi->qf_listcount) |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5131 newlist = TRUE; |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5132 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5133 qf_idx = qi->qf_curlist; /* default is the current list */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5134 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5135 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5136 /* Use the specified quickfix/location list */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5137 if (di->di_tv.v_type == VAR_NUMBER) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5138 { |
11445
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
5139 /* for zero use the current list */ |
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
5140 if (di->di_tv.vval.v_number != 0) |
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
5141 qf_idx = di->di_tv.vval.v_number - 1; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5142 |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5143 if ((action == ' ' || action == 'a') && qf_idx == qi->qf_listcount) |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5144 { |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5145 /* |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5146 * When creating a new list, accept qf_idx pointing to the next |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5147 * non-available list and add the new list at the end of the |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5148 * stack. |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5149 */ |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5150 newlist = TRUE; |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5151 qf_idx = qi->qf_listcount - 1; |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5152 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5153 else if (qf_idx < 0 || qf_idx >= qi->qf_listcount) |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5154 return FAIL; |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5155 else if (action != ' ') |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5156 newlist = FALSE; /* use the specified list */ |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5157 } |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5158 else if (di->di_tv.v_type == VAR_STRING |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5159 && STRCMP(di->di_tv.vval.v_string, "$") == 0) |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5160 { |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5161 if (qi->qf_listcount > 0) |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5162 qf_idx = qi->qf_listcount - 1; |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5163 else if (newlist) |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5164 qf_idx = 0; |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5165 else |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5166 return FAIL; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5167 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5168 else |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5169 return FAIL; |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5170 } |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5171 |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5172 if (!newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5173 { |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5174 /* Use the quickfix/location list with the specified id */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5175 if (di->di_tv.v_type == VAR_NUMBER) |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5176 { |
12427
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5177 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number); |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5178 if (qf_idx == -1) |
12287
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5179 return FAIL; /* List not found */ |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5180 } |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5181 else |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5182 return FAIL; |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5183 } |
20641a7e1fc9
patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents:
12252
diff
changeset
|
5184 |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5185 if (newlist) |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5186 { |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5187 qi->qf_curlist = qf_idx; |
12048
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5188 qf_new_list(qi, title); |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5189 qf_idx = qi->qf_curlist; |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5190 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5191 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5192 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5193 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5194 if (di->di_tv.v_type == VAR_STRING) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5195 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5196 vim_free(qi->qf_lists[qf_idx].qf_title); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5197 qi->qf_lists[qf_idx].qf_title = |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5198 get_dict_string(what, (char_u *)"title", TRUE); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5199 if (qf_idx == qi->qf_curlist) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5200 qf_update_win_titlevar(qi); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5201 retval = OK; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5202 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5203 } |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5204 |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5205 if ((di = dict_find(what, (char_u *)"items", -1)) != NULL) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5206 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5207 if (di->di_tv.v_type == VAR_LIST) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5208 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5209 char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5210 |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5211 retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list, |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5212 title_save, action == ' ' ? 'a' : action); |
12427
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5213 if (action == 'r') |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5214 { |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5215 /* |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5216 * When replacing the quickfix list entries using |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5217 * qf_add_entries(), the title is set with a ':' prefix. |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5218 * Restore the title with the saved title. |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5219 */ |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5220 vim_free(qi->qf_lists[qf_idx].qf_title); |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5221 qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save); |
fc3e2d5614dd
patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents:
12321
diff
changeset
|
5222 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5223 vim_free(title_save); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5224 } |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
5225 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5226 |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5227 if ((di = dict_find(what, (char_u *)"efm", -1)) != NULL) |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5228 { |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5229 if (di->di_tv.v_type != VAR_STRING || di->di_tv.vval.v_string == NULL) |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5230 return FAIL; |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5231 errorformat = di->di_tv.vval.v_string; |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5232 } |
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5233 |
12303
ec7a4fd21dd5
patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12299
diff
changeset
|
5234 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) |
12048
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5235 { |
12303
ec7a4fd21dd5
patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12299
diff
changeset
|
5236 /* Only a List value is supported */ |
ec7a4fd21dd5
patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents:
12299
diff
changeset
|
5237 if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL) |
12048
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5238 { |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5239 if (action == 'r') |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5240 qf_free_items(qi, qf_idx); |
12321
2779d593a706
patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents:
12303
diff
changeset
|
5241 if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat, |
12048
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5242 FALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0) |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5243 retval = OK; |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5244 } |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5245 else |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5246 return FAIL; |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5247 } |
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5248 |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5249 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5250 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5251 typval_T *ctx; |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
5252 |
11445
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
5253 free_tv(qi->qf_lists[qf_idx].qf_ctx); |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5254 ctx = alloc_tv(); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5255 if (ctx != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5256 copy_tv(&di->di_tv, ctx); |
11445
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
5257 qi->qf_lists[qf_idx].qf_ctx = ctx; |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
5258 retval = OK; |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5259 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5260 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5261 return retval; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5262 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5263 |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5264 /* |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5265 * Find the non-location list window with the specified location list. |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5266 */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5267 static win_T * |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5268 find_win_with_ll(qf_info_T *qi) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5269 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5270 win_T *wp = NULL; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5271 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5272 FOR_ALL_WINDOWS(wp) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5273 if ((wp->w_llist == qi) && !bt_quickfix(wp->w_buffer)) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5274 return wp; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5275 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5276 return NULL; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5277 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5278 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5279 /* |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5280 * Free the entire quickfix/location list stack. |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5281 * If the quickfix/location list window is open, then clear it. |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5282 */ |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5283 static void |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5284 qf_free_stack(win_T *wp, qf_info_T *qi) |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5285 { |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5286 win_T *qfwin = qf_find_win(qi); |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5287 win_T *llwin = NULL; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5288 win_T *orig_wp = wp; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5289 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5290 if (qfwin != NULL) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5291 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5292 /* If the quickfix/location list window is open, then clear it */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5293 if (qi->qf_curlist < qi->qf_listcount) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5294 qf_free(qi, qi->qf_curlist); |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5295 qf_update_buffer(qi, NULL); |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5296 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5297 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5298 if (wp != NULL && IS_LL_WINDOW(wp)) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5299 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5300 /* If in the location list window, then use the non-location list |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5301 * window with this location list (if present) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5302 */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5303 llwin = find_win_with_ll(qi); |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5304 if (llwin != NULL) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5305 wp = llwin; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5306 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5307 |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5308 qf_free_all(wp); |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5309 if (wp == NULL) |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5310 { |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5311 /* quickfix list */ |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5312 qi->qf_curlist = 0; |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5313 qi->qf_listcount = 0; |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5314 } |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5315 else if (IS_LL_WINDOW(orig_wp)) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5316 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5317 /* If the location list window is open, then create a new empty |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5318 * location list */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5319 qf_info_T *new_ll = ll_new_list(); |
11378
2ed7a34ecc54
patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents:
11360
diff
changeset
|
5320 |
11398
30af33f4d353
patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents:
11390
diff
changeset
|
5321 /* first free the list reference in the location list window */ |
30af33f4d353
patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents:
11390
diff
changeset
|
5322 ll_free_all(&orig_wp->w_llist_ref); |
30af33f4d353
patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents:
11390
diff
changeset
|
5323 |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5324 orig_wp->w_llist_ref = new_ll; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5325 if (llwin != NULL) |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5326 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5327 llwin->w_llist = new_ll; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5328 new_ll->qf_refcount++; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5329 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5330 } |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5331 } |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5332 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5333 /* |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5334 * Populate the quickfix list with the items supplied in the list |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5335 * of dictionaries. "title" will be copied to w:quickfix_title. |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5336 * "action" is 'a' for add, 'r' for replace. Otherwise create a new list. |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5337 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5338 int |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5339 set_errorlist( |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5340 win_T *wp, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5341 list_T *list, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5342 int action, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5343 char_u *title, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5344 dict_T *what) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5345 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5346 qf_info_T *qi = &ql_info; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5347 int retval = OK; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5348 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5349 if (wp != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5350 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5351 qi = ll_get_or_alloc_list(wp); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5352 if (qi == NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5353 return FAIL; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5354 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5355 |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5356 if (action == 'f') |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5357 { |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5358 /* Free the entire quickfix or location list stack */ |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5359 qf_free_stack(wp, qi); |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5360 } |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5361 else if (what != NULL) |
12048
ebd313aa5a6c
patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
5362 retval = qf_set_properties(qi, what, action, title); |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5363 else |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5364 retval = qf_add_entries(qi, qi->qf_curlist, list, title, action); |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5365 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5366 return retval; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5367 } |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5368 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5369 static int |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5370 mark_quickfix_ctx(qf_info_T *qi, int copyID) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5371 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5372 int i; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5373 int abort = FALSE; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5374 typval_T *ctx; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5375 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5376 for (i = 0; i < LISTCOUNT && !abort; ++i) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5377 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5378 ctx = qi->qf_lists[i].qf_ctx; |
12084
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5379 if (ctx != NULL && ctx->v_type != VAR_NUMBER |
69ce6b3f0834
patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents:
12048
diff
changeset
|
5380 && ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT) |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5381 abort = set_ref_in_item(ctx, copyID, NULL, NULL); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5382 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5383 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5384 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5385 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5386 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5387 /* |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5388 * Mark the context of the quickfix list and the location lists (if present) as |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5389 * "in use". So that garabage collection doesn't free the context. |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5390 */ |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5391 int |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5392 set_ref_in_quickfix(int copyID) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5393 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5394 int abort = FALSE; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5395 tabpage_T *tp; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5396 win_T *win; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5397 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5398 abort = mark_quickfix_ctx(&ql_info, copyID); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5399 if (abort) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5400 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5401 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5402 FOR_ALL_TAB_WINDOWS(tp, win) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5403 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5404 if (win->w_llist != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5405 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5406 abort = mark_quickfix_ctx(win->w_llist, copyID); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5407 if (abort) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5408 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5409 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5410 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5411 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5412 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5413 } |
170 | 5414 #endif |
5415 | |
42 | 5416 /* |
41 | 5417 * ":[range]cbuffer [bufnr]" command. |
657 | 5418 * ":[range]caddbuffer [bufnr]" command. |
798 | 5419 * ":[range]cgetbuffer [bufnr]" command. |
644 | 5420 * ":[range]lbuffer [bufnr]" command. |
657 | 5421 * ":[range]laddbuffer [bufnr]" command. |
798 | 5422 * ":[range]lgetbuffer [bufnr]" command. |
41 | 5423 */ |
5424 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5425 ex_cbuffer(exarg_T *eap) |
41 | 5426 { |
5427 buf_T *buf = NULL; | |
644 | 5428 qf_info_T *qi = &ql_info; |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5429 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5430 char_u *au_name = NULL; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5431 #endif |
644 | 5432 |
798 | 5433 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer |
5434 || eap->cmdidx == CMD_laddbuffer) | |
644 | 5435 { |
5436 qi = ll_get_or_alloc_list(curwin); | |
5437 if (qi == NULL) | |
5438 return; | |
5439 } | |
41 | 5440 |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5441 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5442 switch (eap->cmdidx) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5443 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5444 case CMD_cbuffer: au_name = (char_u *)"cbuffer"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5445 case CMD_cgetbuffer: au_name = (char_u *)"cgetbuffer"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5446 case CMD_caddbuffer: au_name = (char_u *)"caddbuffer"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5447 case CMD_lbuffer: au_name = (char_u *)"lbuffer"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5448 case CMD_lgetbuffer: au_name = (char_u *)"lgetbuffer"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5449 case CMD_laddbuffer: au_name = (char_u *)"laddbuffer"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5450 default: break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5451 } |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5452 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5453 curbuf->b_fname, TRUE, curbuf)) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5454 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5455 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5456 if (aborting()) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5457 return; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5458 # endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5459 } |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5460 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5461 |
41 | 5462 if (*eap->arg == NUL) |
5463 buf = curbuf; | |
5464 else if (*skipwhite(skipdigits(eap->arg)) == NUL) | |
5465 buf = buflist_findnr(atoi((char *)eap->arg)); | |
5466 if (buf == NULL) | |
5467 EMSG(_(e_invarg)); | |
5468 else if (buf->b_ml.ml_mfp == NULL) | |
5469 EMSG(_("E681: Buffer is not loaded")); | |
5470 else | |
5471 { | |
5472 if (eap->addr_count == 0) | |
5473 { | |
5474 eap->line1 = 1; | |
5475 eap->line2 = buf->b_ml.ml_line_count; | |
5476 } | |
5477 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count | |
5478 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) | |
5479 EMSG(_(e_invrange)); | |
5480 else | |
661 | 5481 { |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5482 char_u *qf_title = *eap->cmdlinep; |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5483 |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5484 if (buf->b_sfname) |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5485 { |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5486 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5487 (char *)qf_title, (char *)buf->b_sfname); |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5488 qf_title = IObuff; |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5489 } |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5490 |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
5491 if (qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm, |
798 | 5492 (eap->cmdidx != CMD_caddbuffer |
5493 && eap->cmdidx != CMD_laddbuffer), | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5494 eap->line1, eap->line2, |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
5495 qf_title, NULL) > 0) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5496 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5497 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5498 if (au_name != NULL) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5499 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5500 curbuf->b_fname, TRUE, curbuf); |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5501 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5502 if (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5503 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5504 } |
661 | 5505 } |
41 | 5506 } |
5507 } | |
5508 | |
532 | 5509 #if defined(FEAT_EVAL) || defined(PROTO) |
41 | 5510 /* |
798 | 5511 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command. |
5512 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command. | |
446 | 5513 */ |
5514 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5515 ex_cexpr(exarg_T *eap) |
446 | 5516 { |
5517 typval_T *tv; | |
644 | 5518 qf_info_T *qi = &ql_info; |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5519 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5520 char_u *au_name = NULL; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5521 #endif |
644 | 5522 |
798 | 5523 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr |
5524 || eap->cmdidx == CMD_laddexpr) | |
644 | 5525 { |
5526 qi = ll_get_or_alloc_list(curwin); | |
5527 if (qi == NULL) | |
5528 return; | |
5529 } | |
446 | 5530 |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5531 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5532 switch (eap->cmdidx) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5533 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5534 case CMD_cexpr: au_name = (char_u *)"cexpr"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5535 case CMD_cgetexpr: au_name = (char_u *)"cgetexpr"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5536 case CMD_caddexpr: au_name = (char_u *)"caddexpr"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5537 case CMD_lexpr: au_name = (char_u *)"lexpr"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5538 case CMD_lgetexpr: au_name = (char_u *)"lgetexpr"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5539 case CMD_laddexpr: au_name = (char_u *)"laddexpr"; break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5540 default: break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5541 } |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5542 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5543 curbuf->b_fname, TRUE, curbuf)) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5544 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5545 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5546 if (aborting()) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5547 return; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5548 # endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5549 } |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5550 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5551 |
625 | 5552 /* Evaluate the expression. When the result is a string or a list we can |
5553 * use it to fill the errorlist. */ | |
446 | 5554 tv = eval_expr(eap->arg, NULL); |
625 | 5555 if (tv != NULL) |
5556 { | |
5557 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL) | |
5558 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) | |
5559 { | |
11700
dd821396754e
patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11609
diff
changeset
|
5560 if (qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, |
798 | 5561 (eap->cmdidx != CMD_caddexpr |
5562 && eap->cmdidx != CMD_laddexpr), | |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
5563 (linenr_T)0, (linenr_T)0, *eap->cmdlinep, |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
5564 NULL) > 0) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5565 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5566 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5567 if (au_name != NULL) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5568 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5569 curbuf->b_fname, TRUE, curbuf); |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5570 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5571 if (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5572 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5573 } |
625 | 5574 } |
5575 else | |
626 | 5576 EMSG(_("E777: String or List expected")); |
625 | 5577 free_tv(tv); |
5578 } | |
446 | 5579 } |
532 | 5580 #endif |
446 | 5581 |
5582 /* | |
7 | 5583 * ":helpgrep {pattern}" |
5584 */ | |
5585 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5586 ex_helpgrep(exarg_T *eap) |
7 | 5587 { |
5588 regmatch_T regmatch; | |
5589 char_u *save_cpo; | |
5590 char_u *p; | |
5591 int fcount; | |
5592 char_u **fnames; | |
5593 FILE *fd; | |
5594 int fi; | |
5595 long lnum; | |
9 | 5596 #ifdef FEAT_MULTI_LANG |
5597 char_u *lang; | |
5598 #endif | |
644 | 5599 qf_info_T *qi = &ql_info; |
11195
13c660bd07b2
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5600 qf_info_T *save_qi; |
659 | 5601 int new_qi = FALSE; |
5602 win_T *wp; | |
3269 | 5603 #ifdef FEAT_AUTOCMD |
5604 char_u *au_name = NULL; | |
5605 #endif | |
7 | 5606 |
9 | 5607 #ifdef FEAT_MULTI_LANG |
5608 /* Check for a specified language */ | |
5609 lang = check_help_lang(eap->arg); | |
5610 #endif | |
5611 | |
3269 | 5612 #ifdef FEAT_AUTOCMD |
5613 switch (eap->cmdidx) | |
5614 { | |
5615 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break; | |
5616 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break; | |
5617 default: break; | |
5618 } | |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5619 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5620 curbuf->b_fname, TRUE, curbuf)) |
3269 | 5621 { |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5622 # ifdef FEAT_EVAL |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5623 if (aborting()) |
3269 | 5624 return; |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5625 # endif |
3269 | 5626 } |
5627 #endif | |
5628 | |
5629 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ | |
5630 save_cpo = p_cpo; | |
5631 p_cpo = empty_option; | |
5632 | |
659 | 5633 if (eap->cmdidx == CMD_lhelpgrep) |
5634 { | |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5635 /* If the current window is a help window, then use it */ |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5636 if (bt_help(curwin->w_buffer)) |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5637 wp = curwin; |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5638 else |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5639 /* Find an existing help window */ |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5640 FOR_ALL_WINDOWS(wp) |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5641 if (bt_help(wp->w_buffer)) |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5642 break; |
659 | 5643 |
5644 if (wp == NULL) /* Help window not found */ | |
5645 qi = NULL; | |
5646 else | |
5647 qi = wp->w_llist; | |
5648 | |
5649 if (qi == NULL) | |
5650 { | |
5651 /* Allocate a new location list for help text matches */ | |
5652 if ((qi = ll_new_list()) == NULL) | |
5653 return; | |
5654 new_qi = TRUE; | |
5655 } | |
5656 } | |
5657 | |
11195
13c660bd07b2
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5658 /* Autocommands may change the list. Save it for later comparison */ |
13c660bd07b2
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5659 save_qi = qi; |
13c660bd07b2
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5660 |
7 | 5661 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); |
5662 regmatch.rm_ic = FALSE; | |
5663 if (regmatch.regprog != NULL) | |
5664 { | |
3257 | 5665 #ifdef FEAT_MBYTE |
5666 vimconv_T vc; | |
5667 | |
5668 /* Help files are in utf-8 or latin1, convert lines when 'encoding' | |
5669 * differs. */ | |
5670 vc.vc_type = CONV_NONE; | |
5671 if (!enc_utf8) | |
5672 convert_setup(&vc, (char_u *)"utf-8", p_enc); | |
5673 #endif | |
5674 | |
7 | 5675 /* create a new quickfix list */ |
3965 | 5676 qf_new_list(qi, *eap->cmdlinep); |
7 | 5677 |
5678 /* Go through all directories in 'runtimepath' */ | |
5679 p = p_rtp; | |
5680 while (*p != NUL && !got_int) | |
5681 { | |
5682 copy_option_part(&p, NameBuff, MAXPATHL, ","); | |
5683 | |
5684 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */ | |
5685 add_pathsep(NameBuff); | |
5686 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)"); | |
5687 if (gen_expand_wildcards(1, &NameBuff, &fcount, | |
5688 &fnames, EW_FILE|EW_SILENT) == OK | |
5689 && fcount > 0) | |
5690 { | |
5691 for (fi = 0; fi < fcount && !got_int; ++fi) | |
5692 { | |
9 | 5693 #ifdef FEAT_MULTI_LANG |
5694 /* Skip files for a different language. */ | |
5695 if (lang != NULL | |
5696 && STRNICMP(lang, fnames[fi] | |
5697 + STRLEN(fnames[fi]) - 3, 2) != 0 | |
5698 && !(STRNICMP(lang, "en", 2) == 0 | |
5699 && STRNICMP("txt", fnames[fi] | |
5700 + STRLEN(fnames[fi]) - 3, 3) == 0)) | |
5701 continue; | |
5702 #endif | |
531 | 5703 fd = mch_fopen((char *)fnames[fi], "r"); |
7 | 5704 if (fd != NULL) |
5705 { | |
5706 lnum = 1; | |
5707 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) | |
5708 { | |
3257 | 5709 char_u *line = IObuff; |
5710 #ifdef FEAT_MBYTE | |
5711 /* Convert a line if 'encoding' is not utf-8 and | |
5712 * the line contains a non-ASCII character. */ | |
5713 if (vc.vc_type != CONV_NONE | |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5714 && has_non_ascii(IObuff)) |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5715 { |
3257 | 5716 line = string_convert(&vc, IObuff, NULL); |
5717 if (line == NULL) | |
5718 line = IObuff; | |
5719 } | |
5720 #endif | |
5721 | |
5722 if (vim_regexec(®match, line, (colnr_T)0)) | |
7 | 5723 { |
3257 | 5724 int l = (int)STRLEN(line); |
7 | 5725 |
5726 /* remove trailing CR, LF, spaces, etc. */ | |
3257 | 5727 while (l > 0 && line[l - 1] <= ' ') |
5728 line[--l] = NUL; | |
7 | 5729 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
5730 if (qf_add_entry(qi, |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5731 qi->qf_curlist, |
7 | 5732 NULL, /* dir */ |
5733 fnames[fi], | |
1065 | 5734 0, |
3257 | 5735 line, |
7 | 5736 lnum, |
3257 | 5737 (int)(regmatch.startp[0] - line) |
42 | 5738 + 1, /* col */ |
170 | 5739 FALSE, /* vis_col */ |
230 | 5740 NULL, /* search pattern */ |
7 | 5741 0, /* nr */ |
5742 1, /* type */ | |
5743 TRUE /* valid */ | |
5744 ) == FAIL) | |
5745 { | |
5746 got_int = TRUE; | |
3257 | 5747 #ifdef FEAT_MBYTE |
5748 if (line != IObuff) | |
5749 vim_free(line); | |
5750 #endif | |
7 | 5751 break; |
5752 } | |
5753 } | |
3257 | 5754 #ifdef FEAT_MBYTE |
5755 if (line != IObuff) | |
5756 vim_free(line); | |
5757 #endif | |
7 | 5758 ++lnum; |
5759 line_breakcheck(); | |
5760 } | |
5761 fclose(fd); | |
5762 } | |
5763 } | |
5764 FreeWild(fcount, fnames); | |
5765 } | |
5766 } | |
3257 | 5767 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4371
diff
changeset
|
5768 vim_regfree(regmatch.regprog); |
3257 | 5769 #ifdef FEAT_MBYTE |
5770 if (vc.vc_type != CONV_NONE) | |
5771 convert_setup(&vc, NULL, NULL); | |
5772 #endif | |
7 | 5773 |
644 | 5774 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
5775 qi->qf_lists[qi->qf_curlist].qf_ptr = | |
5776 qi->qf_lists[qi->qf_curlist].qf_start; | |
5777 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
7 | 5778 } |
5779 | |
1672 | 5780 if (p_cpo == empty_option) |
5781 p_cpo = save_cpo; | |
5782 else | |
5783 /* Darn, some plugin changed the value. */ | |
5784 free_string_option(save_cpo); | |
7 | 5785 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
5786 qf_update_buffer(qi, NULL); |
7 | 5787 |
3269 | 5788 #ifdef FEAT_AUTOCMD |
5789 if (au_name != NULL) | |
5790 { | |
5791 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | |
5792 curbuf->b_fname, TRUE, curbuf); | |
11195
13c660bd07b2
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5793 if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL) |
3269 | 5794 /* autocommands made "qi" invalid */ |
5795 return; | |
5796 } | |
5797 #endif | |
5798 | |
7 | 5799 /* Jump to first match. */ |
644 | 5800 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
659 | 5801 qf_jump(qi, 0, 0, FALSE); |
9 | 5802 else |
5803 EMSG2(_(e_nomatch2), eap->arg); | |
659 | 5804 |
5805 if (eap->cmdidx == CMD_lhelpgrep) | |
5806 { | |
5807 /* If the help window is not opened or if it already points to the | |
661 | 5808 * correct location list, then free the new location list. */ |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5809 if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi) |
659 | 5810 { |
5811 if (new_qi) | |
5812 ll_free_all(&qi); | |
5813 } | |
5814 else if (curwin->w_llist == NULL) | |
5815 curwin->w_llist = qi; | |
5816 } | |
7 | 5817 } |
5818 | |
5819 #endif /* FEAT_QUICKFIX */ |