Mercurial > vim
annotate src/quickfix.c @ 11863:e1b0061c5101
Added tag v8.0.0811 for changeset 18cda18a38e20c5b493e1f3854b8616f2bcaee26
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 30 Jul 2017 14:00:05 +0200 |
parents | 5ceaecedbad2 |
children | ebd313aa5a6c |
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 { |
230 | 61 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
|
62 qfline_T *qf_last; /* pointer to the last error */ |
230 | 63 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
|
64 int qf_count; /* number of errors (0 means empty list) */ |
230 | 65 int qf_index; /* current index in the error list */ |
66 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
|
67 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
|
68 * 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
|
69 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
|
70 |
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 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 int qf_multiscan; |
644 | 78 } qf_list_T; |
79 | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
80 /* |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
81 * 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
|
82 * 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
|
83 */ |
644 | 84 struct qf_info_S |
85 { | |
86 /* | |
87 * Count of references to this list. Used only for location lists. | |
88 * When a location list window reference this list, qf_refcount | |
89 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount | |
90 * reaches 0, the list is freed. | |
91 */ | |
92 int qf_refcount; | |
93 int qf_listcount; /* current number of lists */ | |
94 int qf_curlist; /* current error list */ | |
95 qf_list_T qf_lists[LISTCOUNT]; | |
96 }; | |
97 | |
98 static qf_info_T ql_info; /* global quickfix list */ | |
7 | 99 |
230 | 100 #define FMT_PATTERNS 10 /* maximum number of % recognized */ |
7 | 101 |
102 /* | |
103 * Structure used to hold the info of one part of 'errorformat' | |
104 */ | |
789 | 105 typedef struct efm_S efm_T; |
106 struct efm_S | |
7 | 107 { |
108 regprog_T *prog; /* pre-formatted part of 'errorformat' */ | |
789 | 109 efm_T *next; /* pointer to next (NULL if last) */ |
7 | 110 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */ |
111 char_u prefix; /* prefix of this format line: */ | |
112 /* 'D' enter directory */ | |
113 /* 'X' leave directory */ | |
114 /* 'A' start of multi-line message */ | |
115 /* 'E' error message */ | |
116 /* 'W' warning message */ | |
117 /* 'I' informational message */ | |
118 /* 'C' continuation line */ | |
119 /* 'Z' end of multi-line message */ | |
120 /* 'G' general, unspecific message */ | |
121 /* 'P' push file (partial) message */ | |
122 /* 'Q' pop/quit file (partial) message */ | |
123 /* 'O' overread (partial) message */ | |
124 char_u flags; /* additional flags given in prefix */ | |
125 /* '-' do not include this line */ | |
625 | 126 /* '+' include whole line in message */ |
789 | 127 int conthere; /* %> used */ |
7 | 128 }; |
129 | |
10367
4e4e116e3689
commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
130 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
|
131 |
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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 static void qf_clean_dir_stack(struct dir_stack_T **); |
7 | 146 #ifdef FEAT_WINDOWS |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last); |
7 | 154 #endif |
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 | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
185 qf_init( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
186 win_T *wp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
187 char_u *efile, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
188 char_u *errorformat, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
189 int newlist, /* TRUE: start a new error list */ |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
190 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
|
191 char_u *enc) |
7 | 192 { |
644 | 193 qf_info_T *qi = &ql_info; |
194 | |
195 if (wp != NULL) | |
665 | 196 { |
197 qi = ll_get_or_alloc_list(wp); | |
198 if (qi == NULL) | |
199 return FAIL; | |
200 } | |
644 | 201 |
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
|
202 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
|
203 newlist, (linenr_T)0, (linenr_T)0, qf_title, enc); |
41 | 204 } |
205 | |
206 /* | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
207 * 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
|
208 */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
209 #define LINE_MAXLEN 4096 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
210 |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
211 static struct fmtpattern |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
212 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
213 char_u convchar; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
214 char *pattern; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
215 } fmt_pat[FMT_PATTERNS] = |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
216 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
217 {'f', ".\\+"}, /* only used when at end */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
218 {'n', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
219 {'l', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
220 {'c', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
221 {'t', "."}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
222 {'m', ".\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
223 {'r', ".*"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
224 {'p', "[- .]*"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
225 {'v', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
226 {'s', ".\\+"} |
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 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
230 * 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
|
231 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
232 static int |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
233 efm_to_regpat( |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
234 char_u *efm, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
235 int len, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
236 efm_T *fmt_ptr, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
237 char_u *regpat, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
238 char_u *errmsg) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
239 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
240 char_u *ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
241 char_u *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
242 char_u *srcptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
243 int round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
244 int idx = 0; |
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 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
247 * 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
|
248 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
249 ptr = regpat; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
250 *ptr++ = '^'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
251 round = 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
252 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
|
253 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
254 if (*efmp == '%') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
255 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
256 ++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
257 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
|
258 if (fmt_pat[idx].convchar == *efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
259 break; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
260 if (idx < FMT_PATTERNS) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
261 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
262 if (fmt_ptr->addr[idx]) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
263 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
264 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
265 _("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
|
266 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
267 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
268 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
269 if ((idx |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
270 && idx < 6 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
271 && vim_strchr((char_u *)"DXOPQ", |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
272 fmt_ptr->prefix) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
273 || (idx == 6 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
274 && vim_strchr((char_u *)"OPQ", |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
275 fmt_ptr->prefix) == NULL)) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
276 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
277 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
278 _("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
|
279 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
280 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
281 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
282 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
|
283 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
284 *ptr++ = '('; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
285 #ifdef BACKSLASH_IN_FILENAME |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
286 if (*efmp == 'f') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
287 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
288 /* 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
|
289 * checking for a colon next: "%f:". |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
290 * "\%(\a:\)\=" */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
291 STRCPY(ptr, "\\%(\\a:\\)\\="); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
292 ptr += 10; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
293 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
294 #endif |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
295 if (*efmp == 'f' && efmp[1] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
296 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
297 if (efmp[1] != '\\' && efmp[1] != '%') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
298 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
299 /* 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
|
300 * 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
|
301 * 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
|
302 * 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
|
303 * follows should work. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
304 STRCPY(ptr, ".\\{-1,}"); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
305 ptr += 7; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
306 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
307 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
308 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
309 /* 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
|
310 * many file name chars as possible. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
311 STRCPY(ptr, "\\f\\+"); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
312 ptr += 4; |
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 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
315 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
316 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
317 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
|
318 while ((*ptr = *srcptr++) != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
319 ++ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
320 } |
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 *ptr++ = ')'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
323 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
324 else if (*efmp == '*') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
325 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
326 if (*++efmp == '[' || *efmp == '\\') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
327 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
328 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
|
329 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
330 if (efmp[1] == '^') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
331 *ptr++ = *++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
332 if (efmp < efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
333 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
334 *ptr++ = *++efmp; /* could be ']' */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
335 while (efmp < efm + len |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
336 && (*ptr++ = *++efmp) != ']') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
337 /* skip */; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
338 if (efmp == efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
339 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
340 EMSG(_("E374: Missing ] in format string")); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
341 return -1; |
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 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
345 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
|
346 *ptr++ = *++efmp; |
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 *ptr++ = '+'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
349 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
350 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
351 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
352 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
353 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
354 _("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
|
355 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
356 return -1; |
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 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
359 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
|
360 *ptr++ = *efmp; /* regexp magic characters */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
361 else if (*efmp == '#') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
362 *ptr++ = '*'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
363 else if (*efmp == '>') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
364 fmt_ptr->conthere = TRUE; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
365 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
|
366 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
367 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
|
368 fmt_ptr->flags = *efmp++; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
369 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
|
370 fmt_ptr->prefix = *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
371 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
372 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
373 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
374 _("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
|
375 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
376 return -1; |
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 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
379 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
380 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
381 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
382 _("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
|
383 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
384 return -1; |
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 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
387 else /* copy normal character */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
388 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
389 if (*efmp == '\\' && efmp + 1 < efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
390 ++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
391 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
|
392 *ptr++ = '\\'; /* escape regexp atoms */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
393 if (*efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
394 *ptr++ = *efmp; |
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 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
397 *ptr++ = '$'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
398 *ptr = NUL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
399 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
400 return 0; |
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 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
403 static void |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
404 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
|
405 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
406 efm_T *efm_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
407 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
408 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
|
409 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
410 *efm_first = efm_ptr->next; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
411 vim_regfree(efm_ptr->prog); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
412 vim_free(efm_ptr); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
413 } |
10367
4e4e116e3689
commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
414 fmt_start = NULL; |
9365
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 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
417 /* Parse 'errorformat' option */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
418 static efm_T * |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
419 parse_efm_option(char_u *efm) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
420 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
421 char_u *errmsg = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
422 int errmsglen; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
423 efm_T *fmt_ptr = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
424 efm_T *fmt_first = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
425 efm_T *fmt_last = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
426 char_u *fmtstr = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
427 int len; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
428 int i; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
429 int round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
430 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
431 errmsglen = CMDBUFFSIZE + 1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
432 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
|
433 if (errmsg == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
434 goto parse_efm_end; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
435 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
436 /* |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
437 * 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
|
438 * 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
|
439 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
440 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
441 /* |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
442 * 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
|
443 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
444 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
|
445 for (round = FMT_PATTERNS; round > 0; ) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
446 i += (int)STRLEN(fmt_pat[--round].pattern); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
447 #ifdef COLON_IN_FILENAME |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
448 i += 12; /* "%f" can become twelve chars longer */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
449 #else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
450 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
|
451 #endif |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
452 if ((fmtstr = alloc(i)) == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
453 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
454 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
455 while (efm[0] != NUL) |
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 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
458 * 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
|
459 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
460 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
|
461 if (fmt_ptr == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
462 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
463 if (fmt_first == NULL) /* first one */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
464 fmt_first = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
465 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
466 fmt_last->next = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
467 fmt_last = fmt_ptr; |
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 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
470 * 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
|
471 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
472 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
|
473 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
|
474 ++len; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
475 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
476 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
|
477 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
478 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
|
479 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
480 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
481 * Advance to next part |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
482 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
483 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
|
484 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
485 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
486 if (fmt_first == NULL) /* nothing found */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
487 EMSG(_("E378: 'errorformat' contains no pattern")); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
488 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
489 goto parse_efm_end; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
490 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
491 parse_efm_error: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
492 free_efm_list(&fmt_first); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
493 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
494 parse_efm_end: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
495 vim_free(fmtstr); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
496 vim_free(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
497 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
498 return fmt_first; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
499 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
500 |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
501 enum { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
502 QF_FAIL = 0, |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
503 QF_OK = 1, |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
504 QF_END_OF_INPUT = 2, |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
505 QF_NOMEM = 3, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
506 QF_IGNORE_LINE = 4 |
9531
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
509 typedef struct { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
510 char_u *linebuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
511 int linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
512 char_u *growbuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
513 int growbufsiz; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
514 FILE *fd; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
515 typval_T *tv; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
516 char_u *p_str; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
517 listitem_T *p_li; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
518 buf_T *buf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
519 linenr_T buflnum; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
520 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
|
521 vimconv_T vc; |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
522 } qfstate_T; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
523 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
524 static char_u * |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
525 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
|
526 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
527 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
528 * 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
|
529 * 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
|
530 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
531 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
|
532 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
533 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
534 state->growbuf = alloc(state->linelen + 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
535 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
536 return NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
537 state->growbufsiz = state->linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
538 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
539 else if (state->linelen > state->growbufsiz) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
540 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
541 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
|
542 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
543 return NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
544 state->growbufsiz = state->linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
545 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
546 return state->growbuf; |
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 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
550 * 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
|
551 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
552 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
553 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
|
554 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
555 /* 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
|
556 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
|
557 char_u *p; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
558 int len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
559 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
560 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
|
561 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
562 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
563 p = vim_strchr(p_str, '\n'); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
564 if (p != NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
565 len = (int)(p - p_str) + 1; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
566 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
567 len = (int)STRLEN(p_str); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
568 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
569 if (len > IOSIZE - 2) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
570 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
571 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
|
572 if (state->linebuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
573 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
574 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
575 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
576 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
577 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
578 state->linelen = len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
579 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
580 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
|
581 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
582 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
583 * 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
|
584 * line if it exceeds LINE_MAXLEN. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
585 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
586 p_str += len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
587 state->p_str = p_str; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
588 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
589 return QF_OK; |
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 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
593 * 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
|
594 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
595 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
596 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
|
597 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
598 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
|
599 int len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
600 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
601 while (p_li != NULL |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
602 && (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
|
603 || 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
|
604 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
|
605 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
606 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
|
607 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
608 state->p_li = NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
609 return QF_END_OF_INPUT; |
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
612 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
|
613 if (len > IOSIZE - 2) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
614 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
615 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
|
616 if (state->linebuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
617 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
618 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
619 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
620 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
621 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
622 state->linelen = len; |
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
625 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
|
626 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
627 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
|
628 return QF_OK; |
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 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
632 * 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
|
633 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
634 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
635 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
|
636 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
637 char_u *p_buf = NULL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
638 int len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
639 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
640 /* 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
|
641 if (state->buflnum > state->lnumlast) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
642 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
643 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
644 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
|
645 state->buflnum += 1; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
646 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
647 len = (int)STRLEN(p_buf); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
648 if (len > IOSIZE - 2) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
649 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
650 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
|
651 if (state->linebuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
652 return QF_NOMEM; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
653 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
654 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
655 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
656 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
657 state->linelen = len; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
658 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
659 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
|
660 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
661 return QF_OK; |
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 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
665 * 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
|
666 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
667 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
668 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
|
669 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
670 int discard; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
671 int growbuflen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
672 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
673 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
|
674 return QF_END_OF_INPUT; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
675 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
676 discard = FALSE; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
677 state->linelen = (int)STRLEN(IObuff); |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
678 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
|
679 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
680 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
681 * 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
|
682 * 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
|
683 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
684 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
685 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
686 state->growbufsiz = 2 * (IOSIZE - 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
687 state->growbuf = alloc(state->growbufsiz); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
688 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
689 return QF_NOMEM; |
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
692 /* 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
|
693 memcpy(state->growbuf, IObuff, IOSIZE - 1); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
694 growbuflen = state->linelen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
695 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
696 for (;;) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
697 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
698 if (fgets((char *)state->growbuf + growbuflen, |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
699 state->growbufsiz - growbuflen, state->fd) == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
700 break; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
701 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
|
702 growbuflen += state->linelen; |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
703 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
|
704 break; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
705 if (state->growbufsiz == LINE_MAXLEN) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
706 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
707 discard = TRUE; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
708 break; |
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
711 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
|
712 ? 2 * state->growbufsiz : LINE_MAXLEN; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
713 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
|
714 if (state->growbuf == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
715 return QF_NOMEM; |
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
718 while (discard) |
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 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
721 * 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
|
722 * 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
|
723 * reached. |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
724 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
725 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
|
726 || (int)STRLEN(IObuff) < IOSIZE - 1 |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
727 || IObuff[IOSIZE - 1] == '\n') |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
728 break; |
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 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
731 state->linebuf = state->growbuf; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
732 state->linelen = growbuflen; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
733 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
734 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
735 state->linebuf = IObuff; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
736 |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
737 #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
|
738 /* 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
|
739 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
|
740 { |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
741 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
|
742 |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
743 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
|
744 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
|
745 { |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
746 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
|
747 { |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
748 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
|
749 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
|
750 } |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
751 else |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
752 { |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 ? 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
|
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 } |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
760 #endif |
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
761 |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
762 return QF_OK; |
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 /* |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
766 * 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
|
767 */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
768 static int |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
769 qf_get_nextline(qfstate_T *state) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
770 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
771 int status = QF_FAIL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
772 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
773 if (state->fd == NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
774 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
775 if (state->tv != NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
776 { |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
777 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
|
778 /* 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
|
779 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
|
780 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
|
781 /* 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
|
782 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
|
783 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
784 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
785 /* 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
|
786 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
|
787 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
788 else |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
789 /* 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
|
790 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
|
791 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
792 if (status != QF_OK) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
793 return status; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
794 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
795 /* remove newline/CR from the line */ |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
796 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
|
797 { |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
798 state->linebuf[state->linelen - 1] = NUL; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
799 #ifdef USE_CRNL |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
800 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
|
801 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
|
802 #endif |
9738
6818e3c96473
commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
803 } |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
804 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
805 #ifdef FEAT_MBYTE |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
806 remove_bom(state->linebuf); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
807 #endif |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
808 |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
809 return QF_OK; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
810 } |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
811 |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
812 typedef struct { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
813 char_u *namebuf; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
814 char_u *errmsg; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
815 int errmsglen; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
816 long lnum; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
817 int col; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
818 char_u use_viscol; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
819 char_u *pattern; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
820 int enr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
821 int type; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
822 int valid; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
823 } qffields_T; |
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 /* |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
826 * 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
|
827 * Return the QF_ status. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
828 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
829 static int |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
830 qf_parse_line( |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
831 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
|
832 int qf_idx, |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
833 char_u *linebuf, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
834 int linelen, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
835 efm_T *fmt_first, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
836 qffields_T *fields) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
837 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
838 efm_T *fmt_ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
839 char_u *ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
840 int len; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
841 int i; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
842 int idx = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
843 char_u *tail = NULL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
844 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
|
845 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
|
846 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
847 /* 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
|
848 regmatch.rm_ic = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
849 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
850 /* 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
|
851 if (fmt_start == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
852 fmt_ptr = fmt_first; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
853 else |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
854 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
855 fmt_ptr = fmt_start; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
856 fmt_start = NULL; |
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 /* |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
860 * 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
|
861 * match or no match. |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
862 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
863 fields->valid = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
864 restofline: |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
865 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
|
866 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
867 int r; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
868 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
869 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
|
870 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
|
871 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
872 fields->namebuf[0] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
873 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
|
874 if (!qfl->qf_multiscan) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
875 fields->errmsg[0] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
876 fields->lnum = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
877 fields->col = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
878 fields->use_viscol = FALSE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
879 fields->enr = -1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
880 fields->type = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
881 tail = NULL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
882 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
883 regmatch.regprog = fmt_ptr->prog; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
884 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
|
885 fmt_ptr->prog = regmatch.regprog; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
886 if (r) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
887 { |
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
|
888 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
|
889 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
890 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
|
891 fields->type = idx; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
892 else |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
893 fields->type = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
894 /* |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
895 * 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
|
896 * 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
|
897 * 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
|
898 */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
899 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
|
900 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
901 int c; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
902 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
903 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
|
904 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
905 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
906 /* 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
|
907 c = *regmatch.endp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
908 *regmatch.endp[i] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
909 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
|
910 *regmatch.endp[i] = c; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
911 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
912 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
|
913 && mch_getperm(fields->namebuf) == -1) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
914 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
915 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
916 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
|
917 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
918 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
919 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
920 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
|
921 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
922 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
|
923 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
924 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
925 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
926 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
|
927 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
928 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
|
929 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
930 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
931 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
932 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
|
933 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
934 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
|
935 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
936 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
937 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
938 fields->type = *regmatch.startp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
939 } |
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
|
940 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
|
941 { |
11426
3270f080bf0a
patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents:
11422
diff
changeset
|
942 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
|
943 { |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
944 /* linelen + null terminator */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
945 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
|
946 linelen + 1)) == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
947 return QF_NOMEM; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
948 fields->errmsglen = linelen + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
949 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
950 vim_strncpy(fields->errmsg, linebuf, linelen); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
951 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
952 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
|
953 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
954 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
|
955 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
956 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
|
957 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
|
958 { |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
959 /* len + null terminator */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
960 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
|
961 == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
962 return QF_NOMEM; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
963 fields->errmsglen = len + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
964 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
965 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
|
966 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
967 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
|
968 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
969 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
970 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
971 tail = regmatch.startp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
972 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
973 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
|
974 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
975 char_u *match_ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
976 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
977 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
|
978 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
979 fields->col = 0; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
980 for (match_ptr = regmatch.startp[i]; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
981 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
|
982 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
983 ++fields->col; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
984 if (*match_ptr == TAB) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
985 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
986 fields->col += 7; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
987 fields->col -= fields->col % 8; |
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 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
990 ++fields->col; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
991 fields->use_viscol = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
992 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
993 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
|
994 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
995 if (regmatch.startp[i] == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
996 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
997 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
|
998 fields->use_viscol = TRUE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
999 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1000 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
|
1001 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1002 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
|
1003 continue; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1004 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
|
1005 if (len > CMDBUFFSIZE - 5) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1006 len = CMDBUFFSIZE - 5; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1007 STRCPY(fields->pattern, "^\\V"); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1008 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
|
1009 fields->pattern[len + 3] = '\\'; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1010 fields->pattern[len + 4] = '$'; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1011 fields->pattern[len + 5] = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1012 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1013 break; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1014 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1015 } |
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
|
1016 qfl->qf_multiscan = FALSE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1017 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1018 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
|
1019 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1020 if (fmt_ptr != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1021 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1022 if (idx == 'D') /* enter directory */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1023 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1024 if (*fields->namebuf == NUL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1025 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1026 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
|
1027 return QF_FAIL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1028 } |
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
|
1029 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
|
1030 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
|
1031 if (qfl->qf_directory == NULL) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1032 return QF_FAIL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1033 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1034 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
|
1035 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
|
1036 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 { |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1042 /* linelen + null terminator */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1043 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
|
1044 linelen + 1)) == NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1045 return QF_NOMEM; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1046 fields->errmsglen = linelen + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1047 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1048 /* copy whole line to error message */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1049 vim_strncpy(fields->errmsg, linebuf, linelen); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1050 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
|
1051 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
|
1052 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1053 else if (fmt_ptr != NULL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1054 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1055 /* honor %> item */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1056 if (fmt_ptr->conthere) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1057 fmt_start = fmt_ptr; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1058 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1059 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
|
1060 { |
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
|
1061 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
|
1062 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
|
1063 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1064 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
|
1065 { /* 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
|
1066 if (!qfl->qf_multiignore) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1067 { |
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
|
1068 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
|
1069 |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1070 if (qfprev == NULL) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1071 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
|
1072 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
|
1073 { |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1074 len = (int)STRLEN(qfprev->qf_text); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1075 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
|
1076 == NULL) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1077 return QF_FAIL; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1078 STRCPY(ptr, qfprev->qf_text); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1079 vim_free(qfprev->qf_text); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1080 qfprev->qf_text = ptr; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1081 *(ptr += len) = '\n'; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1082 STRCPY(++ptr, fields->errmsg); |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1083 } |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1084 if (qfprev->qf_nr == -1) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1085 qfprev->qf_nr = fields->enr; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1086 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
|
1087 /* only printable chars allowed */ |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1088 qfprev->qf_type = fields->type; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1089 |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1090 if (!qfprev->qf_lnum) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1091 qfprev->qf_lnum = fields->lnum; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1092 if (!qfprev->qf_col) |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1093 qfprev->qf_col = fields->col; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1094 qfprev->qf_viscol = fields->use_viscol; |
2d0e6034743a
commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents:
10237
diff
changeset
|
1095 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
|
1096 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
|
1097 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
|
1098 *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
|
1099 ? 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
|
1100 : 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
|
1101 ? qfl->qf_currfile : 0); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1102 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1103 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
|
1104 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
|
1105 line_breakcheck(); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1106 return QF_IGNORE_LINE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1107 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1108 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
|
1109 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1110 /* global file names */ |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1111 fields->valid = FALSE; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1112 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
|
1113 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1114 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
|
1115 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
|
1116 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
|
1117 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
|
1118 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
|
1119 *fields->namebuf = NUL; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1120 if (tail && *tail) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1121 { |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1122 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
|
1123 qfl->qf_multiscan = TRUE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1124 goto restofline; |
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 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1128 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
|
1129 { |
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
|
1130 if (qfl->qf_multiline) |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1131 /* 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
|
1132 qfl->qf_multiignore = TRUE; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1133 return QF_IGNORE_LINE; |
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 |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1137 return QF_OK; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1138 } |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1139 |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1140 /* |
41 | 1141 * Read the errorfile "efile" into memory, line by line, building the error |
1142 * list. | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1143 * 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
|
1144 * Alternative: when "tv" is not NULL get errors from the string or list. |
41 | 1145 * 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
|
1146 * 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
|
1147 * Set the title of the list to "qf_title". |
41 | 1148 * Return -1 for error, number of errors for success. |
1149 */ | |
1150 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1151 qf_init_ext( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1152 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
|
1153 int qf_idx, |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1154 char_u *efile, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1155 buf_T *buf, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1156 typval_T *tv, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1157 char_u *errorformat, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1158 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
|
1159 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
|
1160 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
|
1161 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
|
1162 char_u *enc) |
41 | 1163 { |
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
|
1164 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
|
1165 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
|
1166 qffields_T fields; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1167 #ifdef FEAT_WINDOWS |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1168 qfline_T *old_last = NULL; |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
1169 #endif |
10369
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1170 int adding = FALSE; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1171 static efm_T *fmt_first = NULL; |
7 | 1172 char_u *efm; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1173 static char_u *last_efm = NULL; |
7 | 1174 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
|
1175 int status; |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1176 |
11443
30b3775addb2
patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents:
11426
diff
changeset
|
1177 /* 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
|
1178 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
|
1179 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
|
1180 |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
1181 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
|
1182 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
|
1183 #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
|
1184 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
|
1185 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
|
1186 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
|
1187 #endif |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1188 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
|
1189 fields.errmsglen = CMDBUFFSIZE + 1; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1190 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
|
1191 fields.pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1192 if (fields.namebuf == NULL || fields.errmsg == NULL || |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1193 fields.pattern == NULL) |
7 | 1194 goto qf_init_end; |
1195 | |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1196 if (efile != NULL && (state.fd = mch_fopen((char *)efile, "r")) == NULL) |
7 | 1197 { |
1198 EMSG2(_(e_openerrf), efile); | |
1199 goto qf_init_end; | |
1200 } | |
1201 | |
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 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
|
1203 { |
7 | 1204 /* make place for a new list */ |
3965 | 1205 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
|
1206 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
|
1207 } |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
1208 else |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1209 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1210 /* 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
|
1211 adding = TRUE; |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
1212 #ifdef FEAT_WINDOWS |
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
|
1213 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
|
1214 old_last = qi->qf_lists[qf_idx].qf_last; |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
1215 #endif |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1216 } |
7 | 1217 |
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
|
1218 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
|
1219 |
7 | 1220 /* Use the local value of 'errorformat' if it's set. */ |
446 | 1221 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) |
41 | 1222 efm = buf->b_p_efm; |
7 | 1223 else |
1224 efm = errorformat; | |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
1225 |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1226 /* |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1227 * 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
|
1228 * previously parsed values. |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1229 */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1230 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
|
1231 { |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1232 /* free the previously parsed data */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1233 vim_free(last_efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1234 last_efm = NULL; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1235 free_efm_list(&fmt_first); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1236 |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1237 /* parse the current 'efm' */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1238 fmt_first = parse_efm_option(efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1239 if (fmt_first != NULL) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1240 last_efm = vim_strsave(efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1241 } |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1242 |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
1243 if (fmt_first == NULL) /* nothing found */ |
7 | 1244 goto error2; |
1245 | |
1246 /* | |
1247 * got_int is reset here, because it was probably set when killing the | |
1248 * ":make" command, but we still want to read the errorfile then. | |
1249 */ | |
1250 got_int = FALSE; | |
1251 | |
446 | 1252 if (tv != NULL) |
1253 { | |
1254 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
|
1255 state.p_str = tv->vval.v_string; |
446 | 1256 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
|
1257 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
|
1258 state.tv = tv; |
446 | 1259 } |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1260 state.buf = buf; |
9534
340106787852
commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents:
9531
diff
changeset
|
1261 state.buflnum = lnumfirst; |
340106787852
commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents:
9531
diff
changeset
|
1262 state.lnumlast = lnumlast; |
446 | 1263 |
7 | 1264 /* |
1265 * Read the lines in the error file one by one. | |
1266 * Try to recognize one of the error formats in each line. | |
1267 */ | |
41 | 1268 while (!got_int) |
7 | 1269 { |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1270 /* 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
|
1271 status = qf_get_nextline(&state); |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1272 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
|
1273 goto qf_init_end; |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1274 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
|
1275 break; |
7 | 1276 |
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
|
1277 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
|
1278 fmt_first, &fields); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1279 if (status == QF_FAIL) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1280 goto error2; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1281 if (status == QF_NOMEM) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1282 goto qf_init_end; |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1283 if (status == QF_IGNORE_LINE) |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1284 continue; |
7 | 1285 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1286 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
|
1287 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
|
1288 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
|
1289 (*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
|
1290 ? 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
|
1291 : ((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
|
1292 ? qfl->qf_currfile : (char_u *)NULL), |
1065 | 1293 0, |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1294 fields.errmsg, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1295 fields.lnum, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1296 fields.col, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1297 fields.use_viscol, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1298 fields.pattern, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1299 fields.enr, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1300 fields.type, |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1301 fields.valid) == FAIL) |
7 | 1302 goto error2; |
1303 line_breakcheck(); | |
1304 } | |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1305 if (state.fd == NULL || !ferror(state.fd)) |
7 | 1306 { |
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
|
1307 if (qfl->qf_index == 0) |
7 | 1308 { |
644 | 1309 /* 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
|
1310 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
|
1311 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
|
1312 qfl->qf_nonevalid = TRUE; |
7 | 1313 } |
1314 else | |
1315 { | |
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
|
1316 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
|
1317 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
|
1318 qfl->qf_ptr = qfl->qf_start; |
7 | 1319 } |
644 | 1320 /* 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
|
1321 retval = qfl->qf_count; |
9369
ce5b79b005ec
commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents:
9365
diff
changeset
|
1322 goto qf_init_end; |
7 | 1323 } |
1324 EMSG(_(e_readerrf)); | |
1325 error2: | |
10369
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1326 if (!adding) |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1327 { |
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
|
1328 /* 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
|
1329 qf_free(qi, qi->qf_curlist); |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1330 qi->qf_listcount--; |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1331 if (qi->qf_curlist > 0) |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1332 --qi->qf_curlist; |
4e5b307638cb
commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents:
10367
diff
changeset
|
1333 } |
9369
ce5b79b005ec
commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents:
9365
diff
changeset
|
1334 qf_init_end: |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1335 if (state.fd != NULL) |
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1336 fclose(state.fd); |
9568
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1337 vim_free(fields.namebuf); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1338 vim_free(fields.errmsg); |
ccbd2e604e59
commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents:
9540
diff
changeset
|
1339 vim_free(fields.pattern); |
9531
50697f3b49d6
commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1340 vim_free(state.growbuf); |
7 | 1341 |
1342 #ifdef FEAT_WINDOWS | |
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
|
1343 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
|
1344 qf_update_buffer(qi, old_last); |
7 | 1345 #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
|
1346 #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
|
1347 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
|
1348 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
|
1349 #endif |
7 | 1350 |
1351 return retval; | |
1352 } | |
1353 | |
6079 | 1354 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
|
1355 qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) |
6079 | 1356 { |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1357 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
|
1358 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
|
1359 |
6079 | 1360 if (title != NULL) |
1361 { | |
1362 char_u *p = alloc((int)STRLEN(title) + 2); | |
1363 | |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1364 qi->qf_lists[qf_idx].qf_title = p; |
6079 | 1365 if (p != NULL) |
1366 sprintf((char *)p, ":%s", (char *)title); | |
1367 } | |
1368 } | |
1369 | |
7 | 1370 /* |
1371 * Prepare for adding a new quickfix list. | |
1372 */ | |
1373 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1374 qf_new_list(qf_info_T *qi, char_u *qf_title) |
7 | 1375 { |
1376 int i; | |
1377 | |
1378 /* | |
6079 | 1379 * If the current entry is not the last entry, delete entries beyond |
7 | 1380 * the current entry. This makes it possible to browse in a tree-like |
1381 * way with ":grep'. | |
1382 */ | |
644 | 1383 while (qi->qf_listcount > qi->qf_curlist + 1) |
1384 qf_free(qi, --qi->qf_listcount); | |
7 | 1385 |
1386 /* | |
1387 * When the stack is full, remove to oldest entry | |
1388 * Otherwise, add a new entry. | |
1389 */ | |
644 | 1390 if (qi->qf_listcount == LISTCOUNT) |
7 | 1391 { |
644 | 1392 qf_free(qi, 0); |
7 | 1393 for (i = 1; i < LISTCOUNT; ++i) |
644 | 1394 qi->qf_lists[i - 1] = qi->qf_lists[i]; |
1395 qi->qf_curlist = LISTCOUNT - 1; | |
7 | 1396 } |
1397 else | |
644 | 1398 qi->qf_curlist = qi->qf_listcount++; |
3259 | 1399 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
|
1400 qf_store_title(qi, qi->qf_curlist, qf_title); |
7 | 1401 } |
1402 | |
644 | 1403 /* |
1404 * Free a location list | |
1405 */ | |
1406 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1407 ll_free_all(qf_info_T **pqi) |
359 | 1408 { |
1409 int i; | |
644 | 1410 qf_info_T *qi; |
1411 | |
1412 qi = *pqi; | |
1413 if (qi == NULL) | |
1414 return; | |
1415 *pqi = NULL; /* Remove reference to this list */ | |
1416 | |
1417 qi->qf_refcount--; | |
1418 if (qi->qf_refcount < 1) | |
1419 { | |
1420 /* No references to this location list */ | |
1421 for (i = 0; i < qi->qf_listcount; ++i) | |
1422 qf_free(qi, i); | |
1423 vim_free(qi); | |
1424 } | |
359 | 1425 } |
644 | 1426 |
1427 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1428 qf_free_all(win_T *wp) |
644 | 1429 { |
1430 int i; | |
1431 qf_info_T *qi = &ql_info; | |
1432 | |
1433 if (wp != NULL) | |
1434 { | |
1435 /* location list */ | |
1436 ll_free_all(&wp->w_llist); | |
1437 ll_free_all(&wp->w_llist_ref); | |
1438 } | |
1439 else | |
1440 /* quickfix list */ | |
1441 for (i = 0; i < qi->qf_listcount; ++i) | |
1442 qf_free(qi, i); | |
1443 } | |
359 | 1444 |
7 | 1445 /* |
1446 * Add an entry to the end of the list of errors. | |
1447 * Returns OK or FAIL. | |
1448 */ | |
1449 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1450 qf_add_entry( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1451 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
|
1452 int qf_idx, /* list index */ |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1453 char_u *dir, /* optional directory name */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1454 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
|
1455 int bufnum, /* buffer number or zero */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1456 char_u *mesg, /* message */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1457 long lnum, /* line number */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1458 int col, /* column */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1459 int vis_col, /* using visual column */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1460 char_u *pattern, /* search pattern */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1461 int nr, /* error number */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1462 int type, /* type character */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1463 int valid) /* valid entry */ |
7 | 1464 { |
230 | 1465 qfline_T *qfp; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1466 qfline_T **lastp; /* pointer to qf_last or NULL */ |
7 | 1467 |
230 | 1468 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) |
7 | 1469 return FAIL; |
1065 | 1470 if (bufnum != 0) |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1471 { |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1472 buf_T *buf = buflist_findnr(bufnum); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1473 |
1065 | 1474 qfp->qf_fnum = bufnum; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1475 if (buf != NULL) |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1476 buf->b_has_qf_entry |= |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1477 (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
|
1478 } |
1065 | 1479 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
|
1480 qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname); |
7 | 1481 if ((qfp->qf_text = vim_strsave(mesg)) == NULL) |
1482 { | |
1483 vim_free(qfp); | |
1484 return FAIL; | |
1485 } | |
1486 qfp->qf_lnum = lnum; | |
1487 qfp->qf_col = col; | |
170 | 1488 qfp->qf_viscol = vis_col; |
230 | 1489 if (pattern == NULL || *pattern == NUL) |
1490 qfp->qf_pattern = NULL; | |
1491 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) | |
1492 { | |
1493 vim_free(qfp->qf_text); | |
1494 vim_free(qfp); | |
1495 return FAIL; | |
1496 } | |
7 | 1497 qfp->qf_nr = nr; |
1498 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */ | |
1499 type = 0; | |
1500 qfp->qf_type = type; | |
1501 qfp->qf_valid = valid; | |
1502 | |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1503 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
|
1504 if (qi->qf_lists[qf_idx].qf_count == 0) |
644 | 1505 /* first element in the list */ |
7 | 1506 { |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1507 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
|
1508 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
|
1509 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
|
1510 qfp->qf_prev = NULL; |
7 | 1511 } |
1512 else | |
1513 { | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1514 qfp->qf_prev = *lastp; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1515 (*lastp)->qf_next = qfp; |
7 | 1516 } |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1517 qfp->qf_next = NULL; |
7 | 1518 qfp->qf_cleared = FALSE; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1519 *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
|
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 if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid) |
644 | 1522 /* first valid entry */ |
7 | 1523 { |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
1524 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
|
1525 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
|
1526 qi->qf_lists[qf_idx].qf_ptr = qfp; |
7 | 1527 } |
1528 | |
1529 return OK; | |
1530 } | |
1531 | |
1532 /* | |
659 | 1533 * Allocate a new location list |
644 | 1534 */ |
659 | 1535 static qf_info_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1536 ll_new_list(void) |
644 | 1537 { |
659 | 1538 qf_info_T *qi; |
1539 | |
1540 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T)); | |
1541 if (qi != NULL) | |
1542 { | |
1543 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T))); | |
1544 qi->qf_refcount++; | |
1545 } | |
1546 | |
1547 return qi; | |
644 | 1548 } |
1549 | |
1550 /* | |
1551 * Return the location list for window 'wp'. | |
1552 * If not present, allocate a location list | |
1553 */ | |
1554 static qf_info_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1555 ll_get_or_alloc_list(win_T *wp) |
644 | 1556 { |
1557 if (IS_LL_WINDOW(wp)) | |
1558 /* For a location list window, use the referenced location list */ | |
1559 return wp->w_llist_ref; | |
1560 | |
1561 /* | |
1562 * For a non-location list window, w_llist_ref should not point to a | |
1563 * location list. | |
1564 */ | |
1565 ll_free_all(&wp->w_llist_ref); | |
1566 | |
1567 if (wp->w_llist == NULL) | |
659 | 1568 wp->w_llist = ll_new_list(); /* new location list */ |
644 | 1569 return wp->w_llist; |
1570 } | |
1571 | |
1572 /* | |
1573 * Copy the location list from window "from" to window "to". | |
1574 */ | |
1575 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1576 copy_loclist(win_T *from, win_T *to) |
644 | 1577 { |
1578 qf_info_T *qi; | |
1579 int idx; | |
1580 int i; | |
1581 | |
1582 /* | |
1583 * When copying from a location list window, copy the referenced | |
1584 * location list. For other windows, copy the location list for | |
1585 * that window. | |
1586 */ | |
1587 if (IS_LL_WINDOW(from)) | |
1588 qi = from->w_llist_ref; | |
1589 else | |
1590 qi = from->w_llist; | |
1591 | |
1592 if (qi == NULL) /* no location list to copy */ | |
1593 return; | |
1594 | |
659 | 1595 /* allocate a new location list */ |
1596 if ((to->w_llist = ll_new_list()) == NULL) | |
644 | 1597 return; |
1598 | |
1599 to->w_llist->qf_listcount = qi->qf_listcount; | |
1600 | |
1601 /* Copy the location lists one at a time */ | |
1602 for (idx = 0; idx < qi->qf_listcount; idx++) | |
1603 { | |
1604 qf_list_T *from_qfl; | |
1605 qf_list_T *to_qfl; | |
1606 | |
1607 to->w_llist->qf_curlist = idx; | |
1608 | |
1609 from_qfl = &qi->qf_lists[idx]; | |
1610 to_qfl = &to->w_llist->qf_lists[idx]; | |
1611 | |
1612 /* Some of the fields are populated by qf_add_entry() */ | |
1613 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid; | |
1614 to_qfl->qf_count = 0; | |
1615 to_qfl->qf_index = 0; | |
1616 to_qfl->qf_start = NULL; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1617 to_qfl->qf_last = NULL; |
644 | 1618 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
|
1619 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
|
1620 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
|
1621 else |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1622 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
|
1623 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
|
1624 { |
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 = alloc_tv(); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1626 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
|
1627 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
|
1628 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1629 else |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
1630 to_qfl->qf_ctx = NULL; |
644 | 1631 |
1632 if (from_qfl->qf_count) | |
1633 { | |
1634 qfline_T *from_qfp; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1635 qfline_T *prevp; |
644 | 1636 |
1637 /* 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
|
1638 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
|
1639 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
|
1640 ++i, from_qfp = from_qfp->qf_next) |
644 | 1641 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1642 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
|
1643 to->w_llist->qf_curlist, |
644 | 1644 NULL, |
1645 NULL, | |
1065 | 1646 0, |
644 | 1647 from_qfp->qf_text, |
1648 from_qfp->qf_lnum, | |
1649 from_qfp->qf_col, | |
1650 from_qfp->qf_viscol, | |
1651 from_qfp->qf_pattern, | |
1652 from_qfp->qf_nr, | |
1653 0, | |
1654 from_qfp->qf_valid) == FAIL) | |
1655 { | |
1656 qf_free_all(to); | |
1657 return; | |
1658 } | |
1659 /* | |
1660 * qf_add_entry() will not set the qf_num field, as the | |
1661 * directory and file names are not supplied. So the qf_fnum | |
1662 * field is copied here. | |
1663 */ | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1664 prevp = to->w_llist->qf_lists[to->w_llist->qf_curlist].qf_last; |
644 | 1665 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */ |
1666 prevp->qf_type = from_qfp->qf_type; /* error type */ | |
1667 if (from_qfl->qf_ptr == from_qfp) | |
1668 to_qfl->qf_ptr = prevp; /* current location */ | |
1669 } | |
1670 } | |
1671 | |
1672 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */ | |
1673 | |
1674 /* When no valid entries are present in the list, qf_ptr points to | |
1675 * the first item in the list */ | |
2795 | 1676 if (to_qfl->qf_nonevalid) |
5060
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1677 { |
644 | 1678 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
|
1679 to_qfl->qf_index = 1; |
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1680 } |
644 | 1681 } |
1682 | |
1683 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */ | |
1684 } | |
1685 | |
1686 /* | |
10379
73e2a7abe2a3
commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents:
10369
diff
changeset
|
1687 * 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
|
1688 * Also sets the b_has_qf_entry flag. |
7 | 1689 */ |
1690 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
|
1691 qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory, char_u *fname) |
7 | 1692 { |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1693 char_u *ptr = NULL; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1694 buf_T *buf; |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1695 char_u *bufname; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1696 |
7 | 1697 if (fname == NULL || *fname == NUL) /* no file name */ |
1698 return 0; | |
1699 | |
2823 | 1700 #ifdef VMS |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1701 vms_remove_version(fname); |
2823 | 1702 #endif |
1703 #ifdef BACKSLASH_IN_FILENAME | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1704 if (directory != NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1705 slash_adjust(directory); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1706 slash_adjust(fname); |
2823 | 1707 #endif |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1708 if (directory != NULL && !vim_isAbsName(fname) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1709 && (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
|
1710 { |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1711 /* |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1712 * 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
|
1713 * 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
|
1714 * "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
|
1715 * directory change. |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1716 */ |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1717 if (mch_getperm(ptr) < 0) |
7 | 1718 { |
1719 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
|
1720 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
|
1721 if (directory) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1722 ptr = concat_fnames(directory, fname, TRUE); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1723 else |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1724 ptr = vim_strsave(fname); |
7 | 1725 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1726 /* 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
|
1727 bufname = ptr; |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1728 } |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1729 else |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1730 bufname = fname; |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1731 |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1732 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
|
1733 && bufref_valid(&qf_last_bufref)) |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1734 { |
9475
4d8f7f8da90c
commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents:
9473
diff
changeset
|
1735 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
|
1736 vim_free(ptr); |
7 | 1737 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1738 else |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1739 { |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1740 vim_free(qf_last_bufname); |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1741 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
|
1742 if (bufname == ptr) |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1743 qf_last_bufname = bufname; |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1744 else |
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1745 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
|
1746 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
|
1747 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1748 if (buf == NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1749 return 0; |
9473
bdac1019552f
commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents:
9458
diff
changeset
|
1750 |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1751 buf->b_has_qf_entry = |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
1752 (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
|
1753 return buf->b_fnum; |
7 | 1754 } |
1755 | |
1756 /* | |
9334
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
1757 * 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
|
1758 * NULL on error. |
7 | 1759 */ |
1760 static char_u * | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1761 qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) |
7 | 1762 { |
1763 struct dir_stack_T *ds_new; | |
1764 struct dir_stack_T *ds_ptr; | |
1765 | |
1766 /* allocate new stack element and hook it in */ | |
1767 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T)); | |
1768 if (ds_new == NULL) | |
1769 return NULL; | |
1770 | |
1771 ds_new->next = *stackptr; | |
1772 *stackptr = ds_new; | |
1773 | |
1774 /* store directory on the stack */ | |
1775 if (vim_isAbsName(dirbuf) | |
1776 || (*stackptr)->next == NULL | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1777 || (*stackptr && is_file_stack)) |
7 | 1778 (*stackptr)->dirname = vim_strsave(dirbuf); |
1779 else | |
1780 { | |
1781 /* Okay we don't have an absolute path. | |
1782 * dirbuf must be a subdir of one of the directories on the stack. | |
1783 * Let's search... | |
1784 */ | |
1785 ds_new = (*stackptr)->next; | |
1786 (*stackptr)->dirname = NULL; | |
1787 while (ds_new) | |
1788 { | |
1789 vim_free((*stackptr)->dirname); | |
1790 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, | |
1791 TRUE); | |
1792 if (mch_isdir((*stackptr)->dirname) == TRUE) | |
1793 break; | |
1794 | |
1795 ds_new = ds_new->next; | |
1796 } | |
1797 | |
1798 /* clean up all dirs we already left */ | |
1799 while ((*stackptr)->next != ds_new) | |
1800 { | |
1801 ds_ptr = (*stackptr)->next; | |
1802 (*stackptr)->next = (*stackptr)->next->next; | |
1803 vim_free(ds_ptr->dirname); | |
1804 vim_free(ds_ptr); | |
1805 } | |
1806 | |
1807 /* Nothing found -> it must be on top level */ | |
1808 if (ds_new == NULL) | |
1809 { | |
1810 vim_free((*stackptr)->dirname); | |
1811 (*stackptr)->dirname = vim_strsave(dirbuf); | |
1812 } | |
1813 } | |
1814 | |
1815 if ((*stackptr)->dirname != NULL) | |
1816 return (*stackptr)->dirname; | |
1817 else | |
1818 { | |
1819 ds_ptr = *stackptr; | |
1820 *stackptr = (*stackptr)->next; | |
1821 vim_free(ds_ptr); | |
1822 return NULL; | |
1823 } | |
1824 } | |
1825 | |
1826 | |
1827 /* | |
1828 * pop dirbuf from the directory stack and return previous directory or NULL if | |
1829 * stack is empty | |
1830 */ | |
1831 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1832 qf_pop_dir(struct dir_stack_T **stackptr) |
7 | 1833 { |
1834 struct dir_stack_T *ds_ptr; | |
1835 | |
1836 /* TODO: Should we check if dirbuf is the directory on top of the stack? | |
1837 * What to do if it isn't? */ | |
1838 | |
1839 /* pop top element and free it */ | |
1840 if (*stackptr != NULL) | |
1841 { | |
1842 ds_ptr = *stackptr; | |
1843 *stackptr = (*stackptr)->next; | |
1844 vim_free(ds_ptr->dirname); | |
1845 vim_free(ds_ptr); | |
1846 } | |
1847 | |
1848 /* return NEW top element as current dir or NULL if stack is empty*/ | |
1849 return *stackptr ? (*stackptr)->dirname : NULL; | |
1850 } | |
1851 | |
1852 /* | |
1853 * clean up directory stack | |
1854 */ | |
1855 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1856 qf_clean_dir_stack(struct dir_stack_T **stackptr) |
7 | 1857 { |
1858 struct dir_stack_T *ds_ptr; | |
1859 | |
1860 while ((ds_ptr = *stackptr) != NULL) | |
1861 { | |
1862 *stackptr = (*stackptr)->next; | |
1863 vim_free(ds_ptr->dirname); | |
1864 vim_free(ds_ptr); | |
1865 } | |
1866 } | |
1867 | |
1868 /* | |
1869 * Check in which directory of the directory stack the given file can be | |
1870 * found. | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
1871 * Returns a pointer to the directory name or NULL if not found. |
7 | 1872 * Cleans up intermediate directory entries. |
1873 * | |
1874 * TODO: How to solve the following problem? | |
1875 * If we have the this directory tree: | |
1876 * ./ | |
1877 * ./aa | |
1878 * ./aa/bb | |
1879 * ./bb | |
1880 * ./bb/x.c | |
1881 * and make says: | |
1882 * making all in aa | |
1883 * making all in bb | |
1884 * x.c:9: Error | |
1885 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb. | |
1886 * qf_guess_filepath will return NULL. | |
1887 */ | |
1888 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
|
1889 qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *filename) |
7 | 1890 { |
1891 struct dir_stack_T *ds_ptr; | |
1892 struct dir_stack_T *ds_tmp; | |
1893 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
|
1894 qf_list_T *qfl = &qi->qf_lists[qf_idx]; |
7 | 1895 |
1896 /* 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
|
1897 if (qfl->qf_dir_stack == NULL) |
7 | 1898 return NULL; |
1899 | |
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
|
1900 ds_ptr = qfl->qf_dir_stack->next; |
7 | 1901 fullname = NULL; |
1902 while (ds_ptr) | |
1903 { | |
1904 vim_free(fullname); | |
1905 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE); | |
1906 | |
1907 /* If concat_fnames failed, just go on. The worst thing that can happen | |
1908 * is that we delete the entire stack. | |
1909 */ | |
1910 if ((fullname != NULL) && (mch_getperm(fullname) >= 0)) | |
1911 break; | |
1912 | |
1913 ds_ptr = ds_ptr->next; | |
1914 } | |
1915 | |
1916 vim_free(fullname); | |
1917 | |
1918 /* 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
|
1919 while (qfl->qf_dir_stack->next != ds_ptr) |
7 | 1920 { |
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
|
1921 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
|
1922 qfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next; |
7 | 1923 vim_free(ds_tmp->dirname); |
1924 vim_free(ds_tmp); | |
1925 } | |
1926 | |
1927 return ds_ptr==NULL? NULL: ds_ptr->dirname; | |
1928 } | |
1929 | |
1930 /* | |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1931 * 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
|
1932 * 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
|
1933 * 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
|
1934 * Similar to location list. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1935 */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1936 static int |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1937 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
|
1938 { |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1939 qf_list_T *qfl; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1940 qfline_T *qfp; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1941 int i; |
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 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
|
1944 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1945 /* 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
|
1946 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
|
1947 ++i, qfp = qfp->qf_next) |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1948 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
|
1949 break; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1950 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1951 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
|
1952 return FALSE; |
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 return TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1955 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1956 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1957 /* |
7 | 1958 * jump to a quickfix line |
1959 * if dir == FORWARD go "errornr" valid entries forward | |
1960 * if dir == BACKWARD go "errornr" valid entries backward | |
1961 * if dir == FORWARD_FILE go "errornr" valid entries files backward | |
1962 * if dir == BACKWARD_FILE go "errornr" valid entries files backward | |
1963 * else if "errornr" is zero, redisplay the same line | |
1964 * else go to entry "errornr" | |
1965 */ | |
1966 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1967 qf_jump( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1968 qf_info_T *qi, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1969 int dir, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1970 int errornr, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1971 int forceit) |
7 | 1972 { |
644 | 1973 qf_info_T *ll_ref; |
230 | 1974 qfline_T *qf_ptr; |
1975 qfline_T *old_qf_ptr; | |
7 | 1976 int qf_index; |
1977 int old_qf_fnum; | |
1978 int old_qf_index; | |
1979 int prev_index; | |
1980 static char_u *e_no_more_items = (char_u *)N_("E553: No more items"); | |
1981 char_u *err = e_no_more_items; | |
1982 linenr_T i; | |
1983 buf_T *old_curbuf; | |
1984 linenr_T old_lnum; | |
1985 colnr_T screen_col; | |
1986 colnr_T char_col; | |
1987 char_u *line; | |
1988 #ifdef FEAT_WINDOWS | |
639 | 1989 char_u *old_swb = p_swb; |
1621 | 1990 unsigned old_swb_flags = swb_flags; |
7 | 1991 int opened_window = FALSE; |
1992 win_T *win; | |
1993 win_T *altwin; | |
1822 | 1994 int flags; |
7 | 1995 #endif |
1743 | 1996 win_T *oldwin = curwin; |
7 | 1997 int print_message = TRUE; |
1998 int len; | |
1999 #ifdef FEAT_FOLDING | |
2000 int old_KeyTyped = KeyTyped; /* getting file may reset it */ | |
2001 #endif | |
9 | 2002 int ok = OK; |
644 | 2003 int usable_win; |
2004 | |
659 | 2005 if (qi == NULL) |
2006 qi = &ql_info; | |
644 | 2007 |
2008 if (qi->qf_curlist >= qi->qf_listcount | |
2009 || qi->qf_lists[qi->qf_curlist].qf_count == 0) | |
7 | 2010 { |
2011 EMSG(_(e_quickfix)); | |
2012 return; | |
2013 } | |
2014 | |
644 | 2015 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr; |
7 | 2016 old_qf_ptr = qf_ptr; |
644 | 2017 qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
7 | 2018 old_qf_index = qf_index; |
2019 if (dir == FORWARD || dir == FORWARD_FILE) /* next valid entry */ | |
2020 { | |
2021 while (errornr--) | |
2022 { | |
2023 old_qf_ptr = qf_ptr; | |
2024 prev_index = qf_index; | |
2025 old_qf_fnum = qf_ptr->qf_fnum; | |
2026 do | |
2027 { | |
644 | 2028 if (qf_index == qi->qf_lists[qi->qf_curlist].qf_count |
7 | 2029 || qf_ptr->qf_next == NULL) |
2030 { | |
2031 qf_ptr = old_qf_ptr; | |
2032 qf_index = prev_index; | |
2033 if (err != NULL) | |
2034 { | |
2035 EMSG(_(err)); | |
2036 goto theend; | |
2037 } | |
2038 errornr = 0; | |
2039 break; | |
2040 } | |
2041 ++qf_index; | |
2042 qf_ptr = qf_ptr->qf_next; | |
644 | 2043 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid |
2044 && !qf_ptr->qf_valid) | |
7 | 2045 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
2046 err = NULL; | |
2047 } | |
2048 } | |
2049 else if (dir == BACKWARD || dir == BACKWARD_FILE) /* prev. valid entry */ | |
2050 { | |
2051 while (errornr--) | |
2052 { | |
2053 old_qf_ptr = qf_ptr; | |
2054 prev_index = qf_index; | |
2055 old_qf_fnum = qf_ptr->qf_fnum; | |
2056 do | |
2057 { | |
2058 if (qf_index == 1 || qf_ptr->qf_prev == NULL) | |
2059 { | |
2060 qf_ptr = old_qf_ptr; | |
2061 qf_index = prev_index; | |
2062 if (err != NULL) | |
2063 { | |
2064 EMSG(_(err)); | |
2065 goto theend; | |
2066 } | |
2067 errornr = 0; | |
2068 break; | |
2069 } | |
2070 --qf_index; | |
2071 qf_ptr = qf_ptr->qf_prev; | |
644 | 2072 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid |
2073 && !qf_ptr->qf_valid) | |
7 | 2074 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
2075 err = NULL; | |
2076 } | |
2077 } | |
2078 else if (errornr != 0) /* go to specified number */ | |
2079 { | |
2080 while (errornr < qf_index && qf_index > 1 && qf_ptr->qf_prev != NULL) | |
2081 { | |
2082 --qf_index; | |
2083 qf_ptr = qf_ptr->qf_prev; | |
2084 } | |
644 | 2085 while (errornr > qf_index && qf_index < |
2086 qi->qf_lists[qi->qf_curlist].qf_count | |
7 | 2087 && qf_ptr->qf_next != NULL) |
2088 { | |
2089 ++qf_index; | |
2090 qf_ptr = qf_ptr->qf_next; | |
2091 } | |
2092 } | |
2093 | |
2094 #ifdef FEAT_WINDOWS | |
644 | 2095 qi->qf_lists[qi->qf_curlist].qf_index = qf_index; |
2096 if (qf_win_pos_update(qi, old_qf_index)) | |
7 | 2097 /* No need to print the error message if it's visible in the error |
2098 * window */ | |
2099 print_message = FALSE; | |
2100 | |
2101 /* | |
9 | 2102 * For ":helpgrep" find a help window or open one. |
2103 */ | |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
2104 if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) || cmdmod.tab != 0)) |
9 | 2105 { |
2106 win_T *wp; | |
2107 | |
682 | 2108 if (cmdmod.tab != 0) |
2109 wp = NULL; | |
2110 else | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9608
diff
changeset
|
2111 FOR_ALL_WINDOWS(wp) |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
2112 if (bt_help(wp->w_buffer)) |
682 | 2113 break; |
9 | 2114 if (wp != NULL && wp->w_buffer->b_nwindows > 0) |
2115 win_enter(wp, TRUE); | |
2116 else | |
2117 { | |
2118 /* | |
2119 * Split off help window; put it at far top if no position | |
2120 * specified, the current window is vertically split and narrow. | |
2121 */ | |
1822 | 2122 flags = WSP_HELP; |
9 | 2123 if (cmdmod.split == 0 && curwin->w_width != Columns |
2124 && curwin->w_width < 80) | |
1822 | 2125 flags |= WSP_TOP; |
2126 if (qi != &ql_info) | |
2127 flags |= WSP_NEWLOC; /* don't copy the location list */ | |
2128 | |
2129 if (win_split(0, flags) == FAIL) | |
9 | 2130 goto theend; |
26 | 2131 opened_window = TRUE; /* close it when fail */ |
9 | 2132 |
2133 if (curwin->w_height < p_hh) | |
2134 win_setheight((int)p_hh); | |
659 | 2135 |
2136 if (qi != &ql_info) /* not a quickfix list */ | |
2137 { | |
2138 /* The new window should use the supplied location list */ | |
2139 curwin->w_llist = qi; | |
2140 qi->qf_refcount++; | |
2141 } | |
9 | 2142 } |
2143 | |
2144 if (!p_im) | |
2145 restart_edit = 0; /* don't want insert mode in help file */ | |
2146 } | |
2147 | |
2148 /* | |
7 | 2149 * If currently in the quickfix window, find another window to show the |
2150 * file in. | |
2151 */ | |
26 | 2152 if (bt_quickfix(curbuf) && !opened_window) |
7 | 2153 { |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2154 win_T *usable_win_ptr = NULL; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2155 |
7 | 2156 /* |
2157 * If there is no file specified, we don't know where to go. | |
2158 * But do advance, otherwise ":cn" gets stuck. | |
2159 */ | |
2160 if (qf_ptr->qf_fnum == 0) | |
2161 goto theend; | |
2162 | |
644 | 2163 usable_win = 0; |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2164 |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2165 ll_ref = curwin->w_llist_ref; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2166 if (ll_ref != NULL) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2167 { |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2168 /* Find a window using the same location list that is not a |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2169 * quickfix window. */ |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2170 FOR_ALL_WINDOWS(usable_win_ptr) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2171 if (usable_win_ptr->w_llist == ll_ref |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11705
diff
changeset
|
2172 && !bt_quickfix(usable_win_ptr->w_buffer)) |
5084
14e7a115d54d
updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents:
5062
diff
changeset
|
2173 { |
14e7a115d54d
updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents:
5062
diff
changeset
|
2174 usable_win = 1; |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2175 break; |
5084
14e7a115d54d
updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents:
5062
diff
changeset
|
2176 } |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2177 } |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2178 |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2179 if (!usable_win) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2180 { |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2181 /* Locate a window showing a normal buffer */ |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2182 FOR_ALL_WINDOWS(win) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2183 if (win->w_buffer->b_p_bt[0] == NUL) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2184 { |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2185 usable_win = 1; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2186 break; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2187 } |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2188 } |
644 | 2189 |
7 | 2190 /* |
1621 | 2191 * If no usable window is found and 'switchbuf' contains "usetab" |
1020 | 2192 * then search in other tabs. |
7 | 2193 */ |
1621 | 2194 if (!usable_win && (swb_flags & SWB_USETAB)) |
1020 | 2195 { |
2196 tabpage_T *tp; | |
2197 win_T *wp; | |
2198 | |
2199 FOR_ALL_TAB_WINDOWS(tp, wp) | |
2200 { | |
2201 if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum) | |
2202 { | |
2203 goto_tabpage_win(tp, wp); | |
2204 usable_win = 1; | |
1819 | 2205 goto win_found; |
1020 | 2206 } |
2207 } | |
2208 } | |
1819 | 2209 win_found: |
1020 | 2210 |
2211 /* | |
1396 | 2212 * If there is only one window and it is the quickfix window, create a |
2213 * new one above the quickfix window. | |
1020 | 2214 */ |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10346
diff
changeset
|
2215 if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win) |
7 | 2216 { |
1822 | 2217 flags = WSP_ABOVE; |
2218 if (ll_ref != NULL) | |
2219 flags |= WSP_NEWLOC; | |
2220 if (win_split(0, flags) == FAIL) | |
7 | 2221 goto failed; /* not enough room for window */ |
2222 opened_window = TRUE; /* close it when fail */ | |
2223 p_swb = empty_option; /* don't split again */ | |
1621 | 2224 swb_flags = 0; |
2583 | 2225 RESET_BINDING(curwin); |
644 | 2226 if (ll_ref != NULL) |
2227 { | |
2228 /* The new window should use the location list from the | |
2229 * location list window */ | |
2230 curwin->w_llist = ll_ref; | |
2231 ll_ref->qf_refcount++; | |
2232 } | |
7 | 2233 } |
2234 else | |
2235 { | |
644 | 2236 if (curwin->w_llist_ref != NULL) |
2237 { | |
2238 /* In a location window */ | |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2239 win = usable_win_ptr; |
644 | 2240 if (win == NULL) |
2241 { | |
2242 /* Find the window showing the selected file */ | |
2243 FOR_ALL_WINDOWS(win) | |
2244 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum) | |
2245 break; | |
2246 if (win == NULL) | |
2247 { | |
2248 /* Find a previous usable window */ | |
2249 win = curwin; | |
2250 do | |
2251 { | |
2252 if (win->w_buffer->b_p_bt[0] == NUL) | |
2253 break; | |
2254 if (win->w_prev == NULL) | |
2255 win = lastwin; /* wrap around the top */ | |
2256 else | |
2257 win = win->w_prev; /* go to previous window */ | |
2258 } while (win != curwin); | |
2259 } | |
2260 } | |
2261 win_goto(win); | |
2262 | |
2263 /* If the location list for the window is not set, then set it | |
2264 * to the location list from the location window */ | |
2265 if (win->w_llist == NULL) | |
2266 { | |
2267 win->w_llist = ll_ref; | |
2268 ll_ref->qf_refcount++; | |
2269 } | |
2270 } | |
2271 else | |
2272 { | |
2273 | |
7 | 2274 /* |
2275 * Try to find a window that shows the right buffer. | |
2276 * Default to the window just above the quickfix buffer. | |
2277 */ | |
2278 win = curwin; | |
2279 altwin = NULL; | |
2280 for (;;) | |
2281 { | |
2282 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum) | |
2283 break; | |
2284 if (win->w_prev == NULL) | |
2285 win = lastwin; /* wrap around the top */ | |
2286 else | |
2287 win = win->w_prev; /* go to previous window */ | |
2288 | |
644 | 2289 if (IS_QF_WINDOW(win)) |
7 | 2290 { |
2291 /* Didn't find it, go to the window before the quickfix | |
2292 * window. */ | |
2293 if (altwin != NULL) | |
2294 win = altwin; | |
2295 else if (curwin->w_prev != NULL) | |
2296 win = curwin->w_prev; | |
2297 else | |
2298 win = curwin->w_next; | |
2299 break; | |
2300 } | |
2301 | |
2302 /* Remember a usable window. */ | |
2303 if (altwin == NULL && !win->w_p_pvw | |
2304 && win->w_buffer->b_p_bt[0] == NUL) | |
2305 altwin = win; | |
2306 } | |
2307 | |
2308 win_goto(win); | |
644 | 2309 } |
7 | 2310 } |
2311 } | |
2312 #endif | |
2313 | |
2314 /* | |
2315 * If there is a file name, | |
2316 * read the wanted file if needed, and check autowrite etc. | |
2317 */ | |
2318 old_curbuf = curbuf; | |
2319 old_lnum = curwin->w_cursor.lnum; | |
9 | 2320 |
2321 if (qf_ptr->qf_fnum != 0) | |
2322 { | |
2323 if (qf_ptr->qf_type == 1) | |
2324 { | |
2325 /* Open help file (do_ecmd() will set b_help flag, readfile() will | |
2326 * set b_p_ro flag). */ | |
2327 if (!can_abandon(curbuf, forceit)) | |
2328 { | |
2329 EMSG(_(e_nowrtmsg)); | |
2330 ok = FALSE; | |
2331 } | |
2332 else | |
2333 ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, | |
1743 | 2334 ECMD_HIDE + ECMD_SET_HELP, |
2335 oldwin == curwin ? curwin : NULL); | |
9 | 2336 } |
2337 else | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2338 { |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2339 int old_qf_curlist = qi->qf_curlist; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2340 int is_abort = FALSE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2341 |
9 | 2342 ok = buflist_getfile(qf_ptr->qf_fnum, |
2343 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); | |
10281
92fa8e5ef210
commit https://github.com/vim/vim/commit/0a9046fbcb33770517ab0220b8100c4494bddab2
Christian Brabandt <cb@256bit.org>
parents:
10257
diff
changeset
|
2344 if (qi != &ql_info && !win_valid_any_tab(oldwin)) |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2345 { |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2346 EMSG(_("E924: Current window was closed")); |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2347 is_abort = TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2348 opened_window = FALSE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2349 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2350 else if (old_qf_curlist != qi->qf_curlist |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2351 || !is_qf_entry_present(qi, qf_ptr)) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2352 { |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2353 if (qi == &ql_info) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2354 EMSG(_("E925: Current quickfix was changed")); |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2355 else |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2356 EMSG(_("E926: Current location list was changed")); |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2357 is_abort = TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2358 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2359 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2360 if (is_abort) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2361 { |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2362 ok = FALSE; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2363 qi = NULL; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2364 qf_ptr = NULL; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2365 } |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2366 } |
9 | 2367 } |
2368 | |
2369 if (ok == OK) | |
7 | 2370 { |
2371 /* When not switched to another buffer, still need to set pc mark */ | |
2372 if (curbuf == old_curbuf) | |
2373 setpcmark(); | |
2374 | |
230 | 2375 if (qf_ptr->qf_pattern == NULL) |
7 | 2376 { |
230 | 2377 /* |
2378 * Go to line with error, unless qf_lnum is 0. | |
2379 */ | |
2380 i = qf_ptr->qf_lnum; | |
2381 if (i > 0) | |
2382 { | |
2383 if (i > curbuf->b_ml.ml_line_count) | |
2384 i = curbuf->b_ml.ml_line_count; | |
2385 curwin->w_cursor.lnum = i; | |
2386 } | |
2387 if (qf_ptr->qf_col > 0) | |
7 | 2388 { |
230 | 2389 curwin->w_cursor.col = qf_ptr->qf_col - 1; |
6853 | 2390 #ifdef FEAT_VIRTUALEDIT |
2391 curwin->w_cursor.coladd = 0; | |
2392 #endif | |
230 | 2393 if (qf_ptr->qf_viscol == TRUE) |
7 | 2394 { |
230 | 2395 /* |
2396 * Check each character from the beginning of the error | |
2397 * line up to the error column. For each tab character | |
2398 * found, reduce the error column value by the length of | |
2399 * a tab character. | |
2400 */ | |
2401 line = ml_get_curline(); | |
2402 screen_col = 0; | |
2403 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) | |
7 | 2404 { |
230 | 2405 if (*line == NUL) |
2406 break; | |
2407 if (*line++ == '\t') | |
2408 { | |
2409 curwin->w_cursor.col -= 7 - (screen_col % 8); | |
2410 screen_col += 8 - (screen_col % 8); | |
2411 } | |
2412 else | |
2413 ++screen_col; | |
7 | 2414 } |
2415 } | |
230 | 2416 check_cursor(); |
7 | 2417 } |
230 | 2418 else |
2419 beginline(BL_WHITE | BL_FIX); | |
7 | 2420 } |
2421 else | |
230 | 2422 { |
2423 pos_T save_cursor; | |
2424 | |
2425 /* Move the cursor to the first line in the buffer */ | |
2426 save_cursor = curwin->w_cursor; | |
2427 curwin->w_cursor.lnum = 0; | |
1521 | 2428 if (!do_search(NULL, '/', qf_ptr->qf_pattern, (long)1, |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11516
diff
changeset
|
2429 SEARCH_KEEP, NULL, NULL)) |
230 | 2430 curwin->w_cursor = save_cursor; |
2431 } | |
7 | 2432 |
2433 #ifdef FEAT_FOLDING | |
2434 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped) | |
2435 foldOpenCursor(); | |
2436 #endif | |
2437 if (print_message) | |
2438 { | |
3267 | 2439 /* Update the screen before showing the message, unless the screen |
2440 * scrolled up. */ | |
2441 if (!msg_scrolled) | |
2442 update_topline_redraw(); | |
7 | 2443 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index, |
644 | 2444 qi->qf_lists[qi->qf_curlist].qf_count, |
7 | 2445 qf_ptr->qf_cleared ? _(" (line deleted)") : "", |
2446 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr)); | |
2447 /* Add the message, skipping leading whitespace and newlines. */ | |
2448 len = (int)STRLEN(IObuff); | |
2449 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len); | |
2450 | |
2451 /* Output the message. Overwrite to avoid scrolling when the 'O' | |
2452 * flag is present in 'shortmess'; But when not jumping, print the | |
2453 * whole message. */ | |
2454 i = msg_scroll; | |
2455 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum) | |
2456 msg_scroll = TRUE; | |
2457 else if (!msg_scrolled && shortmess(SHM_OVERALL)) | |
2458 msg_scroll = FALSE; | |
2459 msg_attr_keep(IObuff, 0, TRUE); | |
2460 msg_scroll = i; | |
2461 } | |
2462 } | |
2463 else | |
2464 { | |
2465 #ifdef FEAT_WINDOWS | |
2466 if (opened_window) | |
2467 win_close(curwin, TRUE); /* Close opened window */ | |
2468 #endif | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2469 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) |
7 | 2470 { |
2471 /* | |
2472 * Couldn't open file, so put index back where it was. This could | |
2473 * happen if the file was readonly and we changed something. | |
2474 */ | |
2475 #ifdef FEAT_WINDOWS | |
2476 failed: | |
2477 #endif | |
2478 qf_ptr = old_qf_ptr; | |
2479 qf_index = old_qf_index; | |
2480 } | |
2481 } | |
2482 theend: | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2483 if (qi != NULL) |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2484 { |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2485 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
|
2486 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
|
2487 } |
7 | 2488 #ifdef FEAT_WINDOWS |
2489 if (p_swb != old_swb && opened_window) | |
2490 { | |
2491 /* Restore old 'switchbuf' value, but not when an autocommand or | |
2492 * modeline has changed the value. */ | |
2493 if (p_swb == empty_option) | |
1621 | 2494 { |
7 | 2495 p_swb = old_swb; |
1621 | 2496 swb_flags = old_swb_flags; |
2497 } | |
7 | 2498 else |
2499 free_string_option(old_swb); | |
2500 } | |
2501 #endif | |
2502 } | |
2503 | |
2504 /* | |
2505 * ":clist": list all errors | |
644 | 2506 * ":llist": list all locations |
7 | 2507 */ |
2508 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2509 qf_list(exarg_T *eap) |
7 | 2510 { |
230 | 2511 buf_T *buf; |
2512 char_u *fname; | |
2513 qfline_T *qfp; | |
2514 int i; | |
2515 int idx1 = 1; | |
2516 int idx2 = -1; | |
2517 char_u *arg = eap->arg; | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2518 int plus = FALSE; |
230 | 2519 int all = eap->forceit; /* if not :cl!, only show |
7 | 2520 recognised errors */ |
644 | 2521 qf_info_T *qi = &ql_info; |
2522 | |
2523 if (eap->cmdidx == CMD_llist) | |
2524 { | |
2525 qi = GET_LOC_LIST(curwin); | |
2526 if (qi == NULL) | |
2527 { | |
2528 EMSG(_(e_loclist)); | |
2529 return; | |
2530 } | |
2531 } | |
2532 | |
2533 if (qi->qf_curlist >= qi->qf_listcount | |
2534 || qi->qf_lists[qi->qf_curlist].qf_count == 0) | |
7 | 2535 { |
2536 EMSG(_(e_quickfix)); | |
2537 return; | |
2538 } | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2539 if (*arg == '+') |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2540 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2541 ++arg; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2542 plus = TRUE; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2543 } |
7 | 2544 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) |
2545 { | |
2546 EMSG(_(e_trailing)); | |
2547 return; | |
2548 } | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2549 if (plus) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2550 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2551 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
|
2552 idx2 = i + idx1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2553 idx1 = i; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2554 } |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2555 else |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2556 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2557 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
|
2558 if (idx1 < 0) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2559 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
|
2560 if (idx2 < 0) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2561 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
|
2562 } |
7 | 2563 |
644 | 2564 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid) |
7 | 2565 all = TRUE; |
644 | 2566 qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
2567 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ) | |
7 | 2568 { |
2569 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2) | |
2570 { | |
2047
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2571 msg_putchar('\n'); |
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2572 if (got_int) |
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2573 break; |
446 | 2574 |
2575 fname = NULL; | |
2576 if (qfp->qf_fnum != 0 | |
7 | 2577 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) |
446 | 2578 { |
2579 fname = buf->b_fname; | |
2580 if (qfp->qf_type == 1) /* :helpgrep */ | |
2581 fname = gettail(fname); | |
2582 } | |
2583 if (fname == NULL) | |
2584 sprintf((char *)IObuff, "%2d", i); | |
2585 else | |
2586 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", | |
273 | 2587 i, (char *)fname); |
644 | 2588 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
|
2589 ? HL_ATTR(HLF_QFL) : HL_ATTR(HLF_D)); |
446 | 2590 if (qfp->qf_lnum == 0) |
2591 IObuff[0] = NUL; | |
2592 else if (qfp->qf_col == 0) | |
2593 sprintf((char *)IObuff, ":%ld", qfp->qf_lnum); | |
2594 else | |
2595 sprintf((char *)IObuff, ":%ld col %d", | |
7 | 2596 qfp->qf_lnum, qfp->qf_col); |
446 | 2597 sprintf((char *)IObuff + STRLEN(IObuff), "%s:", |
7 | 2598 (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
|
2599 msg_puts_attr(IObuff, HL_ATTR(HLF_N)); |
446 | 2600 if (qfp->qf_pattern != NULL) |
2601 { | |
2602 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE); | |
2603 STRCAT(IObuff, ":"); | |
2604 msg_puts(IObuff); | |
2605 } | |
2606 msg_puts((char_u *)" "); | |
230 | 2607 |
446 | 2608 /* Remove newlines and leading whitespace from the text. For an |
2609 * unrecognized line keep the indent, the compiler may mark a word | |
2610 * with ^^^^. */ | |
2611 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0) | |
7 | 2612 ? skipwhite(qfp->qf_text) : qfp->qf_text, |
2613 IObuff, IOSIZE); | |
446 | 2614 msg_prt_line(IObuff, FALSE); |
2615 out_flush(); /* show one line at a time */ | |
7 | 2616 } |
446 | 2617 |
2618 qfp = qfp->qf_next; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2619 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2620 break; |
446 | 2621 ++i; |
7 | 2622 ui_breakcheck(); |
2623 } | |
2624 } | |
2625 | |
2626 /* | |
2627 * Remove newlines and leading whitespace from an error message. | |
2628 * Put the result in "buf[bufsize]". | |
2629 */ | |
2630 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2631 qf_fmt_text(char_u *text, char_u *buf, int bufsize) |
7 | 2632 { |
2633 int i; | |
2634 char_u *p = text; | |
2635 | |
2636 for (i = 0; *p != NUL && i < bufsize - 1; ++i) | |
2637 { | |
2638 if (*p == '\n') | |
2639 { | |
2640 buf[i] = ' '; | |
2641 while (*++p != NUL) | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
2642 if (!VIM_ISWHITE(*p) && *p != '\n') |
7 | 2643 break; |
2644 } | |
2645 else | |
2646 buf[i] = *p++; | |
2647 } | |
2648 buf[i] = NUL; | |
2649 } | |
2650 | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2651 static void |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2652 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
|
2653 { |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2654 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
|
2655 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
|
2656 char_u buf[IOSIZE]; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2657 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2658 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
|
2659 lead, |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2660 which + 1, |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2661 qi->qf_listcount, |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2662 count); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2663 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2664 if (title != NULL) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2665 { |
9579
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2666 size_t len = STRLEN(buf); |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2667 |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2668 if (len < 34) |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2669 { |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2670 vim_memset(buf + len, ' ', 34 - len); |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2671 buf[34] = NUL; |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2672 } |
2fb7e008ac9b
commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents:
9573
diff
changeset
|
2673 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
|
2674 } |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2675 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
|
2676 msg(buf); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2677 } |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2678 |
7 | 2679 /* |
2680 * ":colder [count]": Up in the quickfix stack. | |
2681 * ":cnewer [count]": Down in the quickfix stack. | |
644 | 2682 * ":lolder [count]": Up in the location list stack. |
2683 * ":lnewer [count]": Down in the location list stack. | |
7 | 2684 */ |
2685 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2686 qf_age(exarg_T *eap) |
7 | 2687 { |
644 | 2688 qf_info_T *qi = &ql_info; |
7 | 2689 int count; |
2690 | |
644 | 2691 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer) |
2692 { | |
2693 qi = GET_LOC_LIST(curwin); | |
2694 if (qi == NULL) | |
2695 { | |
2696 EMSG(_(e_loclist)); | |
2697 return; | |
2698 } | |
2699 } | |
2700 | |
7 | 2701 if (eap->addr_count != 0) |
2702 count = eap->line2; | |
2703 else | |
2704 count = 1; | |
2705 while (count--) | |
2706 { | |
644 | 2707 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder) |
7 | 2708 { |
644 | 2709 if (qi->qf_curlist == 0) |
7 | 2710 { |
2711 EMSG(_("E380: At bottom of quickfix stack")); | |
4371 | 2712 break; |
7 | 2713 } |
644 | 2714 --qi->qf_curlist; |
7 | 2715 } |
2716 else | |
2717 { | |
644 | 2718 if (qi->qf_curlist >= qi->qf_listcount - 1) |
7 | 2719 { |
2720 EMSG(_("E381: At top of quickfix stack")); | |
4371 | 2721 break; |
7 | 2722 } |
644 | 2723 ++qi->qf_curlist; |
7 | 2724 } |
2725 } | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2726 qf_msg(qi, qi->qf_curlist, ""); |
7 | 2727 #ifdef FEAT_WINDOWS |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2728 qf_update_buffer(qi, NULL); |
7 | 2729 #endif |
2730 } | |
2731 | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2732 void |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2733 qf_history(exarg_T *eap) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2734 { |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2735 qf_info_T *qi = &ql_info; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2736 int i; |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2737 |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2738 if (eap->cmdidx == CMD_lhistory) |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2739 qi = GET_LOC_LIST(curwin); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2740 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
|
2741 && 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
|
2742 MSG(_("No entries")); |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2743 else |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2744 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
|
2745 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
|
2746 } |
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9534
diff
changeset
|
2747 |
7 | 2748 /* |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2749 * 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
|
2750 * associated with the list like context and title are not freed. |
7 | 2751 */ |
2752 static void | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2753 qf_free_items(qf_info_T *qi, int idx) |
7 | 2754 { |
230 | 2755 qfline_T *qfp; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2756 qfline_T *qfpnext; |
3982 | 2757 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
|
2758 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
|
2759 |
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
|
2760 while (qfl->qf_count && qfl->qf_start != NULL) |
7 | 2761 { |
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
|
2762 qfp = qfl->qf_start; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2763 qfpnext = qfp->qf_next; |
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
|
2764 if (qfl->qf_title != NULL && !stop) |
3949 | 2765 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2766 vim_free(qfp->qf_text); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2767 stop = (qfp == qfpnext); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2768 vim_free(qfp->qf_pattern); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2769 vim_free(qfp); |
3982 | 2770 if (stop) |
2771 /* Somehow qf_count may have an incorrect value, set it to 1 | |
2772 * to avoid crashing when it's wrong. | |
2773 * 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
|
2774 qfl->qf_count = 1; |
3949 | 2775 } |
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
|
2776 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
|
2777 --qfl->qf_count; |
7 | 2778 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2779 |
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
|
2780 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
|
2781 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
|
2782 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
|
2783 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
|
2784 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
|
2785 |
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
|
2786 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
|
2787 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
|
2788 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
|
2789 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
|
2790 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
|
2791 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
|
2792 qfl->qf_multiscan = FALSE; |
7 | 2793 } |
2794 | |
2795 /* | |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2796 * 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
|
2797 * 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
|
2798 */ |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2799 static void |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2800 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
|
2801 { |
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
|
2802 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
|
2803 |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2804 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
|
2805 |
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
|
2806 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
|
2807 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
|
2808 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
|
2809 qfl->qf_ctx = NULL; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2810 } |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2811 |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
2812 /* |
7 | 2813 * qf_mark_adjust: adjust marks |
2814 */ | |
2815 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2816 qf_mark_adjust( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2817 win_T *wp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2818 linenr_T line1, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2819 linenr_T line2, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2820 long amount, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2821 long amount_after) |
7 | 2822 { |
230 | 2823 int i; |
2824 qfline_T *qfp; | |
2825 int idx; | |
644 | 2826 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
|
2827 int found_one = FALSE; |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2828 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
|
2829 |
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2830 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
|
2831 return; |
644 | 2832 if (wp != NULL) |
2833 { | |
2834 if (wp->w_llist == NULL) | |
2835 return; | |
2836 qi = wp->w_llist; | |
2837 } | |
2838 | |
2839 for (idx = 0; idx < qi->qf_listcount; ++idx) | |
2840 if (qi->qf_lists[idx].qf_count) | |
2841 for (i = 0, qfp = qi->qf_lists[idx].qf_start; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2842 i < qi->qf_lists[idx].qf_count && qfp != NULL; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2843 ++i, qfp = qfp->qf_next) |
7 | 2844 if (qfp->qf_fnum == curbuf->b_fnum) |
2845 { | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2846 found_one = TRUE; |
7 | 2847 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) |
2848 { | |
2849 if (amount == MAXLNUM) | |
2850 qfp->qf_cleared = TRUE; | |
2851 else | |
2852 qfp->qf_lnum += amount; | |
2853 } | |
2854 else if (amount_after && qfp->qf_lnum > line2) | |
2855 qfp->qf_lnum += amount_after; | |
2856 } | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2857 |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2858 if (!found_one) |
9608
fa64afb99dda
commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents:
9579
diff
changeset
|
2859 curbuf->b_has_qf_entry &= ~buf_has_flag; |
7 | 2860 } |
2861 | |
2862 /* | |
2863 * Make a nice message out of the error character and the error number: | |
2864 * char number message | |
2865 * e or E 0 " error" | |
2866 * w or W 0 " warning" | |
2867 * i or I 0 " info" | |
2868 * 0 0 "" | |
2869 * other 0 " c" | |
2870 * e or E n " error n" | |
2871 * w or W n " warning n" | |
2872 * i or I n " info n" | |
2873 * 0 n " error n" | |
2874 * other n " c n" | |
2875 * 1 x "" :helpgrep | |
2876 */ | |
2877 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2878 qf_types(int c, int nr) |
7 | 2879 { |
2880 static char_u buf[20]; | |
2881 static char_u cc[3]; | |
2882 char_u *p; | |
2883 | |
2884 if (c == 'W' || c == 'w') | |
2885 p = (char_u *)" warning"; | |
2886 else if (c == 'I' || c == 'i') | |
2887 p = (char_u *)" info"; | |
2888 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0)) | |
2889 p = (char_u *)" error"; | |
2890 else if (c == 0 || c == 1) | |
2891 p = (char_u *)""; | |
2892 else | |
2893 { | |
2894 cc[0] = ' '; | |
2895 cc[1] = c; | |
2896 cc[2] = NUL; | |
2897 p = cc; | |
2898 } | |
2899 | |
2900 if (nr <= 0) | |
2901 return p; | |
2902 | |
2903 sprintf((char *)buf, "%s %3d", (char *)p, nr); | |
2904 return buf; | |
2905 } | |
2906 | |
2907 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
2908 /* | |
2909 * ":cwindow": open the quickfix window if we have errors to display, | |
2910 * close it if not. | |
644 | 2911 * ":lwindow": open the location list window if we have locations to display, |
2912 * close it if not. | |
7 | 2913 */ |
2914 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2915 ex_cwindow(exarg_T *eap) |
7 | 2916 { |
644 | 2917 qf_info_T *qi = &ql_info; |
7 | 2918 win_T *win; |
2919 | |
644 | 2920 if (eap->cmdidx == CMD_lwindow) |
2921 { | |
2922 qi = GET_LOC_LIST(curwin); | |
2923 if (qi == NULL) | |
2924 return; | |
2925 } | |
2926 | |
2927 /* Look for an existing quickfix window. */ | |
2928 win = qf_find_win(qi); | |
7 | 2929 |
2930 /* | |
2931 * If a quickfix window is open but we have no errors to display, | |
2932 * close the window. If a quickfix window is not open, then open | |
2933 * it if we have errors; otherwise, leave it closed. | |
2934 */ | |
644 | 2935 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid |
2795 | 2936 || qi->qf_lists[qi->qf_curlist].qf_count == 0 |
857 | 2937 || qi->qf_curlist >= qi->qf_listcount) |
7 | 2938 { |
2939 if (win != NULL) | |
2940 ex_cclose(eap); | |
2941 } | |
2942 else if (win == NULL) | |
2943 ex_copen(eap); | |
2944 } | |
2945 | |
2946 /* | |
2947 * ":cclose": close the window showing the list of errors. | |
644 | 2948 * ":lclose": close the window showing the location list |
7 | 2949 */ |
2950 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2951 ex_cclose(exarg_T *eap) |
7 | 2952 { |
644 | 2953 win_T *win = NULL; |
2954 qf_info_T *qi = &ql_info; | |
2955 | |
2956 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow) | |
2957 { | |
2958 qi = GET_LOC_LIST(curwin); | |
2959 if (qi == NULL) | |
2960 return; | |
2961 } | |
2962 | |
2963 /* Find existing quickfix window and close it. */ | |
2964 win = qf_find_win(qi); | |
7 | 2965 if (win != NULL) |
2966 win_close(win, FALSE); | |
2967 } | |
2968 | |
2969 /* | |
2970 * ":copen": open a window that shows the list of errors. | |
644 | 2971 * ":lopen": open a window that shows the location list. |
7 | 2972 */ |
2973 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2974 ex_copen(exarg_T *eap) |
7 | 2975 { |
644 | 2976 qf_info_T *qi = &ql_info; |
7 | 2977 int height; |
2978 win_T *win; | |
682 | 2979 tabpage_T *prevtab = curtab; |
859 | 2980 buf_T *qf_buf; |
1743 | 2981 win_T *oldwin = curwin; |
7 | 2982 |
644 | 2983 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
2984 { | |
2985 qi = GET_LOC_LIST(curwin); | |
2986 if (qi == NULL) | |
2987 { | |
2988 EMSG(_(e_loclist)); | |
2989 return; | |
2990 } | |
2991 } | |
2992 | |
7 | 2993 if (eap->addr_count != 0) |
2994 height = eap->line2; | |
2995 else | |
2996 height = QF_WINHEIGHT; | |
2997 | |
2998 reset_VIsual_and_resel(); /* stop Visual mode */ | |
2999 #ifdef FEAT_GUI | |
3000 need_mouse_correct = TRUE; | |
3001 #endif | |
3002 | |
3003 /* | |
3004 * Find existing quickfix window, or open a new one. | |
3005 */ | |
644 | 3006 win = qf_find_win(qi); |
3007 | |
682 | 3008 if (win != NULL && cmdmod.tab == 0) |
5753 | 3009 { |
7 | 3010 win_goto(win); |
5753 | 3011 if (eap->addr_count != 0) |
3012 { | |
3013 if (cmdmod.split & WSP_VERT) | |
3014 { | |
3015 if (height != W_WIDTH(win)) | |
3016 win_setwidth(height); | |
3017 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8605
diff
changeset
|
3018 else if (height != win->w_height) |
5753 | 3019 win_setheight(height); |
3020 } | |
3021 } | |
7 | 3022 else |
3023 { | |
859 | 3024 qf_buf = qf_find_buf(qi); |
3025 | |
7 | 3026 /* The current window becomes the previous window afterwards. */ |
3027 win = curwin; | |
3028 | |
3939 | 3029 if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow) |
3030 && cmdmod.split == 0) | |
3031 /* Create the new window at the very bottom, except when | |
3032 * :belowright or :aboveleft is used. */ | |
644 | 3033 win_goto(lastwin); |
1822 | 3034 if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL) |
7 | 3035 return; /* not enough room for window */ |
2583 | 3036 RESET_BINDING(curwin); |
7 | 3037 |
644 | 3038 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
7 | 3039 { |
644 | 3040 /* |
3041 * For the location list window, create a reference to the | |
3042 * location list from the window 'win'. | |
3043 */ | |
3044 curwin->w_llist_ref = win->w_llist; | |
3045 win->w_llist->qf_refcount++; | |
7 | 3046 } |
644 | 3047 |
1743 | 3048 if (oldwin != curwin) |
3049 oldwin = NULL; /* don't store info when in another window */ | |
859 | 3050 if (qf_buf != NULL) |
3051 /* Use the existing quickfix buffer */ | |
3052 (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, | |
1743 | 3053 ECMD_HIDE + ECMD_OLDBUF, oldwin); |
859 | 3054 else |
3055 { | |
3056 /* Create a new quickfix buffer */ | |
1743 | 3057 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin); |
859 | 3058 /* switch off 'swapfile' */ |
3059 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); | |
3060 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", | |
729 | 3061 OPT_LOCAL); |
859 | 3062 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); |
2651 | 3063 RESET_BINDING(curwin); |
1864 | 3064 #ifdef FEAT_DIFF |
3065 curwin->w_p_diff = FALSE; | |
3066 #endif | |
3067 #ifdef FEAT_FOLDING | |
3068 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual", | |
3069 OPT_LOCAL); | |
3070 #endif | |
859 | 3071 } |
7 | 3072 |
682 | 3073 /* Only set the height when still in the same tab page and there is no |
3074 * window to the side. */ | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8605
diff
changeset
|
3075 if (curtab == prevtab && curwin->w_width == Columns) |
7 | 3076 win_setheight(height); |
3077 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */ | |
3078 if (win_valid(win)) | |
3079 prevwin = win; | |
3080 } | |
3081 | |
6793 | 3082 qf_set_title_var(qi); |
3083 | |
7 | 3084 /* |
3085 * Fill the buffer with the quickfix list. | |
3086 */ | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3087 qf_fill_buffer(qi, curbuf, NULL); |
644 | 3088 |
3089 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; | |
7 | 3090 curwin->w_cursor.col = 0; |
3091 check_cursor(); | |
3092 update_topline(); /* scroll to show the line */ | |
3093 } | |
3094 | |
3095 /* | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3096 * 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
|
3097 */ |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3098 static void |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3099 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
|
3100 { |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3101 win_T *old_curwin = curwin; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3102 |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3103 curwin = win; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3104 curbuf = win->w_buffer; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3105 curwin->w_cursor.lnum = lnum; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3106 curwin->w_cursor.col = 0; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3107 #ifdef FEAT_VIRTUALEDIT |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3108 curwin->w_cursor.coladd = 0; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3109 #endif |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3110 curwin->w_curswant = 0; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3111 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
|
3112 redraw_later(VALID); |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3113 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
|
3114 curwin = old_curwin; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3115 curbuf = curwin->w_buffer; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3116 } |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3117 |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3118 /* |
9458
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3119 * :cbottom/:lbottom commands. |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3120 */ |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3121 void |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3122 ex_cbottom(exarg_T *eap UNUSED) |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3123 { |
9458
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3124 qf_info_T *qi = &ql_info; |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3125 win_T *win; |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3126 |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3127 if (eap->cmdidx == CMD_lbottom) |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3128 { |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3129 qi = GET_LOC_LIST(curwin); |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3130 if (qi == NULL) |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3131 { |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3132 EMSG(_(e_loclist)); |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3133 return; |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3134 } |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3135 } |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3136 |
374afcf9d11d
commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
3137 win = qf_find_win(qi); |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3138 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
|
3139 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
|
3140 } |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3141 |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3142 /* |
7 | 3143 * Return the number of the current entry (line number in the quickfix |
3144 * window). | |
3145 */ | |
3146 linenr_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3147 qf_current_entry(win_T *wp) |
7 | 3148 { |
644 | 3149 qf_info_T *qi = &ql_info; |
3150 | |
3151 if (IS_LL_WINDOW(wp)) | |
3152 /* In the location list window, use the referenced location list */ | |
3153 qi = wp->w_llist_ref; | |
3154 | |
3155 return qi->qf_lists[qi->qf_curlist].qf_index; | |
7 | 3156 } |
3157 | |
3158 /* | |
3159 * Update the cursor position in the quickfix window to the current error. | |
3160 * Return TRUE if there is a quickfix window. | |
3161 */ | |
3162 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3163 qf_win_pos_update( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3164 qf_info_T *qi, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3165 int old_qf_index) /* previous qf_index or zero */ |
7 | 3166 { |
3167 win_T *win; | |
644 | 3168 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
7 | 3169 |
3170 /* | |
3171 * Put the cursor on the current error in the quickfix window, so that | |
3172 * it's viewable. | |
3173 */ | |
644 | 3174 win = qf_find_win(qi); |
7 | 3175 if (win != NULL |
3176 && qf_index <= win->w_buffer->b_ml.ml_line_count | |
3177 && old_qf_index != qf_index) | |
3178 { | |
3179 if (qf_index > old_qf_index) | |
3180 { | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3181 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
|
3182 win->w_redraw_bot = qf_index; |
7 | 3183 } |
3184 else | |
3185 { | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3186 win->w_redraw_top = qf_index; |
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3187 win->w_redraw_bot = old_qf_index; |
7 | 3188 } |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9397
diff
changeset
|
3189 qf_win_goto(win, qf_index); |
7 | 3190 } |
3191 return win != NULL; | |
3192 } | |
3193 | |
3194 /* | |
859 | 3195 * Check whether the given window is displaying the specified quickfix/location |
3196 * list buffer | |
3197 */ | |
3198 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3199 is_qf_win(win_T *win, qf_info_T *qi) |
859 | 3200 { |
3201 /* | |
3202 * A window displaying the quickfix buffer will have the w_llist_ref field | |
3203 * set to NULL. | |
3204 * A window displaying a location list buffer will have the w_llist_ref | |
3205 * pointing to the location list. | |
3206 */ | |
3207 if (bt_quickfix(win->w_buffer)) | |
3208 if ((qi == &ql_info && win->w_llist_ref == NULL) | |
3209 || (qi != &ql_info && win->w_llist_ref == qi)) | |
3210 return TRUE; | |
3211 | |
3212 return FALSE; | |
3213 } | |
3214 | |
3215 /* | |
644 | 3216 * Find a window displaying the quickfix/location list 'qi' |
859 | 3217 * Searches in only the windows opened in the current tab. |
644 | 3218 */ |
3219 static win_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3220 qf_find_win(qf_info_T *qi) |
644 | 3221 { |
3222 win_T *win; | |
3223 | |
3224 FOR_ALL_WINDOWS(win) | |
859 | 3225 if (is_qf_win(win, qi)) |
3226 break; | |
644 | 3227 |
3228 return win; | |
3229 } | |
3230 | |
3231 /* | |
859 | 3232 * Find a quickfix buffer. |
3233 * Searches in windows opened in all the tabs. | |
7 | 3234 */ |
3235 static buf_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3236 qf_find_buf(qf_info_T *qi) |
7 | 3237 { |
859 | 3238 tabpage_T *tp; |
644 | 3239 win_T *win; |
3240 | |
859 | 3241 FOR_ALL_TAB_WINDOWS(tp, win) |
3242 if (is_qf_win(win, qi)) | |
3243 return win->w_buffer; | |
3244 | |
3245 return NULL; | |
7 | 3246 } |
3247 | |
3248 /* | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3249 * 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
|
3250 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3251 static void |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3252 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
|
3253 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3254 win_T *win; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3255 win_T *curwin_save; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3256 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3257 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
|
3258 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3259 curwin_save = curwin; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3260 curwin = win; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3261 qf_set_title_var(qi); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3262 curwin = curwin_save; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3263 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3264 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3265 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3266 /* |
7 | 3267 * Find the quickfix buffer. If it exists, update the contents. |
3268 */ | |
3269 static void | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3270 qf_update_buffer(qf_info_T *qi, qfline_T *old_last) |
7 | 3271 { |
3272 buf_T *buf; | |
3016 | 3273 win_T *win; |
7 | 3274 aco_save_T aco; |
3275 | |
3276 /* Check if a buffer for the quickfix list exists. Update it. */ | |
644 | 3277 buf = qf_find_buf(qi); |
7 | 3278 if (buf != NULL) |
3279 { | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3280 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
|
3281 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3282 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3283 /* 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
|
3284 aucmd_prepbuf(&aco, buf); |
7 | 3285 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
3286 qf_update_win_titlevar(qi); |
3016 | 3287 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3288 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
|
3289 ++CHANGEDTICK(buf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3290 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3291 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3292 { |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
3293 (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
|
3294 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3295 /* 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
|
3296 aucmd_restbuf(&aco); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3297 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3298 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3299 /* 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
|
3300 * 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
|
3301 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
|
3302 redraw_buf_later(buf, NOT_VALID); |
7 | 3303 } |
3304 } | |
3305 | |
6793 | 3306 /* |
3307 * Set "w:quickfix_title" if "qi" has a title. | |
3308 */ | |
3016 | 3309 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3310 qf_set_title_var(qf_info_T *qi) |
3016 | 3311 { |
6793 | 3312 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) |
3313 set_internal_string_var((char_u *)"w:quickfix_title", | |
3016 | 3314 qi->qf_lists[qi->qf_curlist].qf_title); |
3315 } | |
3316 | |
7 | 3317 /* |
3318 * Fill current buffer with quickfix errors, replacing any previous contents. | |
3319 * 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
|
3320 * 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
|
3321 * 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
|
3322 * ml_delete() is used and autocommands will be triggered. |
7 | 3323 */ |
3324 static void | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3325 qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) |
7 | 3326 { |
230 | 3327 linenr_T lnum; |
3328 qfline_T *qfp; | |
3329 buf_T *errbuf; | |
3330 int len; | |
3331 int old_KeyTyped = KeyTyped; | |
7 | 3332 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3333 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3334 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3335 if (buf != curbuf) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3336 { |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
3337 internal_error("qf_fill_buffer()"); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3338 return; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3339 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3340 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3341 /* delete all existing lines */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3342 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
|
3343 (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
|
3344 } |
7 | 3345 |
3346 /* Check if there is anything to display */ | |
644 | 3347 if (qi->qf_curlist < qi->qf_listcount) |
7 | 3348 { |
3349 /* 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
|
3350 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3351 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3352 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
|
3353 lnum = 0; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3354 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3355 else |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3356 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3357 qfp = old_last->qf_next; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3358 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
|
3359 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3360 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count) |
7 | 3361 { |
3362 if (qfp->qf_fnum != 0 | |
3363 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL | |
3364 && errbuf->b_fname != NULL) | |
3365 { | |
3366 if (qfp->qf_type == 1) /* :helpgrep */ | |
3367 STRCPY(IObuff, gettail(errbuf->b_fname)); | |
3368 else | |
3369 STRCPY(IObuff, errbuf->b_fname); | |
3370 len = (int)STRLEN(IObuff); | |
3371 } | |
3372 else | |
3373 len = 0; | |
3374 IObuff[len++] = '|'; | |
3375 | |
3376 if (qfp->qf_lnum > 0) | |
3377 { | |
3378 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum); | |
3379 len += (int)STRLEN(IObuff + len); | |
3380 | |
3381 if (qfp->qf_col > 0) | |
3382 { | |
3383 sprintf((char *)IObuff + len, " col %d", qfp->qf_col); | |
3384 len += (int)STRLEN(IObuff + len); | |
3385 } | |
3386 | |
3387 sprintf((char *)IObuff + len, "%s", | |
3388 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); | |
3389 len += (int)STRLEN(IObuff + len); | |
3390 } | |
230 | 3391 else if (qfp->qf_pattern != NULL) |
3392 { | |
3393 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); | |
3394 len += (int)STRLEN(IObuff + len); | |
3395 } | |
7 | 3396 IObuff[len++] = '|'; |
3397 IObuff[len++] = ' '; | |
3398 | |
3399 /* Remove newlines and leading whitespace from the text. | |
3400 * For an unrecognized line keep the indent, the compiler may | |
3401 * mark a word with ^^^^. */ | |
3402 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, | |
3403 IObuff + len, IOSIZE - len); | |
3404 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3405 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
|
3406 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL) |
7 | 3407 break; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3408 ++lnum; |
7 | 3409 qfp = qfp->qf_next; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3410 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3411 break; |
7 | 3412 } |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3413 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3414 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3415 /* 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
|
3416 (void)ml_delete(lnum + 1, FALSE); |
7 | 3417 } |
3418 | |
3419 /* correct cursor position */ | |
3420 check_lnums(TRUE); | |
3421 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3422 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3423 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3424 /* 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
|
3425 * 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
|
3426 * using autocommands. */ |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3427 #ifdef FEAT_AUTOCMD |
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3428 ++curbuf_lock; |
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3429 #endif |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3430 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
|
3431 curbuf->b_p_ma = FALSE; |
7 | 3432 |
3433 #ifdef FEAT_AUTOCMD | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3434 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
|
3435 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, |
7 | 3436 FALSE, curbuf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3437 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL, |
7 | 3438 FALSE, curbuf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3439 keep_filetype = FALSE; |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11549
diff
changeset
|
3440 --curbuf_lock; |
7 | 3441 #endif |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3442 /* make sure it will be redrawn */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3443 redraw_curbuf_later(NOT_VALID); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3444 } |
7 | 3445 |
3446 /* Restore KeyTyped, setting 'filetype' may reset it. */ | |
3447 KeyTyped = old_KeyTyped; | |
3448 } | |
3449 | |
3450 #endif /* FEAT_WINDOWS */ | |
3451 | |
3452 /* | |
41 | 3453 * Return TRUE when using ":vimgrep" for ":grep". |
3454 */ | |
3455 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3456 grep_internal(cmdidx_T cmdidx) |
41 | 3457 { |
661 | 3458 return ((cmdidx == CMD_grep |
3459 || cmdidx == CMD_lgrep | |
3460 || cmdidx == CMD_grepadd | |
3461 || cmdidx == CMD_lgrepadd) | |
41 | 3462 && STRCMP("internal", |
3463 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0); | |
3464 } | |
3465 | |
3466 /* | |
657 | 3467 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd" |
7 | 3468 */ |
3469 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3470 ex_make(exarg_T *eap) |
7 | 3471 { |
161 | 3472 char_u *fname; |
7 | 3473 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
|
3474 char_u *enc = NULL; |
7 | 3475 unsigned len; |
657 | 3476 win_T *wp = NULL; |
659 | 3477 qf_info_T *qi = &ql_info; |
842 | 3478 int res; |
161 | 3479 #ifdef FEAT_AUTOCMD |
3480 char_u *au_name = NULL; | |
3481 | |
2782 | 3482 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */ |
3483 if (grep_internal(eap->cmdidx)) | |
3484 { | |
3485 ex_vimgrep(eap); | |
3486 return; | |
3487 } | |
3488 | |
161 | 3489 switch (eap->cmdidx) |
3490 { | |
661 | 3491 case CMD_make: au_name = (char_u *)"make"; break; |
3492 case CMD_lmake: au_name = (char_u *)"lmake"; break; | |
3493 case CMD_grep: au_name = (char_u *)"grep"; break; | |
3494 case CMD_lgrep: au_name = (char_u *)"lgrep"; break; | |
3495 case CMD_grepadd: au_name = (char_u *)"grepadd"; break; | |
3496 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break; | |
161 | 3497 default: break; |
3498 } | |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
3499 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
|
3500 curbuf->b_fname, TRUE, curbuf)) |
161 | 3501 { |
532 | 3502 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
3503 if (aborting()) |
161 | 3504 return; |
532 | 3505 # endif |
161 | 3506 } |
3507 #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
|
3508 #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
|
3509 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
|
3510 #endif |
7 | 3511 |
657 | 3512 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep |
3513 || eap->cmdidx == CMD_lgrepadd) | |
3514 wp = curwin; | |
3515 | |
7 | 3516 autowrite_all(); |
161 | 3517 fname = get_mef_name(); |
3518 if (fname == NULL) | |
7 | 3519 return; |
161 | 3520 mch_remove(fname); /* in case it's not unique */ |
7 | 3521 |
3522 /* | |
3523 * If 'shellpipe' empty: don't redirect to 'errorfile'. | |
3524 */ | |
3525 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1; | |
3526 if (*p_sp != NUL) | |
161 | 3527 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3; |
7 | 3528 cmd = alloc(len); |
3529 if (cmd == NULL) | |
3530 return; | |
3531 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg, | |
3532 (char *)p_shq); | |
3533 if (*p_sp != NUL) | |
1872 | 3534 append_redir(cmd, len, p_sp, fname); |
7 | 3535 /* |
3536 * Output a newline if there's something else than the :make command that | |
3537 * was typed (in which case the cursor is in column 0). | |
3538 */ | |
3539 if (msg_col == 0) | |
3540 msg_didout = FALSE; | |
3541 msg_start(); | |
3542 MSG_PUTS(":!"); | |
3543 msg_outtrans(cmd); /* show what we are doing */ | |
3544 | |
3545 /* let the shell know if we are redirecting output or not */ | |
3546 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0); | |
3547 | |
3548 #ifdef AMIGA | |
3549 out_flush(); | |
3550 /* read window status report and redraw before message */ | |
3551 (void)char_avail(); | |
3552 #endif | |
3553 | |
842 | 3554 res = qf_init(wp, fname, (eap->cmdidx != CMD_make |
657 | 3555 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, |
3556 (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
|
3557 && 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
|
3558 *eap->cmdlinep, enc); |
2847 | 3559 if (wp != NULL) |
3560 qi = GET_LOC_LIST(wp); | |
842 | 3561 #ifdef FEAT_AUTOCMD |
3562 if (au_name != NULL) | |
2847 | 3563 { |
842 | 3564 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
3565 curbuf->b_fname, TRUE, curbuf); | |
2847 | 3566 if (qi->qf_curlist < qi->qf_listcount) |
3567 res = qi->qf_lists[qi->qf_curlist].qf_count; | |
3568 else | |
3569 res = 0; | |
3570 } | |
842 | 3571 #endif |
3572 if (res > 0 && !eap->forceit) | |
659 | 3573 qf_jump(qi, 0, 0, FALSE); /* display first error */ |
7 | 3574 |
161 | 3575 mch_remove(fname); |
3576 vim_free(fname); | |
7 | 3577 vim_free(cmd); |
3578 } | |
3579 | |
3580 /* | |
3581 * Return the name for the errorfile, in allocated memory. | |
3582 * Find a new unique name when 'makeef' contains "##". | |
3583 * Returns NULL for error. | |
3584 */ | |
3585 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3586 get_mef_name(void) |
7 | 3587 { |
3588 char_u *p; | |
3589 char_u *name; | |
3590 static int start = -1; | |
3591 static int off = 0; | |
3592 #ifdef HAVE_LSTAT | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
3593 stat_T sb; |
7 | 3594 #endif |
3595 | |
3596 if (*p_mef == NUL) | |
3597 { | |
6721 | 3598 name = vim_tempname('e', FALSE); |
7 | 3599 if (name == NULL) |
3600 EMSG(_(e_notmp)); | |
3601 return name; | |
3602 } | |
3603 | |
3604 for (p = p_mef; *p; ++p) | |
3605 if (p[0] == '#' && p[1] == '#') | |
3606 break; | |
3607 | |
3608 if (*p == NUL) | |
3609 return vim_strsave(p_mef); | |
3610 | |
3611 /* Keep trying until the name doesn't exist yet. */ | |
3612 for (;;) | |
3613 { | |
3614 if (start == -1) | |
3615 start = mch_get_pid(); | |
3616 else | |
3617 off += 19; | |
3618 | |
3619 name = alloc((unsigned)STRLEN(p_mef) + 30); | |
3620 if (name == NULL) | |
3621 break; | |
3622 STRCPY(name, p_mef); | |
3623 sprintf((char *)name + (p - p_mef), "%d%d", start, off); | |
3624 STRCAT(name, p + 2); | |
3625 if (mch_getperm(name) < 0 | |
3626 #ifdef HAVE_LSTAT | |
10226
7a4fb555c83a
commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents:
10056
diff
changeset
|
3627 /* Don't accept a symbolic link, it's a security risk. */ |
7 | 3628 && mch_lstat((char *)name, &sb) < 0 |
3629 #endif | |
3630 ) | |
3631 break; | |
3632 vim_free(name); | |
3633 } | |
3634 return name; | |
3635 } | |
3636 | |
3637 /* | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3638 * 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
|
3639 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3640 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3641 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
|
3642 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3643 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3644 qfline_T *qfp; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3645 int i, sz = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3646 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3647 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3648 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
|
3649 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3650 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3651 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3652 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3653 return 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3654 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3655 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3656 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
|
3657 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
|
3658 ++i, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3659 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3660 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3661 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3662 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
|
3663 sz++; /* Count all valid entries */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3664 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
|
3665 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3666 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3667 sz++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3668 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3669 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3670 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3671 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3672 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3673 return sz; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3674 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3675 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3676 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3677 * 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
|
3678 * 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
|
3679 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3680 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3681 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
|
3682 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3683 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3684 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3685 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
|
3686 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3687 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3688 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3689 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3690 return 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3691 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3692 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3693 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
|
3694 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3695 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3696 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3697 * 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
|
3698 * 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
|
3699 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3700 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3701 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
|
3702 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3703 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3704 qf_list_T *qfl; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3705 qfline_T *qfp; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3706 int i, eidx = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3707 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3708 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3709 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
|
3710 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3711 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3712 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3713 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3714 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3715 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3716 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3717 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
|
3718 qfp = qfl->qf_start; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3719 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3720 /* 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
|
3721 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
|
3722 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3723 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3724 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
|
3725 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3726 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3727 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3728 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
|
3729 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3730 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
|
3731 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3732 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3733 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3734 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3735 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3736 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3737 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3738 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3739 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3740 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3741 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3742 return eidx ? eidx : 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3743 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3744 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3745 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3746 * 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
|
3747 * 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
|
3748 * 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
|
3749 * 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
|
3750 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3751 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3752 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
|
3753 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3754 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
|
3755 qfline_T *qfp = qfl->qf_start; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3756 int i, eidx; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3757 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3758 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3759 /* 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
|
3760 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
|
3761 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3762 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3763 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
|
3764 i++, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3765 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3766 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3767 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3768 if (fdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3769 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3770 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
|
3771 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3772 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3773 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3774 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3775 } |
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 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3778 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3779 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3780 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3781 if (eidx == n) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3782 break; |
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 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3785 if (i <= qfl->qf_count) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3786 return i; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3787 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3788 return 1; |
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 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3791 /* |
7 | 3792 * ":cc", ":crewind", ":cfirst" and ":clast". |
644 | 3793 * ":ll", ":lrewind", ":lfirst" and ":llast". |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3794 * ":cdo", ":ldo", ":cfdo" and ":lfdo" |
7 | 3795 */ |
3796 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3797 ex_cc(exarg_T *eap) |
7 | 3798 { |
659 | 3799 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
|
3800 int errornr; |
659 | 3801 |
3802 if (eap->cmdidx == CMD_ll | |
3803 || eap->cmdidx == CMD_lrewind | |
3804 || eap->cmdidx == CMD_lfirst | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3805 || eap->cmdidx == CMD_llast |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3806 || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3807 || eap->cmdidx == CMD_lfdo) |
644 | 3808 { |
3809 qi = GET_LOC_LIST(curwin); | |
3810 if (qi == NULL) | |
3811 { | |
3812 EMSG(_(e_loclist)); | |
3813 return; | |
3814 } | |
3815 } | |
3816 | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3817 if (eap->addr_count > 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3818 errornr = (int)eap->line2; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3819 else |
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 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
|
3822 errornr = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3823 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
|
3824 || 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
|
3825 errornr = 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3826 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3827 errornr = 32767; |
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 /* 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
|
3831 * 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
|
3832 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3833 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
|
3834 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
|
3835 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
|
3836 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
|
3837 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
|
3838 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3839 qf_jump(qi, 0, errornr, eap->forceit); |
7 | 3840 } |
3841 | |
3842 /* | |
3843 * ":cnext", ":cnfile", ":cNext" and ":cprevious". | |
644 | 3844 * ":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
|
3845 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands. |
7 | 3846 */ |
3847 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3848 ex_cnext(exarg_T *eap) |
7 | 3849 { |
659 | 3850 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
|
3851 int errornr; |
659 | 3852 |
3853 if (eap->cmdidx == CMD_lnext | |
3854 || eap->cmdidx == CMD_lNext | |
3855 || eap->cmdidx == CMD_lprevious | |
3856 || eap->cmdidx == CMD_lnfile | |
3857 || eap->cmdidx == CMD_lNfile | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3858 || eap->cmdidx == CMD_lpfile |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3859 || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3860 || eap->cmdidx == CMD_lfdo) |
644 | 3861 { |
3862 qi = GET_LOC_LIST(curwin); | |
3863 if (qi == NULL) | |
3864 { | |
3865 EMSG(_(e_loclist)); | |
3866 return; | |
3867 } | |
3868 } | |
3869 | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3870 if (eap->addr_count > 0 && |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3871 (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
|
3872 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
|
3873 errornr = (int)eap->line2; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3874 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3875 errornr = 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3876 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3877 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
|
3878 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
7 | 3879 ? FORWARD |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3880 : (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
|
3881 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
7 | 3882 ? FORWARD_FILE |
644 | 3883 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile |
3884 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile) | |
7 | 3885 ? BACKWARD_FILE |
3886 : BACKWARD, | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3887 errornr, eap->forceit); |
7 | 3888 } |
3889 | |
3890 /* | |
446 | 3891 * ":cfile"/":cgetfile"/":caddfile" commands. |
644 | 3892 * ":lfile"/":lgetfile"/":laddfile" commands. |
7 | 3893 */ |
3894 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3895 ex_cfile(exarg_T *eap) |
7 | 3896 { |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10379
diff
changeset
|
3897 char_u *enc = NULL; |
644 | 3898 win_T *wp = NULL; |
659 | 3899 qf_info_T *qi = &ql_info; |
3404 | 3900 #ifdef FEAT_AUTOCMD |
3901 char_u *au_name = NULL; | |
3902 #endif | |
644 | 3903 |
3904 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile | |
3404 | 3905 || eap->cmdidx == CMD_laddfile) |
644 | 3906 wp = curwin; |
3907 | |
3404 | 3908 #ifdef FEAT_AUTOCMD |
3909 switch (eap->cmdidx) | |
3910 { | |
3911 case CMD_cfile: au_name = (char_u *)"cfile"; break; | |
3912 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break; | |
3913 case CMD_caddfile: au_name = (char_u *)"caddfile"; break; | |
3914 case CMD_lfile: au_name = (char_u *)"lfile"; break; | |
3915 case CMD_lgetfile: au_name = (char_u *)"lgetfile"; break; | |
3916 case CMD_laddfile: au_name = (char_u *)"laddfile"; break; | |
3917 default: break; | |
3918 } | |
3919 if (au_name != NULL) | |
3920 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); | |
3921 #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
|
3922 #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
|
3923 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
|
3924 #endif |
2296
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3925 #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
|
3926 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
|
3927 { |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3928 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
|
3929 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
|
3930 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
|
3931 return; |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3932 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
|
3933 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
|
3934 } |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3935 else |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3936 #endif |
7 | 3937 if (*eap->arg != NUL) |
694 | 3938 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); |
446 | 3939 |
3940 /* | |
3941 * This function is used by the :cfile, :cgetfile and :caddfile | |
3942 * commands. | |
3943 * :cfile always creates a new quickfix list and jumps to the | |
3944 * first error. | |
3945 * :cgetfile creates a new quickfix list but doesn't jump to the | |
3946 * first error. | |
3947 * :caddfile adds to an existing quickfix list. If there is no | |
3948 * quickfix list then a new list is created. | |
3949 */ | |
644 | 3950 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
|
3951 && 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
|
3952 *eap->cmdlinep, enc) > 0 |
644 | 3953 && (eap->cmdidx == CMD_cfile |
3954 || eap->cmdidx == CMD_lfile)) | |
665 | 3955 { |
3404 | 3956 #ifdef FEAT_AUTOCMD |
3957 if (au_name != NULL) | |
3958 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | |
3959 #endif | |
665 | 3960 if (wp != NULL) |
3961 qi = GET_LOC_LIST(wp); | |
659 | 3962 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
665 | 3963 } |
3404 | 3964 |
3965 else | |
3966 { | |
3967 #ifdef FEAT_AUTOCMD | |
3968 if (au_name != NULL) | |
3969 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | |
3970 #endif | |
3971 } | |
7 | 3972 } |
3973 | |
3974 /* | |
41 | 3975 * ":vimgrep {pattern} file(s)" |
657 | 3976 * ":vimgrepadd {pattern} file(s)" |
3977 * ":lvimgrep {pattern} file(s)" | |
3978 * ":lvimgrepadd {pattern} file(s)" | |
41 | 3979 */ |
3980 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3981 ex_vimgrep(exarg_T *eap) |
41 | 3982 { |
42 | 3983 regmmatch_T regmatch; |
153 | 3984 int fcount; |
41 | 3985 char_u **fnames; |
1411 | 3986 char_u *fname; |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
3987 char_u *title; |
153 | 3988 char_u *s; |
3989 char_u *p; | |
3990 int fi; | |
657 | 3991 qf_info_T *qi = &ql_info; |
4003 | 3992 #ifdef FEAT_AUTOCMD |
3993 qfline_T *cur_qf_start; | |
3994 #endif | |
41 | 3995 long lnum; |
42 | 3996 buf_T *buf; |
3997 int duplicate_name = FALSE; | |
3998 int using_dummy; | |
1396 | 3999 int redraw_for_dummy = FALSE; |
42 | 4000 int found_match; |
123 | 4001 buf_T *first_match_buf = NULL; |
4002 time_t seconds = 0; | |
677 | 4003 int save_mls; |
123 | 4004 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
4005 char_u *save_ei = NULL; | |
677 | 4006 #endif |
123 | 4007 aco_save_T aco; |
170 | 4008 int flags = 0; |
4009 colnr_T col; | |
716 | 4010 long tomatch; |
2770 | 4011 char_u *dirname_start = NULL; |
4012 char_u *dirname_now = NULL; | |
1411 | 4013 char_u *target_dir = NULL; |
1683 | 4014 #ifdef FEAT_AUTOCMD |
4015 char_u *au_name = NULL; | |
161 | 4016 |
4017 switch (eap->cmdidx) | |
4018 { | |
2782 | 4019 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break; |
4020 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break; | |
4021 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break; | |
657 | 4022 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break; |
2782 | 4023 case CMD_grep: au_name = (char_u *)"grep"; break; |
4024 case CMD_lgrep: au_name = (char_u *)"lgrep"; break; | |
4025 case CMD_grepadd: au_name = (char_u *)"grepadd"; break; | |
4026 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break; | |
161 | 4027 default: break; |
4028 } | |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4029 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
|
4030 curbuf->b_fname, TRUE, curbuf)) |
161 | 4031 { |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4032 # ifdef FEAT_EVAL |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4033 if (aborting()) |
161 | 4034 return; |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
4035 # endif |
161 | 4036 } |
4037 #endif | |
41 | 4038 |
661 | 4039 if (eap->cmdidx == CMD_lgrep |
659 | 4040 || eap->cmdidx == CMD_lvimgrep |
4041 || eap->cmdidx == CMD_lgrepadd | |
4042 || eap->cmdidx == CMD_lvimgrepadd) | |
657 | 4043 { |
4044 qi = ll_get_or_alloc_list(curwin); | |
4045 if (qi == NULL) | |
4046 return; | |
4047 } | |
4048 | |
716 | 4049 if (eap->addr_count > 0) |
4050 tomatch = eap->line2; | |
4051 else | |
4052 tomatch = MAXLNUM; | |
4053 | |
42 | 4054 /* Get the search pattern: either white-separated or enclosed in // */ |
41 | 4055 regmatch.regprog = NULL; |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4056 title = vim_strsave(*eap->cmdlinep); |
170 | 4057 p = skip_vimgrep_pat(eap->arg, &s, &flags); |
153 | 4058 if (p == NULL) |
41 | 4059 { |
282 | 4060 EMSG(_(e_invalpat)); |
153 | 4061 goto theend; |
41 | 4062 } |
4197 | 4063 |
4064 if (s != NULL && *s == NUL) | |
4065 { | |
4066 /* Pattern is empty, use last search pattern. */ | |
4067 if (last_search_pat() == NULL) | |
4068 { | |
4069 EMSG(_(e_noprevre)); | |
4070 goto theend; | |
4071 } | |
4072 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); | |
4073 } | |
4074 else | |
4075 regmatch.regprog = vim_regcomp(s, RE_MAGIC); | |
4076 | |
41 | 4077 if (regmatch.regprog == NULL) |
4078 goto theend; | |
95 | 4079 regmatch.rmm_ic = p_ic; |
410 | 4080 regmatch.rmm_maxcol = 0; |
41 | 4081 |
4082 p = skipwhite(p); | |
4083 if (*p == NUL) | |
4084 { | |
4085 EMSG(_("E683: File name missing or invalid pattern")); | |
4086 goto theend; | |
4087 } | |
4088 | |
661 | 4089 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd && |
657 | 4090 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd) |
644 | 4091 || qi->qf_curlist == qi->qf_listcount) |
41 | 4092 /* 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
|
4093 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep); |
41 | 4094 |
4095 /* parse the list of arguments */ | |
3620 | 4096 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) |
41 | 4097 goto theend; |
4098 if (fcount == 0) | |
4099 { | |
4100 EMSG(_(e_nomatch)); | |
4101 goto theend; | |
4102 } | |
4103 | |
7558
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
4104 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
|
4105 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now); |
2770 | 4106 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
|
4107 { |
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
4108 FreeWild(fcount, fnames); |
2770 | 4109 goto theend; |
7662
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
4110 } |
2770 | 4111 |
1411 | 4112 /* Remember the current directory, because a BufRead autocommand that does |
4113 * ":lcd %:p:h" changes the meaning of short path names. */ | |
4114 mch_dirname(dirname_start, MAXPATHL); | |
4115 | |
4003 | 4116 #ifdef FEAT_AUTOCMD |
4352 | 4117 /* Remember the value of qf_start, so that we can check for autocommands |
4003 | 4118 * changing the current quickfix list. */ |
4119 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
4120 #endif | |
4121 | |
123 | 4122 seconds = (time_t)0; |
716 | 4123 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi) |
41 | 4124 { |
1411 | 4125 fname = shorten_fname1(fnames[fi]); |
123 | 4126 if (time(NULL) > seconds) |
4127 { | |
1411 | 4128 /* Display the file name every second or so, show the user we are |
4129 * working on it. */ | |
123 | 4130 seconds = time(NULL); |
4131 msg_start(); | |
1411 | 4132 p = msg_strtrunc(fname, TRUE); |
123 | 4133 if (p == NULL) |
1411 | 4134 msg_outtrans(fname); |
123 | 4135 else |
4136 { | |
4137 msg_outtrans(p); | |
4138 vim_free(p); | |
4139 } | |
4140 msg_clr_eos(); | |
4141 msg_didout = FALSE; /* overwrite this message */ | |
4142 msg_nowait = TRUE; /* don't wait for this message */ | |
4143 msg_col = 0; | |
4144 out_flush(); | |
4145 } | |
4146 | |
42 | 4147 buf = buflist_findname_exp(fnames[fi]); |
4148 if (buf == NULL || buf->b_ml.ml_mfp == NULL) | |
4149 { | |
4150 /* Remember that a buffer with this name already exists. */ | |
4151 duplicate_name = (buf != NULL); | |
123 | 4152 using_dummy = TRUE; |
1396 | 4153 redraw_for_dummy = TRUE; |
123 | 4154 |
4155 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) | |
4156 /* Don't do Filetype autocommands to avoid loading syntax and | |
4157 * indent scripts, a great speed improvement. */ | |
4158 save_ei = au_event_disable(",Filetype"); | |
4159 #endif | |
677 | 4160 /* Don't use modelines here, it's useless. */ |
4161 save_mls = p_mls; | |
4162 p_mls = 0; | |
42 | 4163 |
4164 /* Load file into a buffer, so that 'fileencoding' is detected, | |
4165 * autocommands applied, etc. */ | |
3490 | 4166 buf = load_dummy_buffer(fname, dirname_start, dirname_now); |
123 | 4167 |
677 | 4168 p_mls = save_mls; |
123 | 4169 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
4170 au_event_restore(save_ei); | |
4171 #endif | |
42 | 4172 } |
4173 else | |
4174 /* Use existing, loaded buffer. */ | |
4175 using_dummy = FALSE; | |
123 | 4176 |
4003 | 4177 #ifdef FEAT_AUTOCMD |
4178 if (cur_qf_start != qi->qf_lists[qi->qf_curlist].qf_start) | |
4179 { | |
4180 int idx; | |
4181 | |
4182 /* Autocommands changed the quickfix list. Find the one we were | |
4183 * using and restore it. */ | |
4184 for (idx = 0; idx < LISTCOUNT; ++idx) | |
4185 if (cur_qf_start == qi->qf_lists[idx].qf_start) | |
4186 { | |
4187 qi->qf_curlist = idx; | |
4188 break; | |
4189 } | |
4190 if (idx == LISTCOUNT) | |
4191 { | |
4192 /* List cannot be found, create a new one. */ | |
4193 qf_new_list(qi, *eap->cmdlinep); | |
4194 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
4195 } | |
4196 } | |
4197 #endif | |
4198 | |
42 | 4199 if (buf == NULL) |
123 | 4200 { |
4201 if (!got_int) | |
1411 | 4202 smsg((char_u *)_("Cannot open file \"%s\""), fname); |
123 | 4203 } |
41 | 4204 else |
4205 { | |
717 | 4206 /* Try for a match in all lines of the buffer. |
4207 * For ":1vimgrep" look for first match only. */ | |
42 | 4208 found_match = FALSE; |
716 | 4209 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; |
4210 ++lnum) | |
41 | 4211 { |
170 | 4212 col = 0; |
4213 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
|
4214 col, NULL, NULL) > 0) |
41 | 4215 { |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4216 /* 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
|
4217 * 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
|
4218 * 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
|
4219 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
|
4220 qi->qf_curlist, |
41 | 4221 NULL, /* dir */ |
1411 | 4222 fname, |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4223 duplicate_name ? 0 : buf->b_fnum, |
42 | 4224 ml_get_buf(buf, |
4225 regmatch.startpos[0].lnum + lnum, FALSE), | |
4226 regmatch.startpos[0].lnum + lnum, | |
4227 regmatch.startpos[0].col + 1, | |
170 | 4228 FALSE, /* vis_col */ |
230 | 4229 NULL, /* search pattern */ |
856 | 4230 0, /* nr */ |
4231 0, /* type */ | |
4232 TRUE /* valid */ | |
41 | 4233 ) == FAIL) |
4234 { | |
4235 got_int = TRUE; | |
4236 break; | |
4237 } | |
716 | 4238 found_match = TRUE; |
4239 if (--tomatch == 0) | |
4240 break; | |
170 | 4241 if ((flags & VGR_GLOBAL) == 0 |
4242 || regmatch.endpos[0].lnum > 0) | |
4243 break; | |
4244 col = regmatch.endpos[0].col | |
4245 + (col == regmatch.endpos[0].col); | |
1883 | 4246 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE))) |
170 | 4247 break; |
41 | 4248 } |
4249 line_breakcheck(); | |
42 | 4250 if (got_int) |
4251 break; | |
41 | 4252 } |
4003 | 4253 #ifdef FEAT_AUTOCMD |
4254 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
4255 #endif | |
42 | 4256 |
4257 if (using_dummy) | |
4258 { | |
123 | 4259 if (found_match && first_match_buf == NULL) |
4260 first_match_buf = buf; | |
42 | 4261 if (duplicate_name) |
123 | 4262 { |
42 | 4263 /* Never keep a dummy buffer if there is another buffer |
4264 * with the same name. */ | |
3490 | 4265 wipe_dummy_buffer(buf, dirname_start); |
123 | 4266 buf = NULL; |
4267 } | |
717 | 4268 else if (!cmdmod.hide |
4269 || buf->b_p_bh[0] == 'u' /* "unload" */ | |
4270 || buf->b_p_bh[0] == 'w' /* "wipe" */ | |
4271 || buf->b_p_bh[0] == 'd') /* "delete" */ | |
42 | 4272 { |
717 | 4273 /* When no match was found we don't need to remember the |
4274 * buffer, wipe it out. If there was a match and it | |
4275 * wasn't the first one or we won't jump there: only | |
4276 * unload the buffer. | |
4277 * Ignore 'hidden' here, because it may lead to having too | |
4278 * many swap files. */ | |
42 | 4279 if (!found_match) |
123 | 4280 { |
3490 | 4281 wipe_dummy_buffer(buf, dirname_start); |
123 | 4282 buf = NULL; |
4283 } | |
170 | 4284 else if (buf != first_match_buf || (flags & VGR_NOJUMP)) |
123 | 4285 { |
3490 | 4286 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
|
4287 /* 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
|
4288 buf->b_flags &= ~BF_DUMMY; |
123 | 4289 buf = NULL; |
4290 } | |
42 | 4291 } |
123 | 4292 |
4293 if (buf != NULL) | |
4294 { | |
9540
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4295 /* 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
|
4296 buf->b_flags &= ~BF_DUMMY; |
64a791c53418
commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4297 |
1411 | 4298 /* If the buffer is still loaded we need to use the |
4299 * directory we jumped to below. */ | |
4300 if (buf == first_match_buf | |
4301 && target_dir == NULL | |
4302 && STRCMP(dirname_start, dirname_now) != 0) | |
4303 target_dir = vim_strsave(dirname_now); | |
4304 | |
123 | 4305 /* The buffer is still loaded, the Filetype autocommands |
677 | 4306 * need to be done now, in that buffer. And the modelines |
717 | 4307 * need to be done (again). But not the window-local |
4308 * options! */ | |
123 | 4309 aucmd_prepbuf(&aco, buf); |
677 | 4310 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
123 | 4311 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, |
4312 buf->b_fname, TRUE, buf); | |
677 | 4313 #endif |
717 | 4314 do_modelines(OPT_NOWIN); |
123 | 4315 aucmd_restbuf(&aco); |
4316 } | |
42 | 4317 } |
41 | 4318 } |
4319 } | |
4320 | |
4321 FreeWild(fcount, fnames); | |
4322 | |
644 | 4323 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
4324 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; | |
4325 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
41 | 4326 |
4327 #ifdef FEAT_WINDOWS | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4328 qf_update_buffer(qi, NULL); |
41 | 4329 #endif |
4330 | |
842 | 4331 #ifdef FEAT_AUTOCMD |
4332 if (au_name != NULL) | |
4333 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | |
4334 curbuf->b_fname, TRUE, curbuf); | |
4335 #endif | |
4336 | |
41 | 4337 /* Jump to first match. */ |
644 | 4338 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
170 | 4339 { |
4340 if ((flags & VGR_NOJUMP) == 0) | |
1396 | 4341 { |
4342 buf = curbuf; | |
659 | 4343 qf_jump(qi, 0, 0, eap->forceit); |
1396 | 4344 if (buf != curbuf) |
4345 /* If we jumped to another buffer redrawing will already be | |
4346 * taken care of. */ | |
4347 redraw_for_dummy = FALSE; | |
1411 | 4348 |
4349 /* Jump to the directory used after loading the buffer. */ | |
4350 if (curbuf == first_match_buf && target_dir != NULL) | |
4351 { | |
4352 exarg_T ea; | |
4353 | |
4354 ea.arg = target_dir; | |
4355 ea.cmdidx = CMD_lcd; | |
4356 ex_cd(&ea); | |
4357 } | |
1396 | 4358 } |
170 | 4359 } |
42 | 4360 else |
4361 EMSG2(_(e_nomatch2), s); | |
41 | 4362 |
1396 | 4363 /* If we loaded a dummy buffer into the current window, the autocommands |
4364 * may have messed up things, need to redraw and recompute folds. */ | |
4365 if (redraw_for_dummy) | |
4366 { | |
4367 #ifdef FEAT_FOLDING | |
4368 foldUpdateAll(curwin); | |
4369 #else | |
4370 redraw_later(NOT_VALID); | |
4371 #endif | |
4372 } | |
4373 | |
41 | 4374 theend: |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4375 vim_free(title); |
2770 | 4376 vim_free(dirname_now); |
4377 vim_free(dirname_start); | |
1411 | 4378 vim_free(target_dir); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4371
diff
changeset
|
4379 vim_regfree(regmatch.regprog); |
41 | 4380 } |
4381 | |
4382 /* | |
3490 | 4383 * Restore current working directory to "dirname_start" if they differ, taking |
4384 * into account whether it is set locally or globally. | |
4385 */ | |
4386 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4387 restore_start_dir(char_u *dirname_start) |
3490 | 4388 { |
4389 char_u *dirname_now = alloc(MAXPATHL); | |
4390 | |
4391 if (NULL != dirname_now) | |
4392 { | |
4393 mch_dirname(dirname_now, MAXPATHL); | |
4394 if (STRCMP(dirname_start, dirname_now) != 0) | |
4395 { | |
4396 /* If the directory has changed, change it back by building up an | |
4397 * appropriate ex command and executing it. */ | |
4398 exarg_T ea; | |
4399 | |
4400 ea.arg = dirname_start; | |
4401 ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd; | |
4402 ex_cd(&ea); | |
4403 } | |
3974 | 4404 vim_free(dirname_now); |
3490 | 4405 } |
4406 } | |
4407 | |
4408 /* | |
4409 * Load file "fname" into a dummy buffer and return the buffer pointer, | |
4410 * placing the directory resulting from the buffer load into the | |
4411 * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller | |
4412 * prior to calling this function. Restores directory to "dirname_start" prior | |
4413 * to returning, if autocmds or the 'autochdir' option have changed it. | |
4414 * | |
4415 * If creating the dummy buffer does not fail, must call unload_dummy_buffer() | |
4416 * or wipe_dummy_buffer() later! | |
4417 * | |
42 | 4418 * Returns NULL if it fails. |
4419 */ | |
4420 static buf_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4421 load_dummy_buffer( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4422 char_u *fname, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4423 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
|
4424 char_u *resulting_dir) /* out: new directory */ |
42 | 4425 { |
4426 buf_T *newbuf; | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4427 bufref_T newbufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4428 bufref_T newbuf_to_wipe; |
42 | 4429 int failed = TRUE; |
4430 aco_save_T aco; | |
4431 | |
4432 /* Allocate a buffer without putting it in the buffer list. */ | |
4433 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); | |
4434 if (newbuf == NULL) | |
4435 return NULL; | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4436 set_bufref(&newbufref, newbuf); |
42 | 4437 |
177 | 4438 /* Init the options. */ |
4439 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP); | |
4440 | |
1918 | 4441 /* need to open the memfile before putting the buffer in a window */ |
4442 if (ml_open(newbuf) == OK) | |
42 | 4443 { |
1918 | 4444 /* set curwin/curbuf to buf and save a few things */ |
4445 aucmd_prepbuf(&aco, newbuf); | |
4446 | |
4447 /* Need to set the filename for autocommands. */ | |
4448 (void)setfname(curbuf, fname, NULL, FALSE); | |
4449 | |
42 | 4450 /* Create swap file now to avoid the ATTENTION message. */ |
4451 check_need_swap(TRUE); | |
4452 | |
4453 /* Remove the "dummy" flag, otherwise autocommands may not | |
4454 * work. */ | |
4455 curbuf->b_flags &= ~BF_DUMMY; | |
4456 | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4457 newbuf_to_wipe.br_buf = NULL; |
42 | 4458 if (readfile(fname, NULL, |
4459 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, | |
4460 NULL, READ_NEW | READ_DUMMY) == OK | |
857 | 4461 && !got_int |
42 | 4462 && !(curbuf->b_flags & BF_NEW)) |
4463 { | |
4464 failed = FALSE; | |
4465 if (curbuf != newbuf) | |
4466 { | |
2646 | 4467 /* Bloody autocommands changed the buffer! Can happen when |
4468 * using netrw and editing a remote file. Use the current | |
4469 * buffer instead, delete the dummy one after restoring the | |
4470 * window stuff. */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4471 set_bufref(&newbuf_to_wipe, newbuf); |
42 | 4472 newbuf = curbuf; |
4473 } | |
4474 } | |
1918 | 4475 |
4476 /* restore curwin/curbuf and a few other things */ | |
4477 aucmd_restbuf(&aco); | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4478 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
|
4479 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
|
4480 |
c16e207dc465
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents:
9475
diff
changeset
|
4481 /* 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
|
4482 * skip it. */ |
c16e207dc465
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents:
9475
diff
changeset
|
4483 newbuf->b_flags |= BF_DUMMY; |
42 | 4484 } |
4485 | |
3490 | 4486 /* |
4487 * When autocommands/'autochdir' option changed directory: go back. | |
4488 * Let the caller know what the resulting dir was first, in case it is | |
4489 * important. | |
4490 */ | |
4491 mch_dirname(resulting_dir, MAXPATHL); | |
4492 restore_start_dir(dirname_start); | |
4493 | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9485
diff
changeset
|
4494 if (!bufref_valid(&newbufref)) |
42 | 4495 return NULL; |
4496 if (failed) | |
4497 { | |
3490 | 4498 wipe_dummy_buffer(newbuf, dirname_start); |
42 | 4499 return NULL; |
4500 } | |
4501 return newbuf; | |
4502 } | |
4503 | |
4504 /* | |
3490 | 4505 * Wipe out the dummy buffer that load_dummy_buffer() created. Restores |
4506 * directory to "dirname_start" prior to returning, if autocmds or the | |
4507 * 'autochdir' option have changed it. | |
42 | 4508 */ |
4509 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4510 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) |
42 | 4511 { |
4512 if (curbuf != buf) /* safety check */ | |
857 | 4513 { |
4514 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | |
4515 cleanup_T cs; | |
4516 | |
4517 /* Reset the error/interrupt/exception state here so that aborting() | |
4518 * returns FALSE when wiping out the buffer. Otherwise it doesn't | |
4519 * work when got_int is set. */ | |
4520 enter_cleanup(&cs); | |
4521 #endif | |
4522 | |
42 | 4523 wipe_buffer(buf, FALSE); |
857 | 4524 |
4525 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | |
4526 /* Restore the error/interrupt/exception state if not discarded by a | |
4527 * new aborting error, interrupt, or uncaught exception. */ | |
4528 leave_cleanup(&cs); | |
4529 #endif | |
3490 | 4530 /* When autocommands/'autochdir' option changed directory: go back. */ |
4531 restore_start_dir(dirname_start); | |
857 | 4532 } |
42 | 4533 } |
4534 | |
4535 /* | |
3490 | 4536 * Unload the dummy buffer that load_dummy_buffer() created. Restores |
4537 * directory to "dirname_start" prior to returning, if autocmds or the | |
4538 * 'autochdir' option have changed it. | |
42 | 4539 */ |
4540 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4541 unload_dummy_buffer(buf_T *buf, char_u *dirname_start) |
42 | 4542 { |
4543 if (curbuf != buf) /* safety check */ | |
3490 | 4544 { |
3365 | 4545 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE); |
3490 | 4546 |
4547 /* When autocommands/'autochdir' option changed directory: go back. */ | |
4548 restore_start_dir(dirname_start); | |
4549 } | |
42 | 4550 } |
4551 | |
170 | 4552 #if defined(FEAT_EVAL) || defined(PROTO) |
4553 /* | |
4554 * 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
|
4555 * If qf_idx is -1, use the current list. Otherwise, use the specified list. |
170 | 4556 */ |
4557 int | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4558 get_errorlist(win_T *wp, int qf_idx, list_T *list) |
170 | 4559 { |
644 | 4560 qf_info_T *qi = &ql_info; |
230 | 4561 dict_T *dict; |
4562 char_u buf[2]; | |
4563 qfline_T *qfp; | |
4564 int i; | |
1065 | 4565 int bufnum; |
170 | 4566 |
647 | 4567 if (wp != NULL) |
4568 { | |
4569 qi = GET_LOC_LIST(wp); | |
4570 if (qi == NULL) | |
4571 return FAIL; | |
4572 } | |
4573 | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4574 if (qf_idx == -1) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4575 qf_idx = qi->qf_curlist; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4576 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4577 if (qf_idx >= qi->qf_listcount |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4578 || qi->qf_lists[qf_idx].qf_count == 0) |
170 | 4579 return FAIL; |
4580 | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4581 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
|
4582 for (i = 1; !got_int && i <= qi->qf_lists[qf_idx].qf_count; ++i) |
170 | 4583 { |
1065 | 4584 /* Handle entries with a non-existing buffer number. */ |
4585 bufnum = qfp->qf_fnum; | |
4586 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
4587 bufnum = 0; | |
4588 | |
170 | 4589 if ((dict = dict_alloc()) == NULL) |
4590 return FAIL; | |
4591 if (list_append_dict(list, dict) == FAIL) | |
4592 return FAIL; | |
4593 | |
4594 buf[0] = qfp->qf_type; | |
4595 buf[1] = NUL; | |
1065 | 4596 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL |
170 | 4597 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL |
4598 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL | |
4599 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL | |
4600 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL | |
960 | 4601 || dict_add_nr_str(dict, "pattern", 0L, |
4602 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL | |
4603 || dict_add_nr_str(dict, "text", 0L, | |
4604 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL | |
170 | 4605 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL |
4606 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL) | |
4607 return FAIL; | |
4608 | |
4609 qfp = qfp->qf_next; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4610 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4611 break; |
170 | 4612 } |
4613 return OK; | |
4614 } | |
230 | 4615 |
4616 /* | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4617 * 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
|
4618 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4619 enum { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4620 QF_GETLIST_NONE = 0x0, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4621 QF_GETLIST_TITLE = 0x1, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4622 QF_GETLIST_ITEMS = 0x2, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4623 QF_GETLIST_NR = 0x4, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4624 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
|
4625 QF_GETLIST_CONTEXT = 0x10, |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4626 QF_GETLIST_ALL = 0xFF |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4627 }; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4628 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4629 /* |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4630 * 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
|
4631 * 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
|
4632 * then current list is used. Otherwise the specified list is used. |
230 | 4633 */ |
4634 int | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4635 get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4636 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4637 qf_info_T *qi = &ql_info; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4638 int status = OK; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4639 int qf_idx; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4640 dictitem_T *di; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4641 int flags = QF_GETLIST_NONE; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4642 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4643 if (wp != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4644 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4645 qi = GET_LOC_LIST(wp); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4646 if (qi == NULL) |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4647 { |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4648 /* If querying for the size of the location list, return 0 */ |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4649 if (((di = dict_find(what, (char_u *)"nr", -1)) != NULL) && |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4650 (di->di_tv.v_type == VAR_STRING) && |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4651 (STRCMP(di->di_tv.vval.v_string, "$") == 0)) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4652 return dict_add_nr_str(retdict, "nr", 0, NULL); |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4653 return FAIL; |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4654 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4655 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4656 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4657 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
|
4658 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
|
4659 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4660 /* Use the specified quickfix/location list */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4661 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
|
4662 { |
10237
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4663 /* for zero use the current list */ |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4664 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
|
4665 { |
197795e3530d
commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents:
10226
diff
changeset
|
4666 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
|
4667 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
|
4668 return FAIL; |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4669 } else if (qi->qf_listcount == 0) /* stack is empty */ |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4670 return FAIL; |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4671 flags |= QF_GETLIST_NR; |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4672 } else if ((di->di_tv.v_type == VAR_STRING) && |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4673 (STRCMP(di->di_tv.vval.v_string, "$") == 0)) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4674 { |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4675 /* Get the last quickfix list number */ |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4676 if (qi->qf_listcount > 0) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4677 qf_idx = qi->qf_listcount - 1; |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4678 else |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4679 qf_idx = -1; /* Quickfix stack is empty */ |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4680 flags |= QF_GETLIST_NR; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4681 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4682 else |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4683 return FAIL; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4684 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4685 |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4686 if (qf_idx != -1) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4687 { |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4688 if (dict_find(what, (char_u *)"all", -1) != NULL) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4689 flags |= QF_GETLIST_ALL; |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4690 |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4691 if (dict_find(what, (char_u *)"title", -1) != NULL) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4692 flags |= QF_GETLIST_TITLE; |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4693 |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4694 if (dict_find(what, (char_u *)"winid", -1) != NULL) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4695 flags |= QF_GETLIST_WINID; |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4696 |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4697 if (dict_find(what, (char_u *)"context", -1) != NULL) |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4698 flags |= QF_GETLIST_CONTEXT; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4699 |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4700 if (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
|
4701 flags |= QF_GETLIST_ITEMS; |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4702 } |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4703 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4704 if (flags & QF_GETLIST_TITLE) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4705 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4706 char_u *t; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4707 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
|
4708 if (t == NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4709 t = (char_u *)""; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4710 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
|
4711 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4712 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
|
4713 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
|
4714 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
|
4715 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4716 win_T *win; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4717 win = qf_find_win(qi); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4718 if (win != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4719 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
|
4720 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4721 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
|
4722 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4723 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
|
4724 if (l != NULL) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4725 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4726 (void)get_errorlist(wp, qf_idx, l); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4727 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
|
4728 } |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4729 else |
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4730 status = FAIL; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4731 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4732 |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4733 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
|
4734 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4735 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
|
4736 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4737 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
|
4738 if (di != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4739 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4740 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
|
4741 status = dict_add(retdict, di); |
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4742 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
|
4743 dictitem_free(di); |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4744 } |
11609
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4745 else |
6f11697fb92c
patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents:
11589
diff
changeset
|
4746 status = FAIL; |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4747 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4748 else |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4749 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
|
4750 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4751 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4752 return status; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4753 } |
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 /* |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4756 * 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
|
4757 * a dictionary with item information. |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4758 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4759 static int |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4760 qf_add_entries( |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4761 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
|
4762 int qf_idx, |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4763 list_T *list, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4764 char_u *title, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4765 int action) |
230 | 4766 { |
4767 listitem_T *li; | |
4768 dict_T *d; | |
4769 char_u *filename, *pattern, *text, *type; | |
1065 | 4770 int bufnum; |
230 | 4771 long lnum; |
4772 int col, nr; | |
4773 int vcol; | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4774 #ifdef FEAT_WINDOWS |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4775 qfline_T *old_last = NULL; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4776 #endif |
230 | 4777 int valid, status; |
4778 int retval = OK; | |
1065 | 4779 int did_bufnr_emsg = FALSE; |
644 | 4780 |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
4781 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
|
4782 { |
277 | 4783 /* make place for a new list */ |
3965 | 4784 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
|
4785 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
|
4786 } |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4787 #ifdef FEAT_WINDOWS |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
4788 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
|
4789 /* 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
|
4790 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
|
4791 #endif |
277 | 4792 else if (action == 'r') |
6079 | 4793 { |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4794 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
|
4795 qf_store_title(qi, qf_idx, title); |
6079 | 4796 } |
230 | 4797 |
4798 for (li = list->lv_first; li != NULL; li = li->li_next) | |
4799 { | |
4800 if (li->li_tv.v_type != VAR_DICT) | |
4801 continue; /* Skip non-dict items */ | |
4802 | |
4803 d = li->li_tv.vval.v_dict; | |
4804 if (d == NULL) | |
4805 continue; | |
4806 | |
659 | 4807 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
|
4808 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
|
4809 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
|
4810 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
|
4811 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
|
4812 nr = (int)get_dict_number(d, (char_u *)"nr"); |
659 | 4813 type = get_dict_string(d, (char_u *)"type", TRUE); |
4814 pattern = get_dict_string(d, (char_u *)"pattern", TRUE); | |
4815 text = get_dict_string(d, (char_u *)"text", TRUE); | |
230 | 4816 if (text == NULL) |
4817 text = vim_strsave((char_u *)""); | |
4818 | |
4819 valid = TRUE; | |
1065 | 4820 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL)) |
230 | 4821 valid = FALSE; |
4822 | |
1065 | 4823 /* Mark entries with non-existing buffer number as not valid. Give the |
4824 * error message only once. */ | |
4825 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
4826 { | |
4827 if (!did_bufnr_emsg) | |
4828 { | |
4829 did_bufnr_emsg = TRUE; | |
4830 EMSGN(_("E92: Buffer %ld not found"), bufnum); | |
4831 } | |
4832 valid = FALSE; | |
4833 bufnum = 0; | |
4834 } | |
4835 | |
11390
73cfcf11d983
patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents:
11378
diff
changeset
|
4836 /* 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
|
4837 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
|
4838 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
|
4839 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4840 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
|
4841 qf_idx, |
230 | 4842 NULL, /* dir */ |
4843 filename, | |
1065 | 4844 bufnum, |
230 | 4845 text, |
4846 lnum, | |
4847 col, | |
4848 vcol, /* vis_col */ | |
4849 pattern, /* search pattern */ | |
4850 nr, | |
4851 type == NULL ? NUL : *type, | |
4852 valid); | |
4853 | |
4854 vim_free(filename); | |
4855 vim_free(pattern); | |
4856 vim_free(text); | |
4857 vim_free(type); | |
4858 | |
4859 if (status == FAIL) | |
4860 { | |
4861 retval = FAIL; | |
4862 break; | |
4863 } | |
4864 } | |
4865 | |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
4866 if (qi->qf_lists[qf_idx].qf_index == 0) |
2795 | 4867 /* 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
|
4868 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
|
4869 else |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
4870 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
|
4871 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
|
4872 { |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
4873 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
|
4874 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
|
4875 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
|
4876 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
|
4877 } |
230 | 4878 |
4879 #ifdef FEAT_WINDOWS | |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4880 /* 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
|
4881 qf_update_buffer(qi, old_last); |
230 | 4882 #endif |
4883 | |
4884 return retval; | |
4885 } | |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4886 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4887 static int |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4888 qf_set_properties(qf_info_T *qi, dict_T *what, int action) |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4889 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4890 dictitem_T *di; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4891 int retval = FAIL; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4892 int qf_idx; |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4893 int newlist = FALSE; |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4894 |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4895 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
|
4896 newlist = TRUE; |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4897 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4898 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
|
4899 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
|
4900 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4901 /* Use the specified quickfix/location list */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4902 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
|
4903 { |
11445
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
4904 /* 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
|
4905 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
|
4906 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
|
4907 |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4908 if ((action == ' ' || action == 'a') && |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4909 qf_idx == qi->qf_listcount) |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4910 /* |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4911 * When creating a new list, accept qf_idx pointing to the next |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4912 * non-available list |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4913 */ |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4914 newlist = TRUE; |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4915 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
|
4916 return FAIL; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4917 else |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4918 newlist = FALSE; /* use the specified list */ |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4919 } else if (di->di_tv.v_type == VAR_STRING && |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4920 STRCMP(di->di_tv.vval.v_string, "$") == 0 && |
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4921 qi->qf_listcount > 0) |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4922 { |
11502
46bbef0ee9a6
patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11449
diff
changeset
|
4923 qf_idx = qi->qf_listcount - 1; |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4924 newlist = FALSE; |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4925 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4926 else |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4927 return FAIL; |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4928 } |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4929 |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4930 if (newlist) |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4931 { |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4932 qf_new_list(qi, NULL); |
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
4933 qf_idx = qi->qf_curlist; |
9850
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 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4936 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
|
4937 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4938 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
|
4939 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4940 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
|
4941 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
|
4942 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
|
4943 if (qf_idx == qi->qf_curlist) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4944 qf_update_win_titlevar(qi); |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4945 retval = OK; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4946 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4947 } |
11549
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4948 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
|
4949 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4950 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
|
4951 { |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4952 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
|
4953 |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4954 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
|
4955 title_save, action == ' ' ? 'a' : action); |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4956 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
|
4957 } |
f5add45f9848
patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4958 } |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4959 |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4960 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
|
4961 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4962 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
|
4963 |
11445
461ac47c3793
patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11443
diff
changeset
|
4964 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
|
4965 ctx = alloc_tv(); |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4966 if (ctx != NULL) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
4967 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
|
4968 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
|
4969 retval = OK; |
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 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4972 return retval; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4973 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
4974 |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4975 /* |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4976 * 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
|
4977 */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4978 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
|
4979 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
|
4980 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4981 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
|
4982 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4983 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
|
4984 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
|
4985 return wp; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4986 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4987 return NULL; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4988 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4989 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4990 /* |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4991 * 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
|
4992 * 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
|
4993 */ |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
4994 static void |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
4995 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
|
4996 { |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
4997 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
|
4998 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
|
4999 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
|
5000 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5001 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
|
5002 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5003 /* 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
|
5004 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
|
5005 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
|
5006 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
|
5007 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5008 |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5009 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
|
5010 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5011 /* 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
|
5012 * 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
|
5013 */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5014 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
|
5015 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
|
5016 wp = llwin; |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5017 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5018 |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5019 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
|
5020 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
|
5021 { |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5022 /* quickfix list */ |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5023 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
|
5024 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
|
5025 } |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5026 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
|
5027 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5028 /* 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
|
5029 * location list */ |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5030 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
|
5031 |
11398
30af33f4d353
patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents:
11390
diff
changeset
|
5032 /* 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
|
5033 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
|
5034 |
11301
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5035 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
|
5036 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
|
5037 { |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5038 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
|
5039 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
|
5040 } |
cc8ece2aa389
patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents:
11263
diff
changeset
|
5041 } |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5042 } |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5043 |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5044 /* |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5045 * 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
|
5046 * 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
|
5047 * "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
|
5048 */ |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5049 int |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5050 set_errorlist( |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5051 win_T *wp, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5052 list_T *list, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5053 int action, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5054 char_u *title, |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5055 dict_T *what) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5056 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5057 qf_info_T *qi = &ql_info; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5058 int retval = OK; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5059 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5060 if (wp != NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5061 { |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5062 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
|
5063 if (qi == NULL) |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5064 return FAIL; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5065 } |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5066 |
11263
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5067 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
|
5068 { |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5069 /* 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
|
5070 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
|
5071 } |
ae5f9f26f81c
patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents:
11195
diff
changeset
|
5072 else if (what != NULL) |
9982
e24aa20d815c
commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents:
9931
diff
changeset
|
5073 retval = qf_set_properties(qi, what, action); |
9850
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5074 else |
11449
d2f00eb352b9
patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents:
11447
diff
changeset
|
5075 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
|
5076 |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5077 return retval; |
67781bb0a61a
commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents:
9738
diff
changeset
|
5078 } |
11412
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5079 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5080 static int |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5081 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
|
5082 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5083 int i; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5084 int abort = FALSE; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5085 typval_T *ctx; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5086 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5087 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
|
5088 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5089 ctx = qi->qf_lists[i].qf_ctx; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5090 if (ctx != NULL && ctx->v_type != VAR_NUMBER && |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5091 ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5092 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
|
5093 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5094 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5095 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5096 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5097 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5098 /* |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5099 * 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
|
5100 * "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
|
5101 */ |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5102 int |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5103 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
|
5104 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5105 int abort = FALSE; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5106 tabpage_T *tp; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5107 win_T *win; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5108 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5109 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
|
5110 if (abort) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5111 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5112 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5113 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
|
5114 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5115 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
|
5116 { |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5117 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
|
5118 if (abort) |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5119 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5120 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5121 } |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5122 |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5123 return abort; |
84baca75b7f2
patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents:
11398
diff
changeset
|
5124 } |
170 | 5125 #endif |
5126 | |
42 | 5127 /* |
41 | 5128 * ":[range]cbuffer [bufnr]" command. |
657 | 5129 * ":[range]caddbuffer [bufnr]" command. |
798 | 5130 * ":[range]cgetbuffer [bufnr]" command. |
644 | 5131 * ":[range]lbuffer [bufnr]" command. |
657 | 5132 * ":[range]laddbuffer [bufnr]" command. |
798 | 5133 * ":[range]lgetbuffer [bufnr]" command. |
41 | 5134 */ |
5135 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5136 ex_cbuffer(exarg_T *eap) |
41 | 5137 { |
5138 buf_T *buf = NULL; | |
644 | 5139 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
|
5140 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5141 char_u *au_name = NULL; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5142 #endif |
644 | 5143 |
798 | 5144 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer |
5145 || eap->cmdidx == CMD_laddbuffer) | |
644 | 5146 { |
5147 qi = ll_get_or_alloc_list(curwin); | |
5148 if (qi == NULL) | |
5149 return; | |
5150 } | |
41 | 5151 |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5152 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5153 switch (eap->cmdidx) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5154 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5155 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
|
5156 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
|
5157 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
|
5158 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
|
5159 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
|
5160 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
|
5161 default: break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5162 } |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5163 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
|
5164 curbuf->b_fname, TRUE, curbuf)) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5165 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5166 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5167 if (aborting()) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5168 return; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5169 # endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5170 } |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5171 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5172 |
41 | 5173 if (*eap->arg == NUL) |
5174 buf = curbuf; | |
5175 else if (*skipwhite(skipdigits(eap->arg)) == NUL) | |
5176 buf = buflist_findnr(atoi((char *)eap->arg)); | |
5177 if (buf == NULL) | |
5178 EMSG(_(e_invarg)); | |
5179 else if (buf->b_ml.ml_mfp == NULL) | |
5180 EMSG(_("E681: Buffer is not loaded")); | |
5181 else | |
5182 { | |
5183 if (eap->addr_count == 0) | |
5184 { | |
5185 eap->line1 = 1; | |
5186 eap->line2 = buf->b_ml.ml_line_count; | |
5187 } | |
5188 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count | |
5189 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) | |
5190 EMSG(_(e_invrange)); | |
5191 else | |
661 | 5192 { |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5193 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
|
5194 |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5195 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
|
5196 { |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5197 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
|
5198 (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
|
5199 qf_title = IObuff; |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5200 } |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
5201 |
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
|
5202 if (qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm, |
798 | 5203 (eap->cmdidx != CMD_caddbuffer |
5204 && 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
|
5205 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
|
5206 qf_title, NULL) > 0) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5207 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5208 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5209 if (au_name != NULL) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5210 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5211 curbuf->b_fname, TRUE, curbuf); |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5212 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5213 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
|
5214 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
|
5215 } |
661 | 5216 } |
41 | 5217 } |
5218 } | |
5219 | |
532 | 5220 #if defined(FEAT_EVAL) || defined(PROTO) |
41 | 5221 /* |
798 | 5222 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command. |
5223 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command. | |
446 | 5224 */ |
5225 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5226 ex_cexpr(exarg_T *eap) |
446 | 5227 { |
5228 typval_T *tv; | |
644 | 5229 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
|
5230 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5231 char_u *au_name = NULL; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5232 #endif |
644 | 5233 |
798 | 5234 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr |
5235 || eap->cmdidx == CMD_laddexpr) | |
644 | 5236 { |
5237 qi = ll_get_or_alloc_list(curwin); | |
5238 if (qi == NULL) | |
5239 return; | |
5240 } | |
446 | 5241 |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5242 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5243 switch (eap->cmdidx) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5244 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5245 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
|
5246 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
|
5247 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
|
5248 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
|
5249 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
|
5250 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
|
5251 default: break; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5252 } |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5253 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
|
5254 curbuf->b_fname, TRUE, curbuf)) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5255 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5256 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5257 if (aborting()) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5258 return; |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5259 # endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5260 } |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5261 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5262 |
625 | 5263 /* Evaluate the expression. When the result is a string or a list we can |
5264 * use it to fill the errorlist. */ | |
446 | 5265 tv = eval_expr(eap->arg, NULL); |
625 | 5266 if (tv != NULL) |
5267 { | |
5268 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL) | |
5269 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) | |
5270 { | |
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
|
5271 if (qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, |
798 | 5272 (eap->cmdidx != CMD_caddexpr |
5273 && 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
|
5274 (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
|
5275 NULL) > 0) |
10056
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5276 { |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5277 #ifdef FEAT_AUTOCMD |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5278 if (au_name != NULL) |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5279 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5280 curbuf->b_fname, TRUE, curbuf); |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5281 #endif |
21f685af3fc1
commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
5282 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
|
5283 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
|
5284 } |
625 | 5285 } |
5286 else | |
626 | 5287 EMSG(_("E777: String or List expected")); |
625 | 5288 free_tv(tv); |
5289 } | |
446 | 5290 } |
532 | 5291 #endif |
446 | 5292 |
5293 /* | |
7 | 5294 * ":helpgrep {pattern}" |
5295 */ | |
5296 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5297 ex_helpgrep(exarg_T *eap) |
7 | 5298 { |
5299 regmatch_T regmatch; | |
5300 char_u *save_cpo; | |
5301 char_u *p; | |
5302 int fcount; | |
5303 char_u **fnames; | |
5304 FILE *fd; | |
5305 int fi; | |
5306 long lnum; | |
9 | 5307 #ifdef FEAT_MULTI_LANG |
5308 char_u *lang; | |
5309 #endif | |
644 | 5310 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
|
5311 qf_info_T *save_qi; |
659 | 5312 int new_qi = FALSE; |
5313 win_T *wp; | |
3269 | 5314 #ifdef FEAT_AUTOCMD |
5315 char_u *au_name = NULL; | |
5316 #endif | |
7 | 5317 |
9 | 5318 #ifdef FEAT_MULTI_LANG |
5319 /* Check for a specified language */ | |
5320 lang = check_help_lang(eap->arg); | |
5321 #endif | |
5322 | |
3269 | 5323 #ifdef FEAT_AUTOCMD |
5324 switch (eap->cmdidx) | |
5325 { | |
5326 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break; | |
5327 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break; | |
5328 default: break; | |
5329 } | |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5330 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
|
5331 curbuf->b_fname, TRUE, curbuf)) |
3269 | 5332 { |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5333 # ifdef FEAT_EVAL |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5334 if (aborting()) |
3269 | 5335 return; |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10281
diff
changeset
|
5336 # endif |
3269 | 5337 } |
5338 #endif | |
5339 | |
5340 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ | |
5341 save_cpo = p_cpo; | |
5342 p_cpo = empty_option; | |
5343 | |
659 | 5344 if (eap->cmdidx == CMD_lhelpgrep) |
5345 { | |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5346 /* 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
|
5347 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
|
5348 wp = curwin; |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5349 else |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5350 /* 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
|
5351 FOR_ALL_WINDOWS(wp) |
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11788
diff
changeset
|
5352 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
|
5353 break; |
659 | 5354 |
5355 if (wp == NULL) /* Help window not found */ | |
5356 qi = NULL; | |
5357 else | |
5358 qi = wp->w_llist; | |
5359 | |
5360 if (qi == NULL) | |
5361 { | |
5362 /* Allocate a new location list for help text matches */ | |
5363 if ((qi = ll_new_list()) == NULL) | |
5364 return; | |
5365 new_qi = TRUE; | |
5366 } | |
5367 } | |
5368 | |
11195
13c660bd07b2
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
5369 /* 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
|
5370 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
|
5371 |
7 | 5372 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); |
5373 regmatch.rm_ic = FALSE; | |
5374 if (regmatch.regprog != NULL) | |
5375 { | |
3257 | 5376 #ifdef FEAT_MBYTE |
5377 vimconv_T vc; | |
5378 | |
5379 /* Help files are in utf-8 or latin1, convert lines when 'encoding' | |
5380 * differs. */ | |
5381 vc.vc_type = CONV_NONE; | |
5382 if (!enc_utf8) | |
5383 convert_setup(&vc, (char_u *)"utf-8", p_enc); | |
5384 #endif | |
5385 | |
7 | 5386 /* create a new quickfix list */ |
3965 | 5387 qf_new_list(qi, *eap->cmdlinep); |
7 | 5388 |
5389 /* Go through all directories in 'runtimepath' */ | |
5390 p = p_rtp; | |
5391 while (*p != NUL && !got_int) | |
5392 { | |
5393 copy_option_part(&p, NameBuff, MAXPATHL, ","); | |
5394 | |
5395 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */ | |
5396 add_pathsep(NameBuff); | |
5397 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)"); | |
5398 if (gen_expand_wildcards(1, &NameBuff, &fcount, | |
5399 &fnames, EW_FILE|EW_SILENT) == OK | |
5400 && fcount > 0) | |
5401 { | |
5402 for (fi = 0; fi < fcount && !got_int; ++fi) | |
5403 { | |
9 | 5404 #ifdef FEAT_MULTI_LANG |
5405 /* Skip files for a different language. */ | |
5406 if (lang != NULL | |
5407 && STRNICMP(lang, fnames[fi] | |
5408 + STRLEN(fnames[fi]) - 3, 2) != 0 | |
5409 && !(STRNICMP(lang, "en", 2) == 0 | |
5410 && STRNICMP("txt", fnames[fi] | |
5411 + STRLEN(fnames[fi]) - 3, 3) == 0)) | |
5412 continue; | |
5413 #endif | |
531 | 5414 fd = mch_fopen((char *)fnames[fi], "r"); |
7 | 5415 if (fd != NULL) |
5416 { | |
5417 lnum = 1; | |
5418 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) | |
5419 { | |
3257 | 5420 char_u *line = IObuff; |
5421 #ifdef FEAT_MBYTE | |
5422 /* Convert a line if 'encoding' is not utf-8 and | |
5423 * the line contains a non-ASCII character. */ | |
5424 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
|
5425 && 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
|
5426 { |
3257 | 5427 line = string_convert(&vc, IObuff, NULL); |
5428 if (line == NULL) | |
5429 line = IObuff; | |
5430 } | |
5431 #endif | |
5432 | |
5433 if (vim_regexec(®match, line, (colnr_T)0)) | |
7 | 5434 { |
3257 | 5435 int l = (int)STRLEN(line); |
7 | 5436 |
5437 /* remove trailing CR, LF, spaces, etc. */ | |
3257 | 5438 while (l > 0 && line[l - 1] <= ' ') |
5439 line[--l] = NUL; | |
7 | 5440 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
5441 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
|
5442 qi->qf_curlist, |
7 | 5443 NULL, /* dir */ |
5444 fnames[fi], | |
1065 | 5445 0, |
3257 | 5446 line, |
7 | 5447 lnum, |
3257 | 5448 (int)(regmatch.startp[0] - line) |
42 | 5449 + 1, /* col */ |
170 | 5450 FALSE, /* vis_col */ |
230 | 5451 NULL, /* search pattern */ |
7 | 5452 0, /* nr */ |
5453 1, /* type */ | |
5454 TRUE /* valid */ | |
5455 ) == FAIL) | |
5456 { | |
5457 got_int = TRUE; | |
3257 | 5458 #ifdef FEAT_MBYTE |
5459 if (line != IObuff) | |
5460 vim_free(line); | |
5461 #endif | |
7 | 5462 break; |
5463 } | |
5464 } | |
3257 | 5465 #ifdef FEAT_MBYTE |
5466 if (line != IObuff) | |
5467 vim_free(line); | |
5468 #endif | |
7 | 5469 ++lnum; |
5470 line_breakcheck(); | |
5471 } | |
5472 fclose(fd); | |
5473 } | |
5474 } | |
5475 FreeWild(fcount, fnames); | |
5476 } | |
5477 } | |
3257 | 5478 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4371
diff
changeset
|
5479 vim_regfree(regmatch.regprog); |
3257 | 5480 #ifdef FEAT_MBYTE |
5481 if (vc.vc_type != CONV_NONE) | |
5482 convert_setup(&vc, NULL, NULL); | |
5483 #endif | |
7 | 5484 |
644 | 5485 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
5486 qi->qf_lists[qi->qf_curlist].qf_ptr = | |
5487 qi->qf_lists[qi->qf_curlist].qf_start; | |
5488 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
7 | 5489 } |
5490 | |
1672 | 5491 if (p_cpo == empty_option) |
5492 p_cpo = save_cpo; | |
5493 else | |
5494 /* Darn, some plugin changed the value. */ | |
5495 free_string_option(save_cpo); | |
7 | 5496 |
5497 #ifdef FEAT_WINDOWS | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
5498 qf_update_buffer(qi, NULL); |
7 | 5499 #endif |
5500 | |
3269 | 5501 #ifdef FEAT_AUTOCMD |
5502 if (au_name != NULL) | |
5503 { | |
5504 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | |
5505 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
|
5506 if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL) |
3269 | 5507 /* autocommands made "qi" invalid */ |
5508 return; | |
5509 } | |
5510 #endif | |
5511 | |
7 | 5512 /* Jump to first match. */ |
644 | 5513 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
659 | 5514 qf_jump(qi, 0, 0, FALSE); |
9 | 5515 else |
5516 EMSG2(_(e_nomatch2), eap->arg); | |
659 | 5517 |
5518 if (eap->cmdidx == CMD_lhelpgrep) | |
5519 { | |
5520 /* If the help window is not opened or if it already points to the | |
661 | 5521 * 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
|
5522 if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi) |
659 | 5523 { |
5524 if (new_qi) | |
5525 ll_free_all(&qi); | |
5526 } | |
5527 else if (curwin->w_llist == NULL) | |
5528 curwin->w_llist = qi; | |
5529 } | |
7 | 5530 } |
5531 | |
5532 #endif /* FEAT_QUICKFIX */ |