]>
Commit | Line | Data |
---|---|---|
9b1d76b7 AG |
1 | To: vim-dev@vim.org |
2 | Subject: patch 7.0.191 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.0.191 | |
11 | Problem: The items used by getqflist() and setqflist() don't match. | |
12 | Solution: Support the "bufnum" item for setqflist(). (Yegappan Lakshmanan) | |
13 | Files: runtime/doc/eval.txt, src/quickfix.c | |
14 | ||
15 | ||
16 | *** ../vim-7.0.190/runtime/doc/eval.txt Wed Nov 1 15:31:02 2006 | |
17 | --- runtime/doc/eval.txt Sun Feb 4 01:54:35 2007 | |
18 | *************** | |
19 | *** 2897,2908 **** | |
20 | vcol non-zero: "col" is visual column | |
21 | zero: "col" is byte index | |
22 | nr error number | |
23 | text description of the error | |
24 | type type of the error, 'E', '1', etc. | |
25 | valid non-zero: recognized error message | |
26 | ||
27 | When there is no error list or it's empty an empty list is | |
28 | ! returned. | |
29 | ||
30 | Useful application: Find pattern matches in multiple files and | |
31 | do something with them: > | |
32 | --- 2912,2925 ---- | |
33 | vcol non-zero: "col" is visual column | |
34 | zero: "col" is byte index | |
35 | nr error number | |
36 | + pattern search pattern used to locate the error | |
37 | text description of the error | |
38 | type type of the error, 'E', '1', etc. | |
39 | valid non-zero: recognized error message | |
40 | ||
41 | When there is no error list or it's empty an empty list is | |
42 | ! returned. Quickfix list entries with non-existing buffer | |
43 | ! number are returned with "bufnr" set to zero. | |
44 | ||
45 | Useful application: Find pattern matches in multiple files and | |
46 | do something with them: > | |
47 | *************** | |
48 | *** 4371,4377 **** | |
49 | Non-dictionary items in {list} are ignored. Each dictionary | |
50 | item can contain the following entries: | |
51 | ||
52 | ! filename name of a file | |
53 | lnum line number in the file | |
54 | pattern search pattern used to locate the error | |
55 | col column number | |
56 | --- 4401,4410 ---- | |
57 | Non-dictionary items in {list} are ignored. Each dictionary | |
58 | item can contain the following entries: | |
59 | ||
60 | ! bufnr buffer number; must be the number of a valid | |
61 | ! buffer | |
62 | ! filename name of a file; only used when "bufnr" is not | |
63 | ! present or it is invalid. | |
64 | lnum line number in the file | |
65 | pattern search pattern used to locate the error | |
66 | col column number | |
67 | *************** | |
68 | *** 4384,4394 **** | |
69 | The "col", "vcol", "nr", "type" and "text" entries are | |
70 | optional. Either "lnum" or "pattern" entry can be used to | |
71 | locate a matching error line. | |
72 | ! If the "filename" entry is not present or neither the "lnum" | |
73 | ! or "pattern" entries are present, then the item will not be | |
74 | ! handled as an error line. | |
75 | If both "pattern" and "lnum" are present then "pattern" will | |
76 | be used. | |
77 | ||
78 | If {action} is set to 'a', then the items from {list} are | |
79 | added to the existing quickfix list. If there is no existing | |
80 | --- 4417,4429 ---- | |
81 | The "col", "vcol", "nr", "type" and "text" entries are | |
82 | optional. Either "lnum" or "pattern" entry can be used to | |
83 | locate a matching error line. | |
84 | ! If the "filename" and "bufnr" entries are not present or | |
85 | ! neither the "lnum" or "pattern" entries are present, then the | |
86 | ! item will not be handled as an error line. | |
87 | If both "pattern" and "lnum" are present then "pattern" will | |
88 | be used. | |
89 | + Note that the list is not exactly the same as what | |
90 | + |getqflist()| returns. | |
91 | ||
92 | If {action} is set to 'a', then the items from {list} are | |
93 | added to the existing quickfix list. If there is no existing | |
94 | *** ../vim-7.0.190/src/quickfix.c Fri Oct 20 20:15:05 2006 | |
95 | --- src/quickfix.c Sun Feb 4 01:50:17 2007 | |
96 | *************** | |
97 | *** 106,112 **** | |
98 | ||
99 | static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast)); | |
100 | static void qf_new_list __ARGS((qf_info_T *qi)); | |
101 | ! static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid)); | |
102 | static void qf_msg __ARGS((qf_info_T *qi)); | |
103 | static void qf_free __ARGS((qf_info_T *qi, int idx)); | |
104 | static char_u *qf_types __ARGS((int, int)); | |
105 | --- 106,112 ---- | |
106 | ||
107 | static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast)); | |
108 | static void qf_new_list __ARGS((qf_info_T *qi)); | |
109 | ! static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, 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)); | |
110 | static void qf_msg __ARGS((qf_info_T *qi)); | |
111 | static void qf_free __ARGS((qf_info_T *qi, int idx)); | |
112 | static char_u *qf_types __ARGS((int, int)); | |
113 | *************** | |
114 | *** 791,796 **** | |
115 | --- 791,797 ---- | |
116 | (*namebuf || directory) | |
117 | ? namebuf | |
118 | : ((currfile && valid) ? currfile : (char_u *)NULL), | |
119 | + 0, | |
120 | errmsg, | |
121 | lnum, | |
122 | col, | |
123 | *************** | |
124 | *** 936,947 **** | |
125 | * Returns OK or FAIL. | |
126 | */ | |
127 | static int | |
128 | ! qf_add_entry(qi, prevp, dir, fname, mesg, lnum, col, vis_col, pattern, nr, type, | |
129 | ! valid) | |
130 | qf_info_T *qi; /* quickfix list */ | |
131 | qfline_T **prevp; /* pointer to previously added entry or NULL */ | |
132 | char_u *dir; /* optional directory name */ | |
133 | char_u *fname; /* file name or NULL */ | |
134 | char_u *mesg; /* message */ | |
135 | long lnum; /* line number */ | |
136 | int col; /* column */ | |
137 | --- 937,949 ---- | |
138 | * Returns OK or FAIL. | |
139 | */ | |
140 | static int | |
141 | ! qf_add_entry(qi, prevp, dir, fname, bufnum, mesg, lnum, col, vis_col, pattern, | |
142 | ! nr, type, valid) | |
143 | qf_info_T *qi; /* quickfix list */ | |
144 | qfline_T **prevp; /* pointer to previously added entry or NULL */ | |
145 | char_u *dir; /* optional directory name */ | |
146 | char_u *fname; /* file name or NULL */ | |
147 | + int bufnum; /* buffer number or zero */ | |
148 | char_u *mesg; /* message */ | |
149 | long lnum; /* line number */ | |
150 | int col; /* column */ | |
151 | *************** | |
152 | *** 955,961 **** | |
153 | ||
154 | if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) | |
155 | return FAIL; | |
156 | ! qfp->qf_fnum = qf_get_fnum(dir, fname); | |
157 | if ((qfp->qf_text = vim_strsave(mesg)) == NULL) | |
158 | { | |
159 | vim_free(qfp); | |
160 | --- 957,966 ---- | |
161 | ||
162 | if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) | |
163 | return FAIL; | |
164 | ! if (bufnum != 0) | |
165 | ! qfp->qf_fnum = bufnum; | |
166 | ! else | |
167 | ! qfp->qf_fnum = qf_get_fnum(dir, fname); | |
168 | if ((qfp->qf_text = vim_strsave(mesg)) == NULL) | |
169 | { | |
170 | vim_free(qfp); | |
171 | *************** | |
172 | *** 1106,1111 **** | |
173 | --- 1111,1117 ---- | |
174 | if (qf_add_entry(to->w_llist, &prevp, | |
175 | NULL, | |
176 | NULL, | |
177 | + 0, | |
178 | from_qfp->qf_text, | |
179 | from_qfp->qf_lnum, | |
180 | from_qfp->qf_col, | |
181 | *************** | |
182 | *** 3134,3139 **** | |
183 | --- 3140,3146 ---- | |
184 | if (qf_add_entry(qi, &prevp, | |
185 | NULL, /* dir */ | |
186 | fnames[fi], | |
187 | + 0, | |
188 | ml_get_buf(buf, | |
189 | regmatch.startpos[0].lnum + lnum, FALSE), | |
190 | regmatch.startpos[0].lnum + lnum, | |
191 | *************** | |
192 | *** 3419,3424 **** | |
193 | --- 3426,3432 ---- | |
194 | char_u buf[2]; | |
195 | qfline_T *qfp; | |
196 | int i; | |
197 | + int bufnum; | |
198 | ||
199 | if (wp != NULL) | |
200 | { | |
201 | *************** | |
202 | *** 3434,3439 **** | |
203 | --- 3442,3452 ---- | |
204 | qfp = qi->qf_lists[qi->qf_curlist].qf_start; | |
205 | for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i) | |
206 | { | |
207 | + /* Handle entries with a non-existing buffer number. */ | |
208 | + bufnum = qfp->qf_fnum; | |
209 | + if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
210 | + bufnum = 0; | |
211 | + | |
212 | if ((dict = dict_alloc()) == NULL) | |
213 | return FAIL; | |
214 | if (list_append_dict(list, dict) == FAIL) | |
215 | *************** | |
216 | *** 3441,3447 **** | |
217 | ||
218 | buf[0] = qfp->qf_type; | |
219 | buf[1] = NUL; | |
220 | ! if ( dict_add_nr_str(dict, "bufnr", (long)qfp->qf_fnum, NULL) == FAIL | |
221 | || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL | |
222 | || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL | |
223 | || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL | |
224 | --- 3454,3460 ---- | |
225 | ||
226 | buf[0] = qfp->qf_type; | |
227 | buf[1] = NUL; | |
228 | ! if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL | |
229 | || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL | |
230 | || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL | |
231 | || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL | |
232 | *************** | |
233 | *** 3472,3477 **** | |
234 | --- 3485,3491 ---- | |
235 | listitem_T *li; | |
236 | dict_T *d; | |
237 | char_u *filename, *pattern, *text, *type; | |
238 | + int bufnum; | |
239 | long lnum; | |
240 | int col, nr; | |
241 | int vcol; | |
242 | *************** | |
243 | *** 3479,3484 **** | |
244 | --- 3493,3499 ---- | |
245 | int valid, status; | |
246 | int retval = OK; | |
247 | qf_info_T *qi = &ql_info; | |
248 | + int did_bufnr_emsg = FALSE; | |
249 | ||
250 | if (wp != NULL) | |
251 | { | |
252 | *************** | |
253 | *** 3508,3513 **** | |
254 | --- 3523,3529 ---- | |
255 | continue; | |
256 | ||
257 | filename = get_dict_string(d, (char_u *)"filename", TRUE); | |
258 | + bufnum = get_dict_number(d, (char_u *)"bufnr"); | |
259 | lnum = get_dict_number(d, (char_u *)"lnum"); | |
260 | col = get_dict_number(d, (char_u *)"col"); | |
261 | vcol = get_dict_number(d, (char_u *)"vcol"); | |
262 | *************** | |
263 | *** 3519,3530 **** | |
264 | text = vim_strsave((char_u *)""); | |
265 | ||
266 | valid = TRUE; | |
267 | ! if (filename == NULL || (lnum == 0 && pattern == NULL)) | |
268 | valid = FALSE; | |
269 | ||
270 | status = qf_add_entry(qi, &prevp, | |
271 | NULL, /* dir */ | |
272 | filename, | |
273 | text, | |
274 | lnum, | |
275 | col, | |
276 | --- 3535,3560 ---- | |
277 | text = vim_strsave((char_u *)""); | |
278 | ||
279 | valid = TRUE; | |
280 | ! if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL)) | |
281 | valid = FALSE; | |
282 | ||
283 | + /* Mark entries with non-existing buffer number as not valid. Give the | |
284 | + * error message only once. */ | |
285 | + if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
286 | + { | |
287 | + if (!did_bufnr_emsg) | |
288 | + { | |
289 | + did_bufnr_emsg = TRUE; | |
290 | + EMSGN(_("E92: Buffer %ld not found"), bufnum); | |
291 | + } | |
292 | + valid = FALSE; | |
293 | + bufnum = 0; | |
294 | + } | |
295 | + | |
296 | status = qf_add_entry(qi, &prevp, | |
297 | NULL, /* dir */ | |
298 | filename, | |
299 | + bufnum, | |
300 | text, | |
301 | lnum, | |
302 | col, | |
303 | *************** | |
304 | *** 3757,3762 **** | |
305 | --- 3787,3793 ---- | |
306 | if (qf_add_entry(qi, &prevp, | |
307 | NULL, /* dir */ | |
308 | fnames[fi], | |
309 | + 0, | |
310 | IObuff, | |
311 | lnum, | |
312 | (int)(regmatch.startp[0] - IObuff) | |
313 | *** ../vim-7.0.190/src/version.c Sun Feb 4 02:49:03 2007 | |
314 | --- src/version.c Sun Feb 4 02:50:49 2007 | |
315 | *************** | |
316 | *** 668,669 **** | |
317 | --- 668,671 ---- | |
318 | { /* Add new patch number below this line */ | |
319 | + /**/ | |
320 | + 191, | |
321 | /**/ | |
322 | ||
323 | -- | |
324 | From "know your smileys": | |
325 | |-P Reaction to unusually ugly C code | |
326 | ||
327 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
328 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
329 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
330 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |