Mercurial > vim
annotate src/quickfix.c @ 32669:448aef880252
normalize line endings
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 26 Jun 2023 09:54:34 +0200 |
parents | cb1af9880f6d |
children | 695b50472e85 |
rev | line source |
---|---|
32669
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
9 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
10 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
11 * quickfix.c: functions for quickfix mode, using a file with error messages |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
12 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
13 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
14 #include "vim.h" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
15 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
16 #if defined(FEAT_QUICKFIX) || defined(PROTO) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
17 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
18 struct dir_stack_T |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
19 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
20 struct dir_stack_T *next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
21 char_u *dirname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
22 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
23 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
24 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
25 * For each error the next struct is allocated and linked in a list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
26 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
27 typedef struct qfline_S qfline_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
28 struct qfline_S |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
29 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
30 qfline_T *qf_next; // pointer to next error in the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
31 qfline_T *qf_prev; // pointer to previous error in the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
32 linenr_T qf_lnum; // line number where the error occurred |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
33 linenr_T qf_end_lnum; // line number when the error has range or zero |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
34 int qf_fnum; // file number for the line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
35 int qf_col; // column where the error occurred |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
36 int qf_end_col; // column when the error has range or zero |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
37 int qf_nr; // error number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
38 char_u *qf_module; // module name for this error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
39 char_u *qf_pattern; // search pattern for the error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
40 char_u *qf_text; // description of the error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
41 char_u qf_viscol; // set to TRUE if qf_col and qf_end_col is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
42 // screen column |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
43 char_u qf_cleared; // set to TRUE if line has been deleted |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
44 char_u qf_type; // type of the error (mostly 'E'); 1 for |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
45 // :helpgrep |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
46 char_u qf_valid; // valid error message detected |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
47 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
48 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
49 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
50 * There is a stack of error lists. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
51 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
52 #define LISTCOUNT 10 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
53 #define INVALID_QFIDX (-1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
54 #define INVALID_QFBUFNR (0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
55 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
56 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
57 * Quickfix list type. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
58 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
59 typedef enum |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
60 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
61 QFLT_QUICKFIX, // Quickfix list - global list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
62 QFLT_LOCATION, // Location list - per window list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
63 QFLT_INTERNAL // Internal - Temporary list used by getqflist()/getloclist() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
64 } qfltype_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
65 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
66 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
67 * Quickfix/Location list definition |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
68 * Contains a list of entries (qfline_T). qf_start points to the first entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
69 * and qf_last points to the last entry. qf_count contains the list size. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
70 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
71 * Usually the list contains one or more entries. But an empty list can be |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
72 * created using setqflist()/setloclist() with a title and/or user context |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
73 * information and entries can be added later using setqflist()/setloclist(). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
74 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
75 typedef struct qf_list_S |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
76 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
77 int_u qf_id; // Unique identifier for this list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
78 qfltype_T qfl_type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
79 qfline_T *qf_start; // pointer to the first error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
80 qfline_T *qf_last; // pointer to the last error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
81 qfline_T *qf_ptr; // pointer to the current error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
82 int qf_count; // number of errors (0 means empty list) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
83 int qf_index; // current index in the error list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
84 int qf_nonevalid; // TRUE if not a single valid entry found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
85 char_u *qf_title; // title derived from the command that created |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
86 // the error list or set by setqflist |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
87 typval_T *qf_ctx; // context set by setqflist/setloclist |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
88 callback_T qf_qftf_cb; // 'quickfixtextfunc' callback function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
89 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
90 struct dir_stack_T *qf_dir_stack; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
91 char_u *qf_directory; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
92 struct dir_stack_T *qf_file_stack; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
93 char_u *qf_currfile; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
94 int qf_multiline; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
95 int qf_multiignore; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
96 int qf_multiscan; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
97 long qf_changedtick; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
98 } qf_list_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
99 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
100 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
101 * Quickfix/Location list stack definition |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
102 * Contains a list of quickfix/location lists (qf_list_T) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
103 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
104 struct qf_info_S |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
105 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
106 // Count of references to this list. Used only for location lists. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
107 // When a location list window reference this list, qf_refcount |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
108 // will be 2. Otherwise, qf_refcount will be 1. When qf_refcount |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
109 // reaches 0, the list is freed. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
110 int qf_refcount; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
111 int qf_listcount; // current number of lists |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
112 int qf_curlist; // current error list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
113 qf_list_T qf_lists[LISTCOUNT]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
114 qfltype_T qfl_type; // type of list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
115 int qf_bufnr; // quickfix window buffer number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
116 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
117 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
118 static qf_info_T ql_info; // global quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
119 static int_u last_qf_id = 0; // Last used quickfix list id |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
120 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
121 #define FMT_PATTERNS 13 // maximum number of % recognized |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
122 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
123 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
124 * Structure used to hold the info of one part of 'errorformat' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
125 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
126 typedef struct efm_S efm_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
127 struct efm_S |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
128 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
129 regprog_T *prog; // pre-formatted part of 'errorformat' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
130 efm_T *next; // pointer to next (NULL if last) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
131 char_u addr[FMT_PATTERNS]; // indices of used % patterns |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
132 char_u prefix; // prefix of this format line: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
133 // 'D' enter directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
134 // 'X' leave directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
135 // 'A' start of multi-line message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
136 // 'E' error message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
137 // 'W' warning message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
138 // 'I' informational message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
139 // 'N' note message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
140 // 'C' continuation line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
141 // 'Z' end of multi-line message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
142 // 'G' general, unspecific message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
143 // 'P' push file (partial) message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
144 // 'Q' pop/quit file (partial) message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
145 // 'O' overread (partial) message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
146 char_u flags; // additional flags given in prefix |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
147 // '-' do not include this line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
148 // '+' include whole line in message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
149 int conthere; // %> used |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
150 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
151 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
152 // List of location lists to be deleted. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
153 // Used to delay the deletion of locations lists by autocmds. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
154 typedef struct qf_delq_S |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
155 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
156 struct qf_delq_S *next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
157 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
158 } qf_delq_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
159 static qf_delq_T *qf_delq_head = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
160 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
161 // Counter to prevent autocmds from freeing up location lists when they are |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
162 // still being used. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
163 static int quickfix_busy = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
164 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
165 static efm_T *fmt_start = NULL; // cached across qf_parse_line() calls |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
166 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
167 // callback function for 'quickfixtextfunc' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
168 static callback_T qftf_cb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
169 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
170 static void qf_new_list(qf_info_T *qi, char_u *qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
171 static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, char_u *module, int bufnum, char_u *mesg, long lnum, long end_lnum, int col, int end_col, int vis_col, char_u *pattern, int nr, int type, int valid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
172 static void qf_free(qf_list_T *qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
173 static char_u *qf_types(int, int); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
174 static int qf_get_fnum(qf_list_T *qfl, char_u *, char_u *); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
175 static char_u *qf_push_dir(char_u *, struct dir_stack_T **, int is_file_stack); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
176 static char_u *qf_pop_dir(struct dir_stack_T **); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
177 static char_u *qf_guess_filepath(qf_list_T *qfl, char_u *); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
178 static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit, int newwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
179 static void qf_fmt_text(garray_T *gap, char_u *text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
180 static void qf_range_text(garray_T *gap, qfline_T *qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
181 static int qf_win_pos_update(qf_info_T *qi, int old_qf_index); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
182 static win_T *qf_find_win(qf_info_T *qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
183 static buf_T *qf_find_buf(qf_info_T *qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
184 static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
185 static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
186 static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *resulting_dir); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
187 static void wipe_dummy_buffer(buf_T *buf, char_u *dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
188 static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
189 static qf_info_T *ll_get_or_alloc_list(win_T *); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
190 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
191 // Quickfix window check helper macro |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
192 #define IS_QF_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
193 // Location list window check helper macro |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
194 #define IS_LL_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
195 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
196 // Quickfix and location list stack check helper macros |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
197 #define IS_QF_STACK(qi) ((qi)->qfl_type == QFLT_QUICKFIX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
198 #define IS_LL_STACK(qi) ((qi)->qfl_type == QFLT_LOCATION) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
199 #define IS_QF_LIST(qfl) ((qfl)->qfl_type == QFLT_QUICKFIX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
200 #define IS_LL_LIST(qfl) ((qfl)->qfl_type == QFLT_LOCATION) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
201 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
202 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
203 * Return location list for window 'wp' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
204 * For location list window, return the referenced location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
205 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
206 #define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? (wp)->w_llist_ref : (wp)->w_llist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
207 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
208 // Macro to loop through all the items in a quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
209 // Quickfix item index starts from 1, so i below starts at 1 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
210 #define FOR_ALL_QFL_ITEMS(qfl, qfp, i) \ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
211 for ((i) = 1, (qfp) = (qfl)->qf_start; \ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
212 !got_int && (i) <= (qfl)->qf_count && (qfp) != NULL; \ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
213 ++(i), (qfp) = (qfp)->qf_next) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
214 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
215 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
216 * Looking up a buffer can be slow if there are many. Remember the last one |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
217 * to make this a lot faster if there are multiple matches in the same file. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
218 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
219 static char_u *qf_last_bufname = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
220 static bufref_T qf_last_bufref = {NULL, 0, 0}; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
221 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
222 static garray_T qfga; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
223 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
224 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
225 * Get a growarray to buffer text in. Shared between various commands to avoid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
226 * many alloc/free calls. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
227 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
228 static garray_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
229 qfga_get(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
230 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
231 static int initialized = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
232 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
233 if (!initialized) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
234 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
235 initialized = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
236 ga_init2(&qfga, 1, 256); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
237 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
238 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
239 // Reset the length to zero. Retain ga_data from previous use to avoid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
240 // many alloc/free calls. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
241 qfga.ga_len = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
242 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
243 return &qfga; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
244 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
245 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
246 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
247 * The "qfga" grow array buffer is reused across multiple quickfix commands as |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
248 * a temporary buffer to reduce the number of alloc/free calls. But if the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
249 * buffer size is large, then to avoid holding on to that memory, clear the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
250 * grow array. Otherwise just reset the grow array length. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
251 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
252 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
253 qfga_clear(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
254 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
255 if (qfga.ga_maxlen > 1000) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
256 ga_clear(&qfga); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
257 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
258 qfga.ga_len = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
259 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
260 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
261 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
262 * Maximum number of bytes allowed per line while reading a errorfile. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
263 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
264 #define LINE_MAXLEN 4096 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
265 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
266 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
267 * Patterns used. Keep in sync with qf_parse_fmt[]. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
268 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
269 static struct fmtpattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
270 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
271 char_u convchar; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
272 char *pattern; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
273 } fmt_pat[FMT_PATTERNS] = |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
274 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
275 {'f', ".\\+"}, // only used when at end |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
276 {'n', "\\d\\+"}, // 1 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
277 {'l', "\\d\\+"}, // 2 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
278 {'e', "\\d\\+"}, // 3 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
279 {'c', "\\d\\+"}, // 4 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
280 {'k', "\\d\\+"}, // 5 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
281 {'t', "."}, // 6 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
282 #define FMT_PATTERN_M 7 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
283 {'m', ".\\+"}, // 7 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
284 #define FMT_PATTERN_R 8 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
285 {'r', ".*"}, // 8 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
286 {'p', "[- .]*"}, // 9 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
287 {'v', "\\d\\+"}, // 10 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
288 {'s', ".\\+"}, // 11 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
289 {'o', ".\\+"} // 12 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
290 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
291 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
292 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
293 * Convert an errorformat pattern to a regular expression pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
294 * See fmt_pat definition above for the list of supported patterns. The |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
295 * pattern specifier is supplied in "efmpat". The converted pattern is stored |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
296 * in "regpat". Returns a pointer to the location after the pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
297 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
298 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
299 efmpat_to_regpat( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
300 char_u *efmpat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
301 char_u *regpat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
302 efm_T *efminfo, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
303 int idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
304 int round) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
305 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
306 char_u *srcptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
307 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
308 if (efminfo->addr[idx]) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
309 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
310 // Each errorformat pattern can occur only once |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
311 semsg(_(e_too_many_chr_in_format_string), *efmpat); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
312 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
313 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
314 if ((idx && idx < FMT_PATTERN_R |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
315 && vim_strchr((char_u *)"DXOPQ", efminfo->prefix) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
316 || (idx == FMT_PATTERN_R |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
317 && vim_strchr((char_u *)"OPQ", efminfo->prefix) == NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
318 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
319 semsg(_(e_unexpected_chr_in_format_str), *efmpat); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
320 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
321 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
322 efminfo->addr[idx] = (char_u)++round; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
323 *regpat++ = '\\'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
324 *regpat++ = '('; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
325 #ifdef BACKSLASH_IN_FILENAME |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
326 if (*efmpat == 'f') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
327 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
328 // Also match "c:" in the file name, even when |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
329 // checking for a colon next: "%f:". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
330 // "\%(\a:\)\=" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
331 STRCPY(regpat, "\\%(\\a:\\)\\="); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
332 regpat += 10; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
333 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
334 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
335 if (*efmpat == 'f' && efmpat[1] != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
336 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
337 if (efmpat[1] != '\\' && efmpat[1] != '%') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
338 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
339 // A file name may contain spaces, but this isn't |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
340 // in "\f". For "%f:%l:%m" there may be a ":" in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
341 // the file name. Use ".\{-1,}x" instead (x is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
342 // the next character), the requirement that :999: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
343 // follows should work. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
344 STRCPY(regpat, ".\\{-1,}"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
345 regpat += 7; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
346 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
347 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
348 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
349 // File name followed by '\\' or '%': include as |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
350 // many file name chars as possible. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
351 STRCPY(regpat, "\\f\\+"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
352 regpat += 4; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
353 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
354 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
355 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
356 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
357 srcptr = (char_u *)fmt_pat[idx].pattern; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
358 while ((*regpat = *srcptr++) != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
359 ++regpat; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
360 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
361 *regpat++ = '\\'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
362 *regpat++ = ')'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
363 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
364 return regpat; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
365 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
366 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
367 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
368 * Convert a scanf like format in 'errorformat' to a regular expression. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
369 * Returns a pointer to the location after the pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
370 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
371 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
372 scanf_fmt_to_regpat( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
373 char_u **pefmp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
374 char_u *efm, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
375 int len, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
376 char_u *regpat) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
377 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
378 char_u *efmp = *pefmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
379 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
380 if (*efmp == '[' || *efmp == '\\') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
381 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
382 if ((*regpat++ = *efmp) == '[') // %*[^a-z0-9] etc. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
383 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
384 if (efmp[1] == '^') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
385 *regpat++ = *++efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
386 if (efmp < efm + len) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
387 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
388 *regpat++ = *++efmp; // could be ']' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
389 while (efmp < efm + len |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
390 && (*regpat++ = *++efmp) != ']') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
391 // skip ; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
392 if (efmp == efm + len) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
393 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
394 emsg(_(e_missing_rsb_in_format_string)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
395 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
396 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
397 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
398 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
399 else if (efmp < efm + len) // %*\D, %*\s etc. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
400 *regpat++ = *++efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
401 *regpat++ = '\\'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
402 *regpat++ = '+'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
403 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
404 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
405 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
406 // TODO: scanf()-like: %*ud, %*3c, %*f, ... ? |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
407 semsg(_(e_unsupported_chr_in_format_string), *efmp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
408 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
409 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
410 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
411 *pefmp = efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
412 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
413 return regpat; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
414 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
415 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
416 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
417 * Analyze/parse an errorformat prefix. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
418 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
419 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
420 efm_analyze_prefix(char_u *efmp, efm_T *efminfo) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
421 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
422 if (vim_strchr((char_u *)"+-", *efmp) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
423 efminfo->flags = *efmp++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
424 if (vim_strchr((char_u *)"DXAEWINCZGOPQ", *efmp) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
425 efminfo->prefix = *efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
426 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
427 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
428 semsg(_(e_invalid_chr_in_format_string_prefix), *efmp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
429 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
430 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
431 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
432 return efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
433 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
434 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
435 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
436 * Converts a 'errorformat' string part in 'efm' to a regular expression |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
437 * pattern. The resulting regex pattern is returned in "regpat". Additional |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
438 * information about the 'erroformat' pattern is returned in "fmt_ptr". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
439 * Returns OK or FAIL. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
440 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
441 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
442 efm_to_regpat( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
443 char_u *efm, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
444 int len, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
445 efm_T *fmt_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
446 char_u *regpat) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
447 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
448 char_u *ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
449 char_u *efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
450 int round; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
451 int idx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
452 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
453 // Build a regexp pattern for a 'errorformat' option part |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
454 ptr = regpat; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
455 *ptr++ = '^'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
456 round = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
457 for (efmp = efm; efmp < efm + len; ++efmp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
458 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
459 if (*efmp == '%') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
460 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
461 ++efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
462 for (idx = 0; idx < FMT_PATTERNS; ++idx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
463 if (fmt_pat[idx].convchar == *efmp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
464 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
465 if (idx < FMT_PATTERNS) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
466 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
467 ptr = efmpat_to_regpat(efmp, ptr, fmt_ptr, idx, round); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
468 if (ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
469 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
470 round++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
471 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
472 else if (*efmp == '*') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
473 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
474 ++efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
475 ptr = scanf_fmt_to_regpat(&efmp, efm, len, ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
476 if (ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
477 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
478 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
479 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
480 *ptr++ = *efmp; // regexp magic characters |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
481 else if (*efmp == '#') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
482 *ptr++ = '*'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
483 else if (*efmp == '>') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
484 fmt_ptr->conthere = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
485 else if (efmp == efm + 1) // analyse prefix |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
486 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
487 // prefix is allowed only at the beginning of the errorformat |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
488 // option part |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
489 efmp = efm_analyze_prefix(efmp, fmt_ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
490 if (efmp == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
491 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
492 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
493 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
494 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
495 semsg(_(e_invalid_chr_in_format_string), *efmp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
496 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
497 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
498 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
499 else // copy normal character |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
500 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
501 if (*efmp == '\\' && efmp + 1 < efm + len) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
502 ++efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
503 else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
504 *ptr++ = '\\'; // escape regexp atoms |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
505 if (*efmp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
506 *ptr++ = *efmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
507 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
508 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
509 *ptr++ = '$'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
510 *ptr = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
511 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
512 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
513 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
514 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
515 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
516 * Free the 'errorformat' information list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
517 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
518 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
519 free_efm_list(efm_T **efm_first) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
520 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
521 efm_T *efm_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
522 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
523 for (efm_ptr = *efm_first; efm_ptr != NULL; efm_ptr = *efm_first) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
524 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
525 *efm_first = efm_ptr->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
526 vim_regfree(efm_ptr->prog); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
527 vim_free(efm_ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
528 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
529 fmt_start = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
530 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
531 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
532 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
533 * Compute the size of the buffer used to convert a 'errorformat' pattern into |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
534 * a regular expression pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
535 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
536 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
537 efm_regpat_bufsz(char_u *efm) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
538 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
539 int sz; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
540 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
541 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
542 sz = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
543 for (i = FMT_PATTERNS; i > 0; ) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
544 sz += (int)STRLEN(fmt_pat[--i].pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
545 #ifdef BACKSLASH_IN_FILENAME |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
546 sz += 12; // "%f" can become twelve chars longer (see efm_to_regpat) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
547 #else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
548 sz += 2; // "%f" can become two chars longer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
549 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
550 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
551 return sz; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
552 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
553 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
554 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
555 * Return the length of a 'errorformat' option part (separated by ","). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
556 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
557 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
558 efm_option_part_len(char_u *efm) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
559 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
560 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
561 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
562 for (len = 0; efm[len] != NUL && efm[len] != ','; ++len) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
563 if (efm[len] == '\\' && efm[len + 1] != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
564 ++len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
565 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
566 return len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
567 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
568 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
569 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
570 * Parse the 'errorformat' option. Multiple parts in the 'errorformat' option |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
571 * are parsed and converted to regular expressions. Returns information about |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
572 * the parsed 'errorformat' option. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
573 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
574 static efm_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
575 parse_efm_option(char_u *efm) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
576 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
577 efm_T *fmt_ptr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
578 efm_T *fmt_first = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
579 efm_T *fmt_last = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
580 char_u *fmtstr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
581 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
582 int sz; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
583 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
584 // Each part of the format string is copied and modified from errorformat |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
585 // to regex prog. Only a few % characters are allowed. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
586 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
587 // Get some space to modify the format string into. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
588 sz = efm_regpat_bufsz(efm); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
589 if ((fmtstr = alloc_id(sz, aid_qf_efm_fmtstr)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
590 goto parse_efm_error; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
591 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
592 while (efm[0] != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
593 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
594 // Allocate a new eformat structure and put it at the end of the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
595 fmt_ptr = ALLOC_CLEAR_ONE_ID(efm_T, aid_qf_efm_fmtpart); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
596 if (fmt_ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
597 goto parse_efm_error; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
598 if (fmt_first == NULL) // first one |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
599 fmt_first = fmt_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
600 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
601 fmt_last->next = fmt_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
602 fmt_last = fmt_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
603 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
604 // Isolate one part in the 'errorformat' option |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
605 len = efm_option_part_len(efm); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
606 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
607 if (efm_to_regpat(efm, len, fmt_ptr, fmtstr) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
608 goto parse_efm_error; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
609 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
610 goto parse_efm_error; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
611 // Advance to next part |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
612 efm = skip_to_option_part(efm + len); // skip comma and spaces |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
613 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
614 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
615 if (fmt_first == NULL) // nothing found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
616 emsg(_(e_errorformat_contains_no_pattern)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
617 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
618 goto parse_efm_end; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
619 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
620 parse_efm_error: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
621 free_efm_list(&fmt_first); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
622 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
623 parse_efm_end: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
624 vim_free(fmtstr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
625 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
626 return fmt_first; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
627 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
628 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
629 enum { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
630 QF_FAIL = 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
631 QF_OK = 1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
632 QF_END_OF_INPUT = 2, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
633 QF_NOMEM = 3, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
634 QF_IGNORE_LINE = 4, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
635 QF_MULTISCAN = 5, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
636 QF_ABORT = 6 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
637 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
638 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
639 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
640 * State information used to parse lines and add entries to a quickfix/location |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
641 * list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
642 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
643 typedef struct { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
644 char_u *linebuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
645 int linelen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
646 char_u *growbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
647 int growbufsiz; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
648 FILE *fd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
649 typval_T *tv; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
650 char_u *p_str; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
651 listitem_T *p_li; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
652 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
653 linenr_T buflnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
654 linenr_T lnumlast; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
655 vimconv_T vc; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
656 } qfstate_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
657 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
658 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
659 * Allocate more memory for the line buffer used for parsing lines. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
660 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
661 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
662 qf_grow_linebuf(qfstate_T *state, int newsz) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
663 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
664 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
665 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
666 // If the line exceeds LINE_MAXLEN exclude the last |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
667 // byte since it's not a NL character. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
668 state->linelen = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
669 if (state->growbuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
670 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
671 state->growbuf = alloc_id(state->linelen + 1, aid_qf_linebuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
672 if (state->growbuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
673 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
674 state->growbufsiz = state->linelen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
675 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
676 else if (state->linelen > state->growbufsiz) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
677 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
678 if ((p = vim_realloc(state->growbuf, state->linelen + 1)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
679 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
680 state->growbuf = p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
681 state->growbufsiz = state->linelen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
682 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
683 return state->growbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
684 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
685 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
686 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
687 * Get the next string (separated by newline) from state->p_str. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
688 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
689 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
690 qf_get_next_str_line(qfstate_T *state) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
691 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
692 // Get the next line from the supplied string |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
693 char_u *p_str = state->p_str; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
694 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
695 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
696 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
697 if (*p_str == NUL) // Reached the end of the string |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
698 return QF_END_OF_INPUT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
699 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
700 p = vim_strchr(p_str, '\n'); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
701 if (p != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
702 len = (int)(p - p_str) + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
703 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
704 len = (int)STRLEN(p_str); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
705 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
706 if (len > IOSIZE - 2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
707 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
708 state->linebuf = qf_grow_linebuf(state, len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
709 if (state->linebuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
710 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
711 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
712 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
713 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
714 state->linebuf = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
715 state->linelen = len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
716 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
717 vim_strncpy(state->linebuf, p_str, state->linelen); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
718 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
719 // Increment using len in order to discard the rest of the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
720 // line if it exceeds LINE_MAXLEN. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
721 p_str += len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
722 state->p_str = p_str; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
723 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
724 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
725 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
726 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
727 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
728 * Get the next string from the List item state->p_li. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
729 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
730 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
731 qf_get_next_list_line(qfstate_T *state) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
732 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
733 listitem_T *p_li = state->p_li; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
734 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
735 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
736 while (p_li != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
737 && (p_li->li_tv.v_type != VAR_STRING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
738 || p_li->li_tv.vval.v_string == NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
739 p_li = p_li->li_next; // Skip non-string items |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
740 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
741 if (p_li == NULL) // End of the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
742 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
743 state->p_li = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
744 return QF_END_OF_INPUT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
745 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
746 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
747 len = (int)STRLEN(p_li->li_tv.vval.v_string); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
748 if (len > IOSIZE - 2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
749 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
750 state->linebuf = qf_grow_linebuf(state, len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
751 if (state->linebuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
752 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
753 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
754 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
755 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
756 state->linebuf = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
757 state->linelen = len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
758 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
759 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
760 vim_strncpy(state->linebuf, p_li->li_tv.vval.v_string, state->linelen); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
761 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
762 state->p_li = p_li->li_next; // next item |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
763 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
764 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
765 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
766 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
767 * Get the next string from state->buf. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
768 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
769 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
770 qf_get_next_buf_line(qfstate_T *state) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
771 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
772 char_u *p_buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
773 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
774 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
775 // Get the next line from the supplied buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
776 if (state->buflnum > state->lnumlast) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
777 return QF_END_OF_INPUT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
778 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
779 p_buf = ml_get_buf(state->buf, state->buflnum, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
780 state->buflnum += 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
781 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
782 len = (int)STRLEN(p_buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
783 if (len > IOSIZE - 2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
784 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
785 state->linebuf = qf_grow_linebuf(state, len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
786 if (state->linebuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
787 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
788 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
789 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
790 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
791 state->linebuf = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
792 state->linelen = len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
793 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
794 vim_strncpy(state->linebuf, p_buf, state->linelen); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
795 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
796 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
797 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
798 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
799 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
800 * Get the next string from file state->fd. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
801 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
802 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
803 qf_get_next_file_line(qfstate_T *state) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
804 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
805 int discard; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
806 int growbuflen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
807 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
808 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
809 return QF_END_OF_INPUT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
810 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
811 discard = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
812 state->linelen = (int)STRLEN(IObuff); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
813 if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\n')) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
814 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
815 // The current line exceeds IObuff, continue reading using |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
816 // growbuf until EOL or LINE_MAXLEN bytes is read. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
817 if (state->growbuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
818 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
819 state->growbufsiz = 2 * (IOSIZE - 1); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
820 state->growbuf = alloc_id(state->growbufsiz, aid_qf_linebuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
821 if (state->growbuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
822 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
823 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
824 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
825 // Copy the read part of the line, excluding null-terminator |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
826 memcpy(state->growbuf, IObuff, IOSIZE - 1); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
827 growbuflen = state->linelen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
828 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
829 for (;;) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
830 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
831 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
832 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
833 if (fgets((char *)state->growbuf + growbuflen, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
834 state->growbufsiz - growbuflen, state->fd) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
835 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
836 state->linelen = (int)STRLEN(state->growbuf + growbuflen); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
837 growbuflen += state->linelen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
838 if ((state->growbuf)[growbuflen - 1] == '\n') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
839 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
840 if (state->growbufsiz == LINE_MAXLEN) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
841 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
842 discard = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
843 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
844 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
845 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
846 state->growbufsiz = 2 * state->growbufsiz < LINE_MAXLEN |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
847 ? 2 * state->growbufsiz : LINE_MAXLEN; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
848 if ((p = vim_realloc(state->growbuf, state->growbufsiz)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
849 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
850 state->growbuf = p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
851 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
852 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
853 while (discard) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
854 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
855 // The current line is longer than LINE_MAXLEN, continue |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
856 // reading but discard everything until EOL or EOF is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
857 // reached. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
858 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
859 || (int)STRLEN(IObuff) < IOSIZE - 1 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
860 || IObuff[IOSIZE - 2] == '\n') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
861 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
862 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
863 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
864 state->linebuf = state->growbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
865 state->linelen = growbuflen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
866 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
867 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
868 state->linebuf = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
869 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
870 // Convert a line if it contains a non-ASCII character. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
871 if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
872 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
873 char_u *line; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
874 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
875 line = string_convert(&state->vc, state->linebuf, &state->linelen); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
876 if (line != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
877 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
878 if (state->linelen < IOSIZE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
879 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
880 STRCPY(state->linebuf, line); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
881 vim_free(line); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
882 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
883 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
884 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
885 vim_free(state->growbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
886 state->linebuf = state->growbuf = line; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
887 state->growbufsiz = state->linelen < LINE_MAXLEN |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
888 ? state->linelen : LINE_MAXLEN; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
889 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
890 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
891 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
892 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
893 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
894 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
895 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
896 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
897 * Get the next string from a file/buffer/list/string. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
898 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
899 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
900 qf_get_nextline(qfstate_T *state) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
901 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
902 int status = QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
903 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
904 if (state->fd == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
905 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
906 if (state->tv != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
907 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
908 if (state->tv->v_type == VAR_STRING) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
909 // Get the next line from the supplied string |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
910 status = qf_get_next_str_line(state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
911 else if (state->tv->v_type == VAR_LIST) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
912 // Get the next line from the supplied list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
913 status = qf_get_next_list_line(state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
914 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
915 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
916 // Get the next line from the supplied buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
917 status = qf_get_next_buf_line(state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
918 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
919 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
920 // Get the next line from the supplied file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
921 status = qf_get_next_file_line(state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
922 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
923 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
924 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
925 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
926 // remove newline/CR from the line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
927 if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\n') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
928 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
929 state->linebuf[state->linelen - 1] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
930 #ifdef USE_CRNL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
931 if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
932 state->linebuf[state->linelen - 2] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
933 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
934 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
935 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
936 remove_bom(state->linebuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
937 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
938 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
939 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
940 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
941 typedef struct { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
942 char_u *namebuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
943 char_u *module; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
944 char_u *errmsg; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
945 int errmsglen; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
946 long lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
947 long end_lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
948 int col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
949 int end_col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
950 char_u use_viscol; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
951 char_u *pattern; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
952 int enr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
953 int type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
954 int valid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
955 } qffields_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
956 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
957 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
958 * Parse the match for filename ('%f') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
959 * Return the matched value in "fields->namebuf". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
960 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
961 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
962 qf_parse_fmt_f(regmatch_T *rmp, int midx, qffields_T *fields, int prefix) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
963 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
964 int c; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
965 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
966 if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
967 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
968 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
969 // Expand ~/file and $HOME/file to full path. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
970 c = *rmp->endp[midx]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
971 *rmp->endp[midx] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
972 expand_env(rmp->startp[midx], fields->namebuf, CMDBUFFSIZE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
973 *rmp->endp[midx] = c; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
974 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
975 // For separate filename patterns (%O, %P and %Q), the specified file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
976 // should exist. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
977 if (vim_strchr((char_u *)"OPQ", prefix) != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
978 && mch_getperm(fields->namebuf) == -1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
979 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
980 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
981 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
982 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
983 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
984 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
985 * Parse the match for error number ('%n') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
986 * Return the matched value in "fields->enr". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
987 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
988 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
989 qf_parse_fmt_n(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
990 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
991 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
992 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
993 fields->enr = (int)atol((char *)rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
994 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
995 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
996 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
997 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
998 * Parse the match for line number ('%l') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
999 * Return the matched value in "fields->lnum". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1000 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1001 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1002 qf_parse_fmt_l(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1003 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1004 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1005 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1006 fields->lnum = atol((char *)rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1007 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1008 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1009 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1010 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1011 * Parse the match for end line number ('%e') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1012 * Return the matched value in "fields->end_lnum". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1013 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1014 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1015 qf_parse_fmt_e(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1016 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1017 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1018 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1019 fields->end_lnum = atol((char *)rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1020 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1021 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1022 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1023 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1024 * Parse the match for column number ('%c') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1025 * Return the matched value in "fields->col". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1026 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1027 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1028 qf_parse_fmt_c(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1029 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1030 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1031 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1032 fields->col = (int)atol((char *)rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1033 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1034 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1035 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1036 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1037 * Parse the match for end column number ('%k') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1038 * Return the matched value in "fields->end_col". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1039 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1040 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1041 qf_parse_fmt_k(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1042 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1043 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1044 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1045 fields->end_col = (int)atol((char *)rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1046 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1047 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1048 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1049 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1050 * Parse the match for error type ('%t') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1051 * Return the matched value in "fields->type". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1052 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1053 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1054 qf_parse_fmt_t(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1055 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1056 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1057 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1058 fields->type = *rmp->startp[midx]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1059 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1060 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1061 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1062 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1063 * Copy a non-error line into the error string. Return the matched line in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1064 * "fields->errmsg". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1065 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1066 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1067 copy_nonerror_line(char_u *linebuf, int linelen, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1068 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1069 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1070 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1071 if (linelen >= fields->errmsglen) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1072 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1073 // linelen + null terminator |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1074 if ((p = vim_realloc(fields->errmsg, linelen + 1)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1075 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1076 fields->errmsg = p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1077 fields->errmsglen = linelen + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1078 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1079 // copy whole line to error message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1080 vim_strncpy(fields->errmsg, linebuf, linelen); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1081 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1082 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1083 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1084 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1085 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1086 * Parse the match for error message ('%m') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1087 * Return the matched value in "fields->errmsg". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1088 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1089 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1090 qf_parse_fmt_m(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1091 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1092 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1093 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1094 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1095 if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1096 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1097 len = (int)(rmp->endp[midx] - rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1098 if (len >= fields->errmsglen) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1099 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1100 // len + null terminator |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1101 if ((p = vim_realloc(fields->errmsg, len + 1)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1102 return QF_NOMEM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1103 fields->errmsg = p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1104 fields->errmsglen = len + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1105 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1106 vim_strncpy(fields->errmsg, rmp->startp[midx], len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1107 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1108 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1109 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1110 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1111 * Parse the match for rest of a single-line file message ('%r') pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1112 * Return the matched value in "tail". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1113 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1114 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1115 qf_parse_fmt_r(regmatch_T *rmp, int midx, char_u **tail) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1116 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1117 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1118 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1119 *tail = rmp->startp[midx]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1120 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1121 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1122 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1123 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1124 * Parse the match for the pointer line ('%p') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1125 * Return the matched value in "fields->col". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1126 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1127 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1128 qf_parse_fmt_p(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1129 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1130 char_u *match_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1131 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1132 if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1133 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1134 fields->col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1135 for (match_ptr = rmp->startp[midx]; match_ptr != rmp->endp[midx]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1136 ++match_ptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1137 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1138 ++fields->col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1139 if (*match_ptr == TAB) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1140 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1141 fields->col += 7; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1142 fields->col -= fields->col % 8; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1143 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1144 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1145 ++fields->col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1146 fields->use_viscol = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1147 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1148 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1149 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1150 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1151 * Parse the match for the virtual column number ('%v') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1152 * Return the matched value in "fields->col". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1153 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1154 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1155 qf_parse_fmt_v(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1156 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1157 if (rmp->startp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1158 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1159 fields->col = (int)atol((char *)rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1160 fields->use_viscol = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1161 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1162 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1163 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1164 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1165 * Parse the match for the search text ('%s') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1166 * Return the matched value in "fields->pattern". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1167 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1168 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1169 qf_parse_fmt_s(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1170 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1171 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1172 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1173 if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1174 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1175 len = (int)(rmp->endp[midx] - rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1176 if (len > CMDBUFFSIZE - 5) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1177 len = CMDBUFFSIZE - 5; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1178 STRCPY(fields->pattern, "^\\V"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1179 STRNCAT(fields->pattern, rmp->startp[midx], len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1180 fields->pattern[len + 3] = '\\'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1181 fields->pattern[len + 4] = '$'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1182 fields->pattern[len + 5] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1183 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1184 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1185 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1186 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1187 * Parse the match for the module ('%o') pattern in regmatch. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1188 * Return the matched value in "fields->module". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1189 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1190 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1191 qf_parse_fmt_o(regmatch_T *rmp, int midx, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1192 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1193 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1194 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1195 if (rmp->startp[midx] == NULL || rmp->endp[midx] == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1196 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1197 len = (int)(rmp->endp[midx] - rmp->startp[midx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1198 if (len > CMDBUFFSIZE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1199 len = CMDBUFFSIZE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1200 STRNCAT(fields->module, rmp->startp[midx], len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1201 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1202 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1203 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1204 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1205 * 'errorformat' format pattern parser functions. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1206 * The '%f' and '%r' formats are parsed differently from other formats. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1207 * See qf_parse_match() for details. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1208 * Keep in sync with fmt_pat[]. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1209 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1210 static int (*qf_parse_fmt[FMT_PATTERNS])(regmatch_T *, int, qffields_T *) = |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1211 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1212 NULL, // %f |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1213 qf_parse_fmt_n, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1214 qf_parse_fmt_l, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1215 qf_parse_fmt_e, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1216 qf_parse_fmt_c, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1217 qf_parse_fmt_k, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1218 qf_parse_fmt_t, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1219 qf_parse_fmt_m, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1220 NULL, // %r |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1221 qf_parse_fmt_p, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1222 qf_parse_fmt_v, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1223 qf_parse_fmt_s, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1224 qf_parse_fmt_o |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1225 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1226 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1227 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1228 * Parse the error format pattern matches in "regmatch" and set the values in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1229 * "fields". fmt_ptr contains the 'efm' format specifiers/prefixes that have a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1230 * match. Returns QF_OK if all the matches are successfully parsed. On |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1231 * failure, returns QF_FAIL or QF_NOMEM. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1232 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1233 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1234 qf_parse_match( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1235 char_u *linebuf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1236 int linelen, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1237 efm_T *fmt_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1238 regmatch_T *regmatch, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1239 qffields_T *fields, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1240 int qf_multiline, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1241 int qf_multiscan, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1242 char_u **tail) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1243 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1244 int idx = fmt_ptr->prefix; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1245 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1246 int midx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1247 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1248 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1249 if ((idx == 'C' || idx == 'Z') && !qf_multiline) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1250 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1251 if (vim_strchr((char_u *)"EWIN", idx) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1252 fields->type = idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1253 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1254 fields->type = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1255 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1256 // Extract error message data from matched line. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1257 // We check for an actual submatch, because "\[" and "\]" in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1258 // the 'errorformat' may cause the wrong submatch to be used. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1259 for (i = 0; i < FMT_PATTERNS; i++) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1260 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1261 status = QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1262 midx = (int)fmt_ptr->addr[i]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1263 if (i == 0 && midx > 0) // %f |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1264 status = qf_parse_fmt_f(regmatch, midx, fields, idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1265 else if (i == FMT_PATTERN_M) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1266 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1267 if (fmt_ptr->flags == '+' && !qf_multiscan) // %+ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1268 status = copy_nonerror_line(linebuf, linelen, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1269 else if (midx > 0) // %m |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1270 status = qf_parse_fmt_m(regmatch, midx, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1271 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1272 else if (i == FMT_PATTERN_R && midx > 0) // %r |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1273 status = qf_parse_fmt_r(regmatch, midx, tail); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1274 else if (midx > 0) // others |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1275 status = (qf_parse_fmt[i])(regmatch, midx, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1276 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1277 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1278 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1279 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1280 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1281 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1282 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1283 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1284 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1285 * Parse an error line in 'linebuf' using a single error format string in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1286 * 'fmt_ptr->prog' and return the matching values in 'fields'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1287 * Returns QF_OK if the efm format matches completely and the fields are |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1288 * successfully copied. Otherwise returns QF_FAIL or QF_NOMEM. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1289 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1290 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1291 qf_parse_get_fields( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1292 char_u *linebuf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1293 int linelen, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1294 efm_T *fmt_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1295 qffields_T *fields, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1296 int qf_multiline, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1297 int qf_multiscan, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1298 char_u **tail) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1299 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1300 regmatch_T regmatch; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1301 int status = QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1302 int r; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1303 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1304 if (qf_multiscan && |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1305 vim_strchr((char_u *)"OPQ", fmt_ptr->prefix) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1306 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1307 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1308 fields->namebuf[0] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1309 fields->module[0] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1310 fields->pattern[0] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1311 if (!qf_multiscan) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1312 fields->errmsg[0] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1313 fields->lnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1314 fields->end_lnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1315 fields->col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1316 fields->end_col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1317 fields->use_viscol = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1318 fields->enr = -1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1319 fields->type = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1320 *tail = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1321 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1322 // Always ignore case when looking for a matching error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1323 regmatch.rm_ic = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1324 regmatch.regprog = fmt_ptr->prog; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1325 r = vim_regexec(®match, linebuf, (colnr_T)0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1326 fmt_ptr->prog = regmatch.regprog; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1327 if (r) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1328 status = qf_parse_match(linebuf, linelen, fmt_ptr, ®match, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1329 fields, qf_multiline, qf_multiscan, tail); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1330 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1331 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1332 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1333 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1334 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1335 * Parse directory error format prefixes (%D and %X). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1336 * Push and pop directories from the directory stack when scanning directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1337 * names. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1338 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1339 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1340 qf_parse_dir_pfx(int idx, qffields_T *fields, qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1341 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1342 if (idx == 'D') // enter directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1343 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1344 if (*fields->namebuf == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1345 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1346 emsg(_(e_missing_or_empty_directory_name)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1347 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1348 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1349 qfl->qf_directory = |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1350 qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1351 if (qfl->qf_directory == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1352 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1353 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1354 else if (idx == 'X') // leave directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1355 qfl->qf_directory = qf_pop_dir(&qfl->qf_dir_stack); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1356 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1357 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1358 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1359 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1360 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1361 * Parse global file name error format prefixes (%O, %P and %Q). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1362 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1363 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1364 qf_parse_file_pfx( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1365 int idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1366 qffields_T *fields, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1367 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1368 char_u *tail) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1369 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1370 fields->valid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1371 if (*fields->namebuf == NUL || mch_getperm(fields->namebuf) >= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1372 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1373 if (*fields->namebuf && idx == 'P') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1374 qfl->qf_currfile = |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1375 qf_push_dir(fields->namebuf, &qfl->qf_file_stack, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1376 else if (idx == 'Q') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1377 qfl->qf_currfile = qf_pop_dir(&qfl->qf_file_stack); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1378 *fields->namebuf = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1379 if (tail && *tail) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1380 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1381 STRMOVE(IObuff, skipwhite(tail)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1382 qfl->qf_multiscan = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1383 return QF_MULTISCAN; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1384 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1385 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1386 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1387 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1388 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1389 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1390 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1391 * Parse a non-error line (a line which doesn't match any of the error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1392 * format in 'efm'). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1393 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1394 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1395 qf_parse_line_nomatch(char_u *linebuf, int linelen, qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1396 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1397 fields->namebuf[0] = NUL; // no match found, remove file name |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1398 fields->lnum = 0; // don't jump to this line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1399 fields->valid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1400 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1401 return copy_nonerror_line(linebuf, linelen, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1402 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1403 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1404 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1405 * Parse multi-line error format prefixes (%C and %Z) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1406 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1407 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1408 qf_parse_multiline_pfx( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1409 int idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1410 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1411 qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1412 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1413 char_u *ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1414 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1415 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1416 if (!qfl->qf_multiignore) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1417 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1418 qfline_T *qfprev = qfl->qf_last; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1419 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1420 if (qfprev == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1421 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1422 if (*fields->errmsg && !qfl->qf_multiignore) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1423 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1424 len = (int)STRLEN(qfprev->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1425 ptr = alloc_id(len + STRLEN(fields->errmsg) + 2, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1426 aid_qf_multiline_pfx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1427 if (ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1428 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1429 STRCPY(ptr, qfprev->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1430 vim_free(qfprev->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1431 qfprev->qf_text = ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1432 *(ptr += len) = '\n'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1433 STRCPY(++ptr, fields->errmsg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1434 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1435 if (qfprev->qf_nr == -1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1436 qfprev->qf_nr = fields->enr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1437 if (vim_isprintc(fields->type) && !qfprev->qf_type) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1438 // only printable chars allowed |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1439 qfprev->qf_type = fields->type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1440 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1441 if (!qfprev->qf_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1442 qfprev->qf_lnum = fields->lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1443 if (!qfprev->qf_end_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1444 qfprev->qf_end_lnum = fields->end_lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1445 if (!qfprev->qf_col) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1446 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1447 qfprev->qf_col = fields->col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1448 qfprev->qf_viscol = fields->use_viscol; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1449 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1450 if (!qfprev->qf_end_col) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1451 qfprev->qf_end_col = fields->end_col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1452 if (!qfprev->qf_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1453 qfprev->qf_fnum = qf_get_fnum(qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1454 qfl->qf_directory, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1455 *fields->namebuf || qfl->qf_directory != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1456 ? fields->namebuf |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1457 : qfl->qf_currfile != NULL && fields->valid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1458 ? qfl->qf_currfile : 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1459 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1460 if (idx == 'Z') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1461 qfl->qf_multiline = qfl->qf_multiignore = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1462 line_breakcheck(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1463 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1464 return QF_IGNORE_LINE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1465 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1466 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1467 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1468 * Parse a line and get the quickfix fields. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1469 * Return the QF_ status. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1470 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1471 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1472 qf_parse_line( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1473 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1474 char_u *linebuf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1475 int linelen, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1476 efm_T *fmt_first, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1477 qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1478 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1479 efm_T *fmt_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1480 int idx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1481 char_u *tail = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1482 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1483 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1484 restofline: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1485 // If there was no %> item start at the first pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1486 if (fmt_start == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1487 fmt_ptr = fmt_first; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1488 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1489 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1490 // Otherwise start from the last used pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1491 fmt_ptr = fmt_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1492 fmt_start = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1493 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1494 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1495 // Try to match each part of 'errorformat' until we find a complete |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1496 // match or no match. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1497 fields->valid = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1498 for ( ; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1499 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1500 idx = fmt_ptr->prefix; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1501 status = qf_parse_get_fields(linebuf, linelen, fmt_ptr, fields, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1502 qfl->qf_multiline, qfl->qf_multiscan, &tail); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1503 if (status == QF_NOMEM) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1504 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1505 if (status == QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1506 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1507 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1508 qfl->qf_multiscan = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1509 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1510 if (fmt_ptr == NULL || idx == 'D' || idx == 'X') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1511 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1512 if (fmt_ptr != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1513 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1514 // 'D' and 'X' directory specifiers |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1515 status = qf_parse_dir_pfx(idx, fields, qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1516 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1517 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1518 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1519 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1520 status = qf_parse_line_nomatch(linebuf, linelen, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1521 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1522 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1523 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1524 if (fmt_ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1525 qfl->qf_multiline = qfl->qf_multiignore = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1526 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1527 else if (fmt_ptr != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1528 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1529 // honor %> item |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1530 if (fmt_ptr->conthere) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1531 fmt_start = fmt_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1532 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1533 if (vim_strchr((char_u *)"AEWIN", idx) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1534 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1535 qfl->qf_multiline = TRUE; // start of a multi-line message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1536 qfl->qf_multiignore = FALSE;// reset continuation |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1537 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1538 else if (vim_strchr((char_u *)"CZ", idx) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1539 { // continuation of multi-line msg |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1540 status = qf_parse_multiline_pfx(idx, qfl, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1541 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1542 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1543 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1544 else if (vim_strchr((char_u *)"OPQ", idx) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1545 { // global file names |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1546 status = qf_parse_file_pfx(idx, fields, qfl, tail); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1547 if (status == QF_MULTISCAN) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1548 goto restofline; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1549 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1550 if (fmt_ptr->flags == '-') // generally exclude this line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1551 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1552 if (qfl->qf_multiline) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1553 // also exclude continuation lines |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1554 qfl->qf_multiignore = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1555 return QF_IGNORE_LINE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1556 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1557 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1558 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1559 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1560 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1561 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1562 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1563 * Returns TRUE if the specified quickfix/location stack is empty |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1564 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1565 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1566 qf_stack_empty(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1567 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1568 return qi == NULL || qi->qf_listcount <= 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1569 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1570 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1571 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1572 * Returns TRUE if the specified quickfix/location list is empty. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1573 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1574 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1575 qf_list_empty(qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1576 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1577 return qfl == NULL || qfl->qf_count <= 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1578 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1579 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1580 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1581 * Returns TRUE if the specified quickfix/location list is not empty and |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1582 * has valid entries. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1583 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1584 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1585 qf_list_has_valid_entries(qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1586 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1587 return !qf_list_empty(qfl) && !qfl->qf_nonevalid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1588 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1589 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1590 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1591 * Return a pointer to a list in the specified quickfix stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1592 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1593 static qf_list_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1594 qf_get_list(qf_info_T *qi, int idx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1595 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1596 return &qi->qf_lists[idx]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1597 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1598 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1599 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1600 * Allocate the fields used for parsing lines and populating a quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1601 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1602 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1603 qf_alloc_fields(qffields_T *pfields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1604 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1605 pfields->namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1606 pfields->module = alloc_id(CMDBUFFSIZE + 1, aid_qf_module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1607 pfields->errmsglen = CMDBUFFSIZE + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1608 pfields->errmsg = alloc_id(pfields->errmsglen, aid_qf_errmsg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1609 pfields->pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1610 if (pfields->namebuf == NULL || pfields->errmsg == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1611 || pfields->pattern == NULL || pfields->module == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1612 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1613 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1614 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1615 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1616 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1617 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1618 * Free the fields used for parsing lines and populating a quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1619 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1620 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1621 qf_free_fields(qffields_T *pfields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1622 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1623 vim_free(pfields->namebuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1624 vim_free(pfields->module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1625 vim_free(pfields->errmsg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1626 vim_free(pfields->pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1627 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1628 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1629 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1630 * Setup the state information used for parsing lines and populating a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1631 * quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1632 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1633 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1634 qf_setup_state( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1635 qfstate_T *pstate, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1636 char_u *enc, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1637 char_u *efile, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1638 typval_T *tv, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1639 buf_T *buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1640 linenr_T lnumfirst, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1641 linenr_T lnumlast) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1642 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1643 pstate->vc.vc_type = CONV_NONE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1644 if (enc != NULL && *enc != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1645 convert_setup(&pstate->vc, enc, p_enc); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1646 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1647 if (efile != NULL && (pstate->fd = mch_fopen((char *)efile, "r")) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1648 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1649 semsg(_(e_cant_open_errorfile_str), efile); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1650 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1651 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1652 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1653 if (tv != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1654 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1655 if (tv->v_type == VAR_STRING) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1656 pstate->p_str = tv->vval.v_string; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1657 else if (tv->v_type == VAR_LIST) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1658 pstate->p_li = tv->vval.v_list->lv_first; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1659 pstate->tv = tv; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1660 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1661 pstate->buf = buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1662 pstate->buflnum = lnumfirst; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1663 pstate->lnumlast = lnumlast; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1664 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1665 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1666 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1667 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1668 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1669 * Cleanup the state information used for parsing lines and populating a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1670 * quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1671 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1672 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1673 qf_cleanup_state(qfstate_T *pstate) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1674 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1675 if (pstate->fd != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1676 fclose(pstate->fd); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1677 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1678 vim_free(pstate->growbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1679 if (pstate->vc.vc_type != CONV_NONE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1680 convert_setup(&pstate->vc, NULL, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1681 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1682 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1683 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1684 * Process the next line from a file/buffer/list/string and add it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1685 * to the quickfix list 'qfl'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1686 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1687 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1688 qf_init_process_nextline( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1689 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1690 efm_T *fmt_first, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1691 qfstate_T *state, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1692 qffields_T *fields) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1693 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1694 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1695 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1696 // Get the next line from a file/buffer/list/string |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1697 status = qf_get_nextline(state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1698 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1699 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1700 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1701 status = qf_parse_line(qfl, state->linebuf, state->linelen, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1702 fmt_first, fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1703 if (status != QF_OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1704 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1705 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1706 return qf_add_entry(qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1707 qfl->qf_directory, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1708 (*fields->namebuf || qfl->qf_directory != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1709 ? fields->namebuf |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1710 : ((qfl->qf_currfile != NULL && fields->valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1711 ? qfl->qf_currfile : (char_u *)NULL), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1712 fields->module, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1713 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1714 fields->errmsg, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1715 fields->lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1716 fields->end_lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1717 fields->col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1718 fields->end_col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1719 fields->use_viscol, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1720 fields->pattern, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1721 fields->enr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1722 fields->type, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1723 fields->valid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1724 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1725 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1726 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1727 * Read the errorfile "efile" into memory, line by line, building the error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1728 * list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1729 * Alternative: when "efile" is NULL read errors from buffer "buf". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1730 * Alternative: when "tv" is not NULL get errors from the string or list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1731 * Always use 'errorformat' from "buf" if there is a local value. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1732 * Then "lnumfirst" and "lnumlast" specify the range of lines to use. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1733 * Set the title of the list to "qf_title". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1734 * Return -1 for error, number of errors for success. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1735 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1736 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1737 qf_init_ext( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1738 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1739 int qf_idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1740 char_u *efile, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1741 buf_T *buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1742 typval_T *tv, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1743 char_u *errorformat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1744 int newlist, // TRUE: start a new error list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1745 linenr_T lnumfirst, // first line number to use |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1746 linenr_T lnumlast, // last line number to use |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1747 char_u *qf_title, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1748 char_u *enc) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1749 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1750 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1751 qfstate_T state; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1752 qffields_T fields; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1753 qfline_T *old_last = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1754 int adding = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1755 static efm_T *fmt_first = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1756 char_u *efm; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1757 static char_u *last_efm = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1758 int retval = -1; // default: return error flag |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1759 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1760 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1761 // Do not used the cached buffer, it may have been wiped out. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1762 VIM_CLEAR(qf_last_bufname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1763 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1764 CLEAR_FIELD(state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1765 CLEAR_FIELD(fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1766 if ((qf_alloc_fields(&fields) == FAIL) || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1767 (qf_setup_state(&state, enc, efile, tv, buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1768 lnumfirst, lnumlast) == FAIL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1769 goto qf_init_end; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1770 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1771 if (newlist || qf_idx == qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1772 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1773 // make place for a new list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1774 qf_new_list(qi, qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1775 qf_idx = qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1776 qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1777 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1778 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1779 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1780 // Adding to existing list, use last entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1781 adding = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1782 qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1783 if (!qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1784 old_last = qfl->qf_last; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1785 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1786 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1787 // Use the local value of 'errorformat' if it's set. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1788 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1789 efm = buf->b_p_efm; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1790 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1791 efm = errorformat; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1792 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1793 // If the errorformat didn't change between calls, then reuse the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1794 // previously parsed values. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1795 if (last_efm == NULL || (STRCMP(last_efm, efm) != 0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1796 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1797 // free the previously parsed data |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1798 VIM_CLEAR(last_efm); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1799 free_efm_list(&fmt_first); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1800 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1801 // parse the current 'efm' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1802 fmt_first = parse_efm_option(efm); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1803 if (fmt_first != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1804 last_efm = vim_strsave(efm); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1805 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1806 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1807 if (fmt_first == NULL) // nothing found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1808 goto error2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1809 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1810 // got_int is reset here, because it was probably set when killing the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1811 // ":make" command, but we still want to read the errorfile then. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1812 got_int = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1813 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1814 // Read the lines in the error file one by one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1815 // Try to recognize one of the error formats in each line. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1816 while (!got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1817 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1818 status = qf_init_process_nextline(qfl, fmt_first, &state, &fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1819 if (status == QF_NOMEM) // memory alloc failure |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1820 goto qf_init_end; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1821 if (status == QF_END_OF_INPUT) // end of input |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1822 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1823 if (status == QF_FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1824 goto error2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1825 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1826 line_breakcheck(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1827 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1828 if (state.fd == NULL || !ferror(state.fd)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1829 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1830 if (qfl->qf_index == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1831 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1832 // no valid entry found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1833 qfl->qf_ptr = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1834 qfl->qf_index = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1835 qfl->qf_nonevalid = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1836 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1837 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1838 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1839 qfl->qf_nonevalid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1840 if (qfl->qf_ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1841 qfl->qf_ptr = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1842 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1843 // return number of matches |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1844 retval = qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1845 goto qf_init_end; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1846 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1847 emsg(_(e_error_while_reading_errorfile)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1848 error2: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1849 if (!adding) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1850 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1851 // Error when creating a new list. Free the new list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1852 qf_free(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1853 qi->qf_listcount--; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1854 if (qi->qf_curlist > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1855 --qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1856 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1857 qf_init_end: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1858 if (qf_idx == qi->qf_curlist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1859 qf_update_buffer(qi, old_last); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1860 qf_cleanup_state(&state); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1861 qf_free_fields(&fields); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1862 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1863 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1864 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1865 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1866 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1867 * Read the errorfile "efile" into memory, line by line, building the error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1868 * list. Set the error list's title to qf_title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1869 * Return -1 for error, number of errors for success. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1870 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1871 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1872 qf_init(win_T *wp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1873 char_u *efile, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1874 char_u *errorformat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1875 int newlist, // TRUE: start a new error list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1876 char_u *qf_title, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1877 char_u *enc) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1878 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1879 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1880 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1881 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1882 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1883 qi = ll_get_or_alloc_list(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1884 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1885 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1886 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1887 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1888 return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1889 newlist, (linenr_T)0, (linenr_T)0, qf_title, enc); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1890 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1891 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1892 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1893 * Set the title of the specified quickfix list. Frees the previous title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1894 * Prepends ':' to the title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1895 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1896 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1897 qf_store_title(qf_list_T *qfl, char_u *title) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1898 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1899 VIM_CLEAR(qfl->qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1900 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1901 if (title == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1902 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1903 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1904 char_u *p = alloc_id(STRLEN(title) + 2, aid_qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1905 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1906 qfl->qf_title = p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1907 if (p != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1908 STRCPY(p, title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1909 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1910 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1911 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1912 * The title of a quickfix/location list is set, by default, to the command |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1913 * that created the quickfix list with the ":" prefix. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1914 * Create a quickfix list title string by prepending ":" to a user command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1915 * Returns a pointer to a static buffer with the title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1916 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1917 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1918 qf_cmdtitle(char_u *cmd) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1919 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1920 static char_u qftitle_str[IOSIZE]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1921 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1922 vim_snprintf((char *)qftitle_str, IOSIZE, ":%s", (char *)cmd); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1923 return qftitle_str; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1924 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1925 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1926 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1927 * Return a pointer to the current list in the specified quickfix stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1928 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1929 static qf_list_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1930 qf_get_curlist(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1931 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1932 return qf_get_list(qi, qi->qf_curlist); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1933 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1934 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1935 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1936 * Prepare for adding a new quickfix list. If the current list is in the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1937 * middle of the stack, then all the following lists are freed and then |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1938 * the new list is added. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1939 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1940 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1941 qf_new_list(qf_info_T *qi, char_u *qf_title) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1942 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1943 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1944 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1945 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1946 // If the current entry is not the last entry, delete entries beyond |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1947 // the current entry. This makes it possible to browse in a tree-like |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1948 // way with ":grep". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1949 while (qi->qf_listcount > qi->qf_curlist + 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1950 qf_free(&qi->qf_lists[--qi->qf_listcount]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1951 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1952 // When the stack is full, remove to oldest entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1953 // Otherwise, add a new entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1954 if (qi->qf_listcount == LISTCOUNT) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1955 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1956 qf_free(&qi->qf_lists[0]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1957 for (i = 1; i < LISTCOUNT; ++i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1958 qi->qf_lists[i - 1] = qi->qf_lists[i]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1959 qi->qf_curlist = LISTCOUNT - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1960 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1961 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1962 qi->qf_curlist = qi->qf_listcount++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1963 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1964 CLEAR_POINTER(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1965 qf_store_title(qfl, qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1966 qfl->qfl_type = qi->qfl_type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1967 qfl->qf_id = ++last_qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1968 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1969 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1970 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1971 * Queue location list stack delete request. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1972 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1973 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1974 locstack_queue_delreq(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1975 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1976 qf_delq_T *q; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1977 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1978 q = ALLOC_ONE(qf_delq_T); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1979 if (q == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1980 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1981 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1982 q->qi = qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1983 q->next = qf_delq_head; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1984 qf_delq_head = q; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1985 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1986 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1987 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1988 * Return the global quickfix stack window buffer number. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1989 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1990 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1991 qf_stack_get_bufnr(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1992 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1993 return ql_info.qf_bufnr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1994 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1995 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1996 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1997 * Wipe the quickfix window buffer (if present) for the specified |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1998 * quickfix/location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
1999 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2000 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2001 wipe_qf_buffer(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2002 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2003 buf_T *qfbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2004 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2005 if (qi->qf_bufnr == INVALID_QFBUFNR) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2006 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2007 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2008 qfbuf = buflist_findnr(qi->qf_bufnr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2009 if (qfbuf != NULL && qfbuf->b_nwindows == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2010 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2011 // If the quickfix buffer is not loaded in any window, then |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2012 // wipe the buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2013 close_buffer(NULL, qfbuf, DOBUF_WIPE, FALSE, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2014 qi->qf_bufnr = INVALID_QFBUFNR; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2015 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2016 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2017 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2018 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2019 * Free a location list stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2020 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2021 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2022 ll_free_all(qf_info_T **pqi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2023 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2024 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2025 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2026 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2027 qi = *pqi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2028 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2029 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2030 *pqi = NULL; // Remove reference to this list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2031 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2032 // If the location list is still in use, then queue the delete request |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2033 // to be processed later. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2034 if (quickfix_busy > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2035 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2036 locstack_queue_delreq(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2037 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2038 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2039 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2040 qi->qf_refcount--; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2041 if (qi->qf_refcount < 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2042 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2043 // No references to this location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2044 // If the quickfix window buffer is loaded, then wipe it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2045 wipe_qf_buffer(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2046 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2047 for (i = 0; i < qi->qf_listcount; ++i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2048 qf_free(qf_get_list(qi, i)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2049 vim_free(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2050 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2051 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2052 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2053 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2054 * Free all the quickfix/location lists in the stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2055 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2056 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2057 qf_free_all(win_T *wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2058 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2059 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2060 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2061 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2062 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2063 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2064 // location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2065 ll_free_all(&wp->w_llist); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2066 ll_free_all(&wp->w_llist_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2067 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2068 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2069 // quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2070 for (i = 0; i < qi->qf_listcount; ++i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2071 qf_free(qf_get_list(qi, i)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2072 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2073 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2074 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2075 * Delay freeing of location list stacks when the quickfix code is running. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2076 * Used to avoid problems with autocmds freeing location list stacks when the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2077 * quickfix code is still referencing the stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2078 * Must always call decr_quickfix_busy() exactly once after this. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2079 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2080 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2081 incr_quickfix_busy(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2082 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2083 quickfix_busy++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2084 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2085 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2086 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2087 * Safe to free location list stacks. Process any delayed delete requests. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2088 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2089 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2090 decr_quickfix_busy(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2091 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2092 if (--quickfix_busy == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2093 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2094 // No longer referencing the location lists. Process all the pending |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2095 // delete requests. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2096 while (qf_delq_head != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2097 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2098 qf_delq_T *q = qf_delq_head; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2099 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2100 qf_delq_head = q->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2101 ll_free_all(&q->qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2102 vim_free(q); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2103 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2104 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2105 #ifdef ABORT_ON_INTERNAL_ERROR |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2106 if (quickfix_busy < 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2107 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2108 emsg("quickfix_busy has become negative"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2109 abort(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2110 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2111 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2112 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2113 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2114 #if defined(EXITFREE) || defined(PROTO) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2115 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2116 check_quickfix_busy(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2117 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2118 if (quickfix_busy != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2119 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2120 semsg("quickfix_busy not zero on exit: %ld", (long)quickfix_busy); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2121 # ifdef ABORT_ON_INTERNAL_ERROR |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2122 abort(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2123 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2124 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2125 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2126 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2127 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2128 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2129 * Add an entry to the end of the list of errors. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2130 * Returns QF_OK on success or QF_FAIL on a memory allocation failure. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2131 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2132 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2133 qf_add_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2134 qf_list_T *qfl, // quickfix list entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2135 char_u *dir, // optional directory name |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2136 char_u *fname, // file name or NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2137 char_u *module, // module name or NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2138 int bufnum, // buffer number or zero |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2139 char_u *mesg, // message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2140 long lnum, // line number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2141 long end_lnum, // line number for end |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2142 int col, // column |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2143 int end_col, // column for end |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2144 int vis_col, // using visual column |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2145 char_u *pattern, // search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2146 int nr, // error number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2147 int type, // type character |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2148 int valid) // valid entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2149 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2150 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2151 qfline_T **lastp; // pointer to qf_last or NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2152 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2153 if ((qfp = ALLOC_ONE_ID(qfline_T, aid_qf_qfline)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2154 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2155 if (bufnum != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2156 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2157 buf_T *buf = buflist_findnr(bufnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2158 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2159 qfp->qf_fnum = bufnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2160 if (buf != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2161 buf->b_has_qf_entry |= |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2162 IS_QF_LIST(qfl) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2163 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2164 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2165 qfp->qf_fnum = qf_get_fnum(qfl, dir, fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2166 if ((qfp->qf_text = vim_strsave(mesg)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2167 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2168 vim_free(qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2169 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2170 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2171 qfp->qf_lnum = lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2172 qfp->qf_end_lnum = end_lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2173 qfp->qf_col = col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2174 qfp->qf_end_col = end_col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2175 qfp->qf_viscol = vis_col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2176 if (pattern == NULL || *pattern == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2177 qfp->qf_pattern = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2178 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2179 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2180 vim_free(qfp->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2181 vim_free(qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2182 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2183 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2184 if (module == NULL || *module == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2185 qfp->qf_module = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2186 else if ((qfp->qf_module = vim_strsave(module)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2187 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2188 vim_free(qfp->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2189 vim_free(qfp->qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2190 vim_free(qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2191 return QF_FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2192 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2193 qfp->qf_nr = nr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2194 if (type != 1 && !vim_isprintc(type)) // only printable chars allowed |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2195 type = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2196 qfp->qf_type = type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2197 qfp->qf_valid = valid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2198 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2199 lastp = &qfl->qf_last; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2200 if (qf_list_empty(qfl)) // first element in the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2201 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2202 qfl->qf_start = qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2203 qfl->qf_ptr = qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2204 qfl->qf_index = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2205 qfp->qf_prev = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2206 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2207 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2208 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2209 qfp->qf_prev = *lastp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2210 (*lastp)->qf_next = qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2211 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2212 qfp->qf_next = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2213 qfp->qf_cleared = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2214 *lastp = qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2215 ++qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2216 if (qfl->qf_index == 0 && qfp->qf_valid) // first valid entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2217 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2218 qfl->qf_index = qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2219 qfl->qf_ptr = qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2220 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2221 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2222 return QF_OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2223 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2224 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2225 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2226 * Allocate a new quickfix/location list stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2227 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2228 static qf_info_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2229 qf_alloc_stack(qfltype_T qfltype) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2230 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2231 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2232 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2233 qi = ALLOC_CLEAR_ONE_ID(qf_info_T, aid_qf_qfinfo); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2234 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2235 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2236 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2237 qi->qf_refcount++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2238 qi->qfl_type = qfltype; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2239 qi->qf_bufnr = INVALID_QFBUFNR; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2240 return qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2241 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2242 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2243 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2244 * Return the location list stack for window 'wp'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2245 * If not present, allocate a location list stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2246 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2247 static qf_info_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2248 ll_get_or_alloc_list(win_T *wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2249 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2250 if (IS_LL_WINDOW(wp)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2251 // For a location list window, use the referenced location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2252 return wp->w_llist_ref; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2253 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2254 // For a non-location list window, w_llist_ref should not point to a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2255 // location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2256 ll_free_all(&wp->w_llist_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2257 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2258 if (wp->w_llist == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2259 wp->w_llist = qf_alloc_stack(QFLT_LOCATION); // new location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2260 return wp->w_llist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2261 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2262 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2263 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2264 * Get the quickfix/location list stack to use for the specified Ex command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2265 * For a location list command, returns the stack for the current window. If |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2266 * the location list is not found, then returns NULL and prints an error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2267 * message if 'print_emsg' is TRUE. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2268 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2269 static qf_info_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2270 qf_cmd_get_stack(exarg_T *eap, int print_emsg) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2271 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2272 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2273 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2274 if (is_loclist_cmd(eap->cmdidx)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2275 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2276 qi = GET_LOC_LIST(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2277 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2278 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2279 if (print_emsg) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2280 emsg(_(e_no_location_list)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2281 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2282 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2283 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2284 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2285 return qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2286 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2287 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2288 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2289 * Get the quickfix/location list stack to use for the specified Ex command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2290 * For a location list command, returns the stack for the current window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2291 * If the location list is not present, then allocates a new one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2292 * Returns NULL if the allocation fails. For a location list command, sets |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2293 * 'pwinp' to curwin. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2294 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2295 static qf_info_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2296 qf_cmd_get_or_alloc_stack(exarg_T *eap, win_T **pwinp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2297 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2298 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2299 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2300 if (is_loclist_cmd(eap->cmdidx)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2301 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2302 qi = ll_get_or_alloc_list(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2303 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2304 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2305 *pwinp = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2306 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2307 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2308 return qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2309 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2310 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2311 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2312 * Copy location list entries from 'from_qfl' to 'to_qfl'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2313 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2314 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2315 copy_loclist_entries(qf_list_T *from_qfl, qf_list_T *to_qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2316 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2317 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2318 qfline_T *from_qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2319 qfline_T *prevp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2320 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2321 // copy all the location entries in this list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2322 FOR_ALL_QFL_ITEMS(from_qfl, from_qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2323 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2324 if (qf_add_entry(to_qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2325 NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2326 NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2327 from_qfp->qf_module, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2328 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2329 from_qfp->qf_text, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2330 from_qfp->qf_lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2331 from_qfp->qf_end_lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2332 from_qfp->qf_col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2333 from_qfp->qf_end_col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2334 from_qfp->qf_viscol, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2335 from_qfp->qf_pattern, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2336 from_qfp->qf_nr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2337 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2338 from_qfp->qf_valid) == QF_FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2339 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2340 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2341 // qf_add_entry() will not set the qf_num field, as the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2342 // directory and file names are not supplied. So the qf_fnum |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2343 // field is copied here. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2344 prevp = to_qfl->qf_last; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2345 prevp->qf_fnum = from_qfp->qf_fnum; // file number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2346 prevp->qf_type = from_qfp->qf_type; // error type |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2347 if (from_qfl->qf_ptr == from_qfp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2348 to_qfl->qf_ptr = prevp; // current location |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2349 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2350 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2351 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2352 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2353 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2354 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2355 * Copy the specified location list 'from_qfl' to 'to_qfl'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2356 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2357 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2358 copy_loclist(qf_list_T *from_qfl, qf_list_T *to_qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2359 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2360 // Some of the fields are populated by qf_add_entry() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2361 to_qfl->qfl_type = from_qfl->qfl_type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2362 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2363 to_qfl->qf_count = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2364 to_qfl->qf_index = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2365 to_qfl->qf_start = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2366 to_qfl->qf_last = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2367 to_qfl->qf_ptr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2368 if (from_qfl->qf_title != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2369 to_qfl->qf_title = vim_strsave(from_qfl->qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2370 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2371 to_qfl->qf_title = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2372 if (from_qfl->qf_ctx != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2373 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2374 to_qfl->qf_ctx = alloc_tv(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2375 if (to_qfl->qf_ctx != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2376 copy_tv(from_qfl->qf_ctx, to_qfl->qf_ctx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2377 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2378 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2379 to_qfl->qf_ctx = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2380 if (from_qfl->qf_qftf_cb.cb_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2381 copy_callback(&to_qfl->qf_qftf_cb, &from_qfl->qf_qftf_cb); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2382 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2383 to_qfl->qf_qftf_cb.cb_name = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2384 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2385 if (from_qfl->qf_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2386 if (copy_loclist_entries(from_qfl, to_qfl) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2387 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2388 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2389 to_qfl->qf_index = from_qfl->qf_index; // current index in the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2390 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2391 // Assign a new ID for the location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2392 to_qfl->qf_id = ++last_qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2393 to_qfl->qf_changedtick = 0L; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2394 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2395 // When no valid entries are present in the list, qf_ptr points to |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2396 // the first item in the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2397 if (to_qfl->qf_nonevalid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2398 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2399 to_qfl->qf_ptr = to_qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2400 to_qfl->qf_index = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2401 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2402 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2403 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2404 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2405 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2406 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2407 * Copy the location list stack 'from' window to 'to' window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2408 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2409 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2410 copy_loclist_stack(win_T *from, win_T *to) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2411 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2412 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2413 int idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2414 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2415 // When copying from a location list window, copy the referenced |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2416 // location list. For other windows, copy the location list for |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2417 // that window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2418 if (IS_LL_WINDOW(from)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2419 qi = from->w_llist_ref; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2420 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2421 qi = from->w_llist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2422 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2423 if (qi == NULL) // no location list to copy |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2424 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2425 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2426 // allocate a new location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2427 if ((to->w_llist = qf_alloc_stack(QFLT_LOCATION)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2428 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2429 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2430 to->w_llist->qf_listcount = qi->qf_listcount; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2431 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2432 // Copy the location lists one at a time |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2433 for (idx = 0; idx < qi->qf_listcount; ++idx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2434 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2435 to->w_llist->qf_curlist = idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2436 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2437 if (copy_loclist(qf_get_list(qi, idx), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2438 qf_get_list(to->w_llist, idx)) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2439 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2440 qf_free_all(to); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2441 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2442 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2443 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2444 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2445 to->w_llist->qf_curlist = qi->qf_curlist; // current list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2446 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2447 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2448 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2449 * Get buffer number for file "directory/fname". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2450 * Also sets the b_has_qf_entry flag. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2451 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2452 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2453 qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2454 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2455 char_u *ptr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2456 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2457 char_u *bufname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2458 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2459 if (fname == NULL || *fname == NUL) // no file name |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2460 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2461 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2462 #ifdef VMS |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2463 vms_remove_version(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2464 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2465 #ifdef BACKSLASH_IN_FILENAME |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2466 if (directory != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2467 slash_adjust(directory); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2468 slash_adjust(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2469 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2470 if (directory != NULL && !vim_isAbsName(fname) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2471 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2472 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2473 // Here we check if the file really exists. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2474 // This should normally be true, but if make works without |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2475 // "leaving directory"-messages we might have missed a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2476 // directory change. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2477 if (mch_getperm(ptr) < 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2478 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2479 vim_free(ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2480 directory = qf_guess_filepath(qfl, fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2481 if (directory) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2482 ptr = concat_fnames(directory, fname, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2483 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2484 ptr = vim_strsave(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2485 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2486 // Use concatenated directory name and file name |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2487 bufname = ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2488 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2489 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2490 bufname = fname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2491 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2492 if (qf_last_bufname != NULL && STRCMP(bufname, qf_last_bufname) == 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2493 && bufref_valid(&qf_last_bufref)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2494 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2495 buf = qf_last_bufref.br_buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2496 vim_free(ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2497 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2498 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2499 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2500 vim_free(qf_last_bufname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2501 buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2502 if (bufname == ptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2503 qf_last_bufname = bufname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2504 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2505 qf_last_bufname = vim_strsave(bufname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2506 set_bufref(&qf_last_bufref, buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2507 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2508 if (buf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2509 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2510 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2511 buf->b_has_qf_entry = |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2512 IS_QF_LIST(qfl) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2513 return buf->b_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2514 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2515 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2516 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2517 * Push dirbuf onto the directory stack and return pointer to actual dir or |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2518 * NULL on error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2519 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2520 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2521 qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2522 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2523 struct dir_stack_T *ds_new; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2524 struct dir_stack_T *ds_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2525 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2526 // allocate new stack element and hook it in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2527 ds_new = ALLOC_ONE_ID(struct dir_stack_T, aid_qf_dirstack); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2528 if (ds_new == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2529 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2530 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2531 ds_new->next = *stackptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2532 *stackptr = ds_new; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2533 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2534 // store directory on the stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2535 if (vim_isAbsName(dirbuf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2536 || (*stackptr)->next == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2537 || is_file_stack) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2538 (*stackptr)->dirname = vim_strsave(dirbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2539 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2540 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2541 // Okay we don't have an absolute path. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2542 // dirbuf must be a subdir of one of the directories on the stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2543 // Let's search... |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2544 ds_new = (*stackptr)->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2545 (*stackptr)->dirname = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2546 while (ds_new) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2547 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2548 vim_free((*stackptr)->dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2549 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2550 TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2551 if (mch_isdir((*stackptr)->dirname) == TRUE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2552 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2553 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2554 ds_new = ds_new->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2555 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2556 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2557 // clean up all dirs we already left |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2558 while ((*stackptr)->next != ds_new) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2559 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2560 ds_ptr = (*stackptr)->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2561 (*stackptr)->next = (*stackptr)->next->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2562 vim_free(ds_ptr->dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2563 vim_free(ds_ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2564 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2565 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2566 // Nothing found -> it must be on top level |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2567 if (ds_new == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2568 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2569 vim_free((*stackptr)->dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2570 (*stackptr)->dirname = vim_strsave(dirbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2571 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2572 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2573 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2574 if ((*stackptr)->dirname != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2575 return (*stackptr)->dirname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2576 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2577 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2578 ds_ptr = *stackptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2579 *stackptr = (*stackptr)->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2580 vim_free(ds_ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2581 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2582 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2583 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2584 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2585 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2586 * pop dirbuf from the directory stack and return previous directory or NULL if |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2587 * stack is empty |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2588 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2589 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2590 qf_pop_dir(struct dir_stack_T **stackptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2591 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2592 struct dir_stack_T *ds_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2593 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2594 // TODO: Should we check if dirbuf is the directory on top of the stack? |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2595 // What to do if it isn't? |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2596 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2597 // pop top element and free it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2598 if (*stackptr != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2599 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2600 ds_ptr = *stackptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2601 *stackptr = (*stackptr)->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2602 vim_free(ds_ptr->dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2603 vim_free(ds_ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2604 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2605 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2606 // return NEW top element as current dir or NULL if stack is empty |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2607 return *stackptr ? (*stackptr)->dirname : NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2608 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2609 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2610 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2611 * clean up directory stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2612 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2613 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2614 qf_clean_dir_stack(struct dir_stack_T **stackptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2615 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2616 struct dir_stack_T *ds_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2617 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2618 while ((ds_ptr = *stackptr) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2619 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2620 *stackptr = (*stackptr)->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2621 vim_free(ds_ptr->dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2622 vim_free(ds_ptr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2623 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2624 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2625 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2626 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2627 * Check in which directory of the directory stack the given file can be |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2628 * found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2629 * Returns a pointer to the directory name or NULL if not found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2630 * Cleans up intermediate directory entries. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2631 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2632 * TODO: How to solve the following problem? |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2633 * If we have this directory tree: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2634 * ./ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2635 * ./aa |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2636 * ./aa/bb |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2637 * ./bb |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2638 * ./bb/x.c |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2639 * and make says: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2640 * making all in aa |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2641 * making all in bb |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2642 * x.c:9: Error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2643 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2644 * qf_guess_filepath will return NULL. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2645 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2646 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2647 qf_guess_filepath(qf_list_T *qfl, char_u *filename) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2648 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2649 struct dir_stack_T *ds_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2650 struct dir_stack_T *ds_tmp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2651 char_u *fullname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2652 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2653 // no dirs on the stack - there's nothing we can do |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2654 if (qfl->qf_dir_stack == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2655 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2656 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2657 ds_ptr = qfl->qf_dir_stack->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2658 fullname = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2659 while (ds_ptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2660 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2661 vim_free(fullname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2662 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2663 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2664 // If concat_fnames failed, just go on. The worst thing that can happen |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2665 // is that we delete the entire stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2666 if ((fullname != NULL) && (mch_getperm(fullname) >= 0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2667 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2668 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2669 ds_ptr = ds_ptr->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2670 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2671 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2672 vim_free(fullname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2673 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2674 // clean up all dirs we already left |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2675 while (qfl->qf_dir_stack->next != ds_ptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2676 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2677 ds_tmp = qfl->qf_dir_stack->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2678 qfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2679 vim_free(ds_tmp->dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2680 vim_free(ds_tmp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2681 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2682 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2683 return ds_ptr == NULL ? NULL : ds_ptr->dirname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2684 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2685 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2686 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2687 * Returns TRUE if a quickfix/location list with the given identifier exists. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2688 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2689 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2690 qflist_valid(win_T *wp, int_u qf_id) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2691 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2692 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2693 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2694 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2695 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2696 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2697 if (!win_valid(wp)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2698 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2699 qi = GET_LOC_LIST(wp); // Location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2700 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2701 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2702 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2703 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2704 for (i = 0; i < qi->qf_listcount; ++i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2705 if (qi->qf_lists[i].qf_id == qf_id) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2706 return TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2707 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2708 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2709 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2710 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2711 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2712 * When loading a file from the quickfix, the autocommands may modify it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2713 * This may invalidate the current quickfix entry. This function checks |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2714 * whether an entry is still present in the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2715 * Similar to location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2716 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2717 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2718 is_qf_entry_present(qf_list_T *qfl, qfline_T *qf_ptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2719 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2720 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2721 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2722 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2723 // Search for the entry in the current list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2724 FOR_ALL_QFL_ITEMS(qfl, qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2725 if (qfp == qf_ptr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2726 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2727 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2728 if (i > qfl->qf_count) // Entry is not found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2729 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2730 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2731 return TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2732 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2733 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2734 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2735 * Get the next valid entry in the current quickfix/location list. The search |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2736 * starts from the current entry. Returns NULL on failure. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2737 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2738 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2739 get_next_valid_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2740 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2741 qfline_T *qf_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2742 int *qf_index, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2743 int dir) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2744 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2745 int idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2746 int old_qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2747 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2748 idx = *qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2749 old_qf_fnum = qf_ptr->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2750 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2751 do |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2752 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2753 if (idx == qfl->qf_count || qf_ptr->qf_next == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2754 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2755 ++idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2756 qf_ptr = qf_ptr->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2757 } while ((!qfl->qf_nonevalid && !qf_ptr->qf_valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2758 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2759 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2760 *qf_index = idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2761 return qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2762 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2763 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2764 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2765 * Get the previous valid entry in the current quickfix/location list. The |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2766 * search starts from the current entry. Returns NULL on failure. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2767 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2768 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2769 get_prev_valid_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2770 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2771 qfline_T *qf_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2772 int *qf_index, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2773 int dir) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2774 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2775 int idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2776 int old_qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2777 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2778 idx = *qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2779 old_qf_fnum = qf_ptr->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2780 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2781 do |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2782 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2783 if (idx == 1 || qf_ptr->qf_prev == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2784 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2785 --idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2786 qf_ptr = qf_ptr->qf_prev; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2787 } while ((!qfl->qf_nonevalid && !qf_ptr->qf_valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2788 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2789 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2790 *qf_index = idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2791 return qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2792 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2793 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2794 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2795 * Get the n'th (errornr) previous/next valid entry from the current entry in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2796 * the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2797 * dir == FORWARD or FORWARD_FILE: next valid entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2798 * dir == BACKWARD or BACKWARD_FILE: previous valid entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2799 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2800 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2801 get_nth_valid_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2802 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2803 int errornr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2804 int dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2805 int *new_qfidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2806 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2807 qfline_T *qf_ptr = qfl->qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2808 int qf_idx = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2809 qfline_T *prev_qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2810 int prev_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2811 char *err = e_no_more_items; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2812 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2813 while (errornr--) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2814 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2815 prev_qf_ptr = qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2816 prev_index = qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2817 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2818 if (dir == FORWARD || dir == FORWARD_FILE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2819 qf_ptr = get_next_valid_entry(qfl, qf_ptr, &qf_idx, dir); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2820 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2821 qf_ptr = get_prev_valid_entry(qfl, qf_ptr, &qf_idx, dir); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2822 if (qf_ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2823 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2824 qf_ptr = prev_qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2825 qf_idx = prev_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2826 if (err != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2827 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2828 emsg(_(err)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2829 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2830 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2831 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2832 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2833 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2834 err = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2835 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2836 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2837 *new_qfidx = qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2838 return qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2839 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2840 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2841 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2842 * Get n'th (errornr) quickfix entry from the current entry in the quickfix |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2843 * list 'qfl'. Returns a pointer to the new entry and the index in 'new_qfidx' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2844 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2845 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2846 get_nth_entry(qf_list_T *qfl, int errornr, int *new_qfidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2847 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2848 qfline_T *qf_ptr = qfl->qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2849 int qf_idx = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2850 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2851 // New error number is less than the current error number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2852 while (errornr < qf_idx && qf_idx > 1 && qf_ptr->qf_prev != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2853 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2854 --qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2855 qf_ptr = qf_ptr->qf_prev; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2856 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2857 // New error number is greater than the current error number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2858 while (errornr > qf_idx && qf_idx < qfl->qf_count && |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2859 qf_ptr->qf_next != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2860 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2861 ++qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2862 qf_ptr = qf_ptr->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2863 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2864 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2865 *new_qfidx = qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2866 return qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2867 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2868 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2869 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2870 * Get a entry specified by 'errornr' and 'dir' from the current |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2871 * quickfix/location list. 'errornr' specifies the index of the entry and 'dir' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2872 * specifies the direction (FORWARD/BACKWARD/FORWARD_FILE/BACKWARD_FILE). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2873 * Returns a pointer to the entry and the index of the new entry is stored in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2874 * 'new_qfidx'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2875 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2876 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2877 qf_get_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2878 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2879 int errornr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2880 int dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2881 int *new_qfidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2882 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2883 qfline_T *qf_ptr = qfl->qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2884 int qfidx = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2885 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2886 if (dir != 0) // next/prev valid entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2887 qf_ptr = get_nth_valid_entry(qfl, errornr, dir, &qfidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2888 else if (errornr != 0) // go to specified number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2889 qf_ptr = get_nth_entry(qfl, errornr, &qfidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2890 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2891 *new_qfidx = qfidx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2892 return qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2893 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2894 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2895 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2896 * Find a window displaying a Vim help file in the current tab page. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2897 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2898 static win_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2899 qf_find_help_win(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2900 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2901 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2902 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2903 FOR_ALL_WINDOWS(wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2904 if (bt_help(wp->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2905 return wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2906 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2907 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2908 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2909 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2910 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2911 * Set the location list for the specified window to 'qi'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2912 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2913 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2914 win_set_loclist(win_T *wp, qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2915 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2916 wp->w_llist = qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2917 qi->qf_refcount++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2918 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2919 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2920 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2921 * Find a help window or open one. If 'newwin' is TRUE, then open a new help |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2922 * window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2923 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2924 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2925 jump_to_help_window(qf_info_T *qi, int newwin, int *opened_window) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2926 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2927 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2928 int flags; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2929 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2930 if (cmdmod.cmod_tab != 0 || newwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2931 wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2932 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2933 wp = qf_find_help_win(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2934 if (wp != NULL && wp->w_buffer->b_nwindows > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2935 win_enter(wp, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2936 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2937 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2938 // Split off help window; put it at far top if no position |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2939 // specified, the current window is vertically split and narrow. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2940 flags = WSP_HELP; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2941 if (cmdmod.cmod_split == 0 && curwin->w_width != Columns |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2942 && curwin->w_width < 80) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2943 flags |= WSP_TOP; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2944 // If the user asks to open a new window, then copy the location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2945 // Otherwise, don't copy the location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2946 if (IS_LL_STACK(qi) && !newwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2947 flags |= WSP_NEWLOC; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2948 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2949 if (win_split(0, flags) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2950 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2951 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2952 *opened_window = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2953 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2954 if (curwin->w_height < p_hh) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2955 win_setheight((int)p_hh); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2956 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2957 // When using location list, the new window should use the supplied |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2958 // location list. If the user asks to open a new window, then the new |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2959 // window will get a copy of the location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2960 if (IS_LL_STACK(qi) && !newwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2961 win_set_loclist(curwin, qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2962 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2963 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2964 if (!p_im) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2965 restart_edit = 0; // don't want insert mode in help file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2966 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2967 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2968 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2969 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2970 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2971 * Find a non-quickfix window using the given location list stack in the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2972 * current tabpage. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2973 * Returns NULL if a matching window is not found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2974 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2975 static win_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2976 qf_find_win_with_loclist(qf_info_T *ll) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2977 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2978 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2979 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2980 FOR_ALL_WINDOWS(wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2981 if (wp->w_llist == ll && !bt_quickfix(wp->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2982 return wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2983 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2984 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2985 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2986 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2987 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2988 * Find a window containing a normal buffer in the current tab page. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2989 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2990 static win_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2991 qf_find_win_with_normal_buf(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2992 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2993 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2994 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2995 FOR_ALL_WINDOWS(wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2996 if (bt_normal(wp->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2997 return wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2998 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
2999 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3000 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3001 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3002 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3003 * Go to a window in any tabpage containing the specified file. Returns TRUE |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3004 * if successfully jumped to the window. Otherwise returns FALSE. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3005 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3006 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3007 qf_goto_tabwin_with_file(int fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3008 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3009 tabpage_T *tp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3010 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3011 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3012 FOR_ALL_TAB_WINDOWS(tp, wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3013 if (wp->w_buffer->b_fnum == fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3014 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3015 goto_tabpage_win(tp, wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3016 return TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3017 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3018 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3019 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3020 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3021 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3022 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3023 * Create a new window to show a file above the quickfix window. Called when |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3024 * only the quickfix window is present. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3025 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3026 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3027 qf_open_new_file_win(qf_info_T *ll_ref) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3028 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3029 int flags; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3030 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3031 flags = WSP_ABOVE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3032 if (ll_ref != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3033 flags |= WSP_NEWLOC; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3034 if (win_split(0, flags) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3035 return FAIL; // not enough room for window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3036 p_swb = empty_option; // don't split again |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3037 swb_flags = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3038 RESET_BINDING(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3039 if (ll_ref != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3040 // The new window should use the location list from the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3041 // location list window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3042 win_set_loclist(curwin, ll_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3043 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3044 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3045 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3046 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3047 * Go to a window that shows the right buffer. If the window is not found, go |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3048 * to the window just above the location list window. This is used for opening |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3049 * a file from a location window and not from a quickfix window. If some usable |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3050 * window is previously found, then it is supplied in 'use_win'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3051 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3052 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3053 qf_goto_win_with_ll_file(win_T *use_win, int qf_fnum, qf_info_T *ll_ref) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3054 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3055 win_T *win = use_win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3056 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3057 if (win == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3058 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3059 // Find the window showing the selected file in the current tab page. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3060 FOR_ALL_WINDOWS(win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3061 if (win->w_buffer->b_fnum == qf_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3062 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3063 if (win == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3064 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3065 // Find a previous usable window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3066 win = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3067 do |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3068 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3069 if (bt_normal(win->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3070 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3071 if (win->w_prev == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3072 win = lastwin; // wrap around the top |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3073 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3074 win = win->w_prev; // go to previous window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3075 } while (win != curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3076 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3077 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3078 win_goto(win); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3079 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3080 // If the location list for the window is not set, then set it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3081 // to the location list from the location window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3082 if (win->w_llist == NULL && ll_ref != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3083 win_set_loclist(win, ll_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3084 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3085 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3086 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3087 * Go to a window that contains the specified buffer 'qf_fnum'. If a window is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3088 * not found, then go to the window just above the quickfix window. This is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3089 * used for opening a file from a quickfix window and not from a location |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3090 * window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3091 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3092 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3093 qf_goto_win_with_qfl_file(int qf_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3094 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3095 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3096 win_T *altwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3097 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3098 win = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3099 altwin = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3100 for (;;) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3101 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3102 if (win->w_buffer->b_fnum == qf_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3103 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3104 if (win->w_prev == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3105 win = lastwin; // wrap around the top |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3106 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3107 win = win->w_prev; // go to previous window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3108 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3109 if (IS_QF_WINDOW(win)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3110 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3111 // Didn't find it, go to the window before the quickfix |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3112 // window, unless 'switchbuf' contains 'uselast': in this case we |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3113 // try to jump to the previously used window first. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3114 if ((swb_flags & SWB_USELAST) && win_valid(prevwin)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3115 win = prevwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3116 else if (altwin != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3117 win = altwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3118 else if (curwin->w_prev != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3119 win = curwin->w_prev; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3120 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3121 win = curwin->w_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3122 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3123 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3124 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3125 // Remember a usable window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3126 if (altwin == NULL && !win->w_p_pvw && bt_normal(win->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3127 altwin = win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3128 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3129 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3130 win_goto(win); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3131 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3132 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3133 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3134 * Find a suitable window for opening a file (qf_fnum) from the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3135 * quickfix/location list and jump to it. If the file is already opened in a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3136 * window, jump to it. Otherwise open a new window to display the file. If |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3137 * 'newwin' is TRUE, then always open a new window. This is called from either |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3138 * a quickfix or a location list window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3139 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3140 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3141 qf_jump_to_usable_window(int qf_fnum, int newwin, int *opened_window) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3142 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3143 win_T *usable_wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3144 int usable_win = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3145 qf_info_T *ll_ref = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3146 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3147 // If opening a new window, then don't use the location list referred by |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3148 // the current window. Otherwise two windows will refer to the same |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3149 // location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3150 if (!newwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3151 ll_ref = curwin->w_llist_ref; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3152 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3153 if (ll_ref != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3154 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3155 // Find a non-quickfix window with this location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3156 usable_wp = qf_find_win_with_loclist(ll_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3157 if (usable_wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3158 usable_win = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3159 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3160 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3161 if (!usable_win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3162 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3163 // Locate a window showing a normal buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3164 win_T *win = qf_find_win_with_normal_buf(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3165 if (win != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3166 usable_win = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3167 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3168 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3169 // If no usable window is found and 'switchbuf' contains "usetab" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3170 // then search in other tabs. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3171 if (!usable_win && (swb_flags & SWB_USETAB)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3172 usable_win = qf_goto_tabwin_with_file(qf_fnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3173 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3174 // If there is only one window and it is the quickfix window, create a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3175 // new one above the quickfix window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3176 if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win || newwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3177 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3178 if (qf_open_new_file_win(ll_ref) != OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3179 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3180 *opened_window = TRUE; // close it when fail |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3181 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3182 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3183 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3184 if (curwin->w_llist_ref != NULL) // In a location window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3185 qf_goto_win_with_ll_file(usable_wp, qf_fnum, ll_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3186 else // In a quickfix window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3187 qf_goto_win_with_qfl_file(qf_fnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3188 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3189 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3190 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3191 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3192 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3193 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3194 * Edit the selected file or help file. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3195 * Returns OK if successfully edited the file, FAIL on failing to open the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3196 * buffer and QF_ABORT if the quickfix/location list was freed by an autocmd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3197 * when opening the buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3198 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3199 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3200 qf_jump_edit_buffer( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3201 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3202 qfline_T *qf_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3203 int forceit, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3204 int prev_winid, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3205 int *opened_window) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3206 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3207 qf_list_T *qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3208 int old_changedtick = qfl->qf_changedtick; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3209 qfltype_T qfl_type = qfl->qfl_type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3210 int retval = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3211 int old_qf_curlist = qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3212 int save_qfid = qfl->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3213 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3214 if (qf_ptr->qf_type == 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3215 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3216 // Open help file (do_ecmd() will set b_help flag, readfile() will |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3217 // set b_p_ro flag). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3218 if (!can_abandon(curbuf, forceit)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3219 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3220 no_write_message(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3221 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3222 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3223 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3224 retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3225 ECMD_HIDE + ECMD_SET_HELP, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3226 prev_winid == curwin->w_id ? curwin : NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3227 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3228 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3229 retval = buflist_getfile(qf_ptr->qf_fnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3230 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3231 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3232 // If a location list, check whether the associated window is still |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3233 // present. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3234 if (qfl_type == QFLT_LOCATION) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3235 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3236 win_T *wp = win_id2wp(prev_winid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3237 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3238 if (wp == NULL && curwin->w_llist != qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3239 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3240 emsg(_(e_current_window_was_closed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3241 *opened_window = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3242 return QF_ABORT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3243 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3244 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3245 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3246 if (qfl_type == QFLT_QUICKFIX && !qflist_valid(NULL, save_qfid)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3247 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3248 emsg(_(e_current_quickfix_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3249 return QF_ABORT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3250 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3251 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3252 // Check if the list was changed. The pointers may happen to be identical, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3253 // thus also check qf_changedtick. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3254 if (old_qf_curlist != qi->qf_curlist |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3255 || old_changedtick != qfl->qf_changedtick |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3256 || !is_qf_entry_present(qfl, qf_ptr)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3257 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3258 if (qfl_type == QFLT_QUICKFIX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3259 emsg(_(e_current_quickfix_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3260 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3261 emsg(_(e_current_location_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3262 return QF_ABORT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3263 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3264 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3265 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3266 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3267 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3268 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3269 * Go to the error line in the current file using either line/column number or |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3270 * a search pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3271 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3272 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3273 qf_jump_goto_line( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3274 linenr_T qf_lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3275 int qf_col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3276 char_u qf_viscol, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3277 char_u *qf_pattern) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3278 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3279 linenr_T i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3280 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3281 if (qf_pattern == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3282 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3283 // Go to line with error, unless qf_lnum is 0. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3284 i = qf_lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3285 if (i > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3286 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3287 if (i > curbuf->b_ml.ml_line_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3288 i = curbuf->b_ml.ml_line_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3289 curwin->w_cursor.lnum = i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3290 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3291 if (qf_col > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3292 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3293 curwin->w_cursor.coladd = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3294 if (qf_viscol == TRUE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3295 coladvance(qf_col - 1); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3296 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3297 curwin->w_cursor.col = qf_col - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3298 curwin->w_set_curswant = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3299 check_cursor(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3300 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3301 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3302 beginline(BL_WHITE | BL_FIX); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3303 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3304 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3305 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3306 pos_T save_cursor; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3307 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3308 // Move the cursor to the first line in the buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3309 save_cursor = curwin->w_cursor; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3310 curwin->w_cursor.lnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3311 if (!do_search(NULL, '/', '/', qf_pattern, (long)1, SEARCH_KEEP, NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3312 curwin->w_cursor = save_cursor; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3313 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3314 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3315 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3316 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3317 * Display quickfix list index and size message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3318 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3319 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3320 qf_jump_print_msg( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3321 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3322 int qf_index, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3323 qfline_T *qf_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3324 buf_T *old_curbuf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3325 linenr_T old_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3326 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3327 linenr_T i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3328 garray_T *gap; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3329 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3330 gap = qfga_get(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3331 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3332 // Update the screen before showing the message, unless the screen |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3333 // scrolled up. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3334 if (!msg_scrolled) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3335 update_topline_redraw(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3336 vim_snprintf((char *)IObuff, IOSIZE, _("(%d of %d)%s%s: "), qf_index, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3337 qf_get_curlist(qi)->qf_count, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3338 qf_ptr->qf_cleared ? _(" (line deleted)") : "", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3339 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3340 // Add the message, skipping leading whitespace and newlines. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3341 ga_concat(gap, IObuff); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3342 qf_fmt_text(gap, skipwhite(qf_ptr->qf_text)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3343 ga_append(gap, NUL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3344 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3345 // Output the message. Overwrite to avoid scrolling when the 'O' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3346 // flag is present in 'shortmess'; But when not jumping, print the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3347 // whole message. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3348 i = msg_scroll; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3349 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3350 msg_scroll = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3351 else if (!msg_scrolled && shortmess(SHM_OVERALL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3352 msg_scroll = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3353 msg_attr_keep((char *)gap->ga_data, 0, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3354 msg_scroll = i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3355 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3356 qfga_clear(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3357 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3358 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3359 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3360 * Find a usable window for opening a file from the quickfix/location list. If |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3361 * a window is not found then open a new window. If 'newwin' is TRUE, then open |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3362 * a new window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3363 * Returns OK if successfully jumped or opened a window. Returns FAIL if not |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3364 * able to jump/open a window. Returns NOTDONE if a file is not associated |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3365 * with the entry. Returns QF_ABORT if the quickfix/location list was modified |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3366 * by an autocmd. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3367 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3368 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3369 qf_jump_open_window( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3370 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3371 qfline_T *qf_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3372 int newwin, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3373 int *opened_window) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3374 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3375 qf_list_T *qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3376 int old_changedtick = qfl->qf_changedtick; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3377 int old_qf_curlist = qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3378 qfltype_T qfl_type = qfl->qfl_type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3379 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3380 // For ":helpgrep" find a help window or open one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3381 if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3382 || cmdmod.cmod_tab != 0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3383 if (jump_to_help_window(qi, newwin, opened_window) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3384 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3385 if (old_qf_curlist != qi->qf_curlist |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3386 || old_changedtick != qfl->qf_changedtick |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3387 || !is_qf_entry_present(qfl, qf_ptr)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3388 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3389 if (qfl_type == QFLT_QUICKFIX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3390 emsg(_(e_current_quickfix_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3391 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3392 emsg(_(e_current_location_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3393 return QF_ABORT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3394 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3395 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3396 // If currently in the quickfix window, find another window to show the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3397 // file in. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3398 if (bt_quickfix(curbuf) && !*opened_window) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3399 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3400 // If there is no file specified, we don't know where to go. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3401 // But do advance, otherwise ":cn" gets stuck. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3402 if (qf_ptr->qf_fnum == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3403 return NOTDONE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3404 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3405 if (qf_jump_to_usable_window(qf_ptr->qf_fnum, newwin, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3406 opened_window) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3407 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3408 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3409 if (old_qf_curlist != qi->qf_curlist |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3410 || old_changedtick != qfl->qf_changedtick |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3411 || !is_qf_entry_present(qfl, qf_ptr)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3412 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3413 if (qfl_type == QFLT_QUICKFIX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3414 emsg(_(e_current_quickfix_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3415 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3416 emsg(_(e_current_location_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3417 return QF_ABORT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3418 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3419 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3420 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3421 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3422 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3423 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3424 * Edit a selected file from the quickfix/location list and jump to a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3425 * particular line/column, adjust the folds and display a message about the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3426 * jump. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3427 * Returns OK on success and FAIL on failing to open the file/buffer. Returns |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3428 * QF_ABORT if the quickfix/location list is freed by an autocmd when opening |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3429 * the file. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3430 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3431 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3432 qf_jump_to_buffer( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3433 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3434 int qf_index, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3435 qfline_T *qf_ptr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3436 int forceit, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3437 int prev_winid, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3438 int *opened_window, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3439 int openfold, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3440 int print_message) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3441 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3442 buf_T *old_curbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3443 linenr_T old_lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3444 int retval = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3445 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3446 // If there is a file name, read the wanted file if needed, and check |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3447 // autowrite etc. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3448 old_curbuf = curbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3449 old_lnum = curwin->w_cursor.lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3450 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3451 if (qf_ptr->qf_fnum != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3452 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3453 retval = qf_jump_edit_buffer(qi, qf_ptr, forceit, prev_winid, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3454 opened_window); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3455 if (retval != OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3456 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3457 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3458 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3459 // When not switched to another buffer, still need to set pc mark |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3460 if (curbuf == old_curbuf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3461 setpcmark(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3462 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3463 qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3464 qf_ptr->qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3465 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3466 #ifdef FEAT_FOLDING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3467 if ((fdo_flags & FDO_QUICKFIX) && openfold) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3468 foldOpenCursor(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3469 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3470 if (print_message) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3471 qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3472 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3473 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3474 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3475 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3476 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3477 * Jump to a quickfix line and try to use an existing window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3478 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3479 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3480 qf_jump(qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3481 int dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3482 int errornr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3483 int forceit) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3484 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3485 qf_jump_newwin(qi, dir, errornr, forceit, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3486 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3487 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3488 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3489 * Jump to a quickfix line. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3490 * If dir == 0 go to entry "errornr". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3491 * If dir == FORWARD go "errornr" valid entries forward. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3492 * If dir == BACKWARD go "errornr" valid entries backward. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3493 * If dir == FORWARD_FILE go "errornr" valid entries files backward. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3494 * If dir == BACKWARD_FILE go "errornr" valid entries files backward |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3495 * else if "errornr" is zero, redisplay the same line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3496 * If 'forceit' is TRUE, then can discard changes to the current buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3497 * If 'newwin' is TRUE, then open the file in a new window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3498 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3499 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3500 qf_jump_newwin(qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3501 int dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3502 int errornr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3503 int forceit, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3504 int newwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3505 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3506 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3507 qfline_T *qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3508 qfline_T *old_qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3509 int qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3510 int old_qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3511 char_u *old_swb = p_swb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3512 unsigned old_swb_flags = swb_flags; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3513 int prev_winid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3514 int opened_window = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3515 int print_message = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3516 int old_KeyTyped = KeyTyped; // getting file may reset it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3517 int retval = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3518 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3519 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3520 qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3521 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3522 if (qf_stack_empty(qi) || qf_list_empty(qf_get_curlist(qi))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3523 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3524 emsg(_(e_no_errors)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3525 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3526 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3527 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3528 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3529 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3530 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3531 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3532 qf_ptr = qfl->qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3533 old_qf_ptr = qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3534 qf_index = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3535 old_qf_index = qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3536 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3537 qf_ptr = qf_get_entry(qfl, errornr, dir, &qf_index); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3538 if (qf_ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3539 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3540 qf_ptr = old_qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3541 qf_index = old_qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3542 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3543 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3544 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3545 qfl->qf_index = qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3546 qfl->qf_ptr = qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3547 if (qf_win_pos_update(qi, old_qf_index)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3548 // No need to print the error message if it's visible in the error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3549 // window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3550 print_message = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3551 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3552 prev_winid = curwin->w_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3553 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3554 retval = qf_jump_open_window(qi, qf_ptr, newwin, &opened_window); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3555 if (retval == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3556 goto failed; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3557 if (retval == QF_ABORT) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3558 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3559 qi = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3560 qf_ptr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3561 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3562 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3563 if (retval == NOTDONE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3564 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3565 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3566 retval = qf_jump_to_buffer(qi, qf_index, qf_ptr, forceit, prev_winid, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3567 &opened_window, old_KeyTyped, print_message); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3568 if (retval == QF_ABORT) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3569 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3570 // Quickfix/location list was modified by an autocmd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3571 qi = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3572 qf_ptr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3573 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3574 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3575 if (retval != OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3576 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3577 if (opened_window) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3578 win_close(curwin, TRUE); // Close opened window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3579 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3580 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3581 // Couldn't open file, so put index back where it was. This could |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3582 // happen if the file was readonly and we changed something. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3583 failed: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3584 qf_ptr = old_qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3585 qf_index = old_qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3586 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3587 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3588 theend: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3589 if (qi != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3590 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3591 qfl->qf_ptr = qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3592 qfl->qf_index = qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3593 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3594 if (p_swb != old_swb && p_swb == empty_option) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3595 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3596 // Restore old 'switchbuf' value, but not when an autocommand or |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3597 // modeline has changed the value. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3598 p_swb = old_swb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3599 swb_flags = old_swb_flags; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3600 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3601 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3602 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3603 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3604 // Highlight attributes used for displaying entries from the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3605 static int qfFileAttr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3606 static int qfSepAttr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3607 static int qfLineAttr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3608 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3609 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3610 * Display information about a single entry from the quickfix/location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3611 * Used by ":clist/:llist" commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3612 * 'cursel' will be set to TRUE for the currently selected entry in the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3613 * quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3614 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3615 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3616 qf_list_entry(qfline_T *qfp, int qf_idx, int cursel) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3617 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3618 char_u *fname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3619 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3620 int filter_entry; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3621 garray_T *gap; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3622 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3623 fname = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3624 if (qfp->qf_module != NULL && *qfp->qf_module != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3625 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", qf_idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3626 (char *)qfp->qf_module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3627 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3628 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3629 if (qfp->qf_fnum != 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3630 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3631 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3632 fname = buf->b_fname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3633 if (qfp->qf_type == 1) // :helpgrep |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3634 fname = gettail(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3635 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3636 if (fname == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3637 sprintf((char *)IObuff, "%2d", qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3638 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3639 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3640 qf_idx, (char *)fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3641 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3642 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3643 // Support for filtering entries using :filter /pat/ clist |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3644 // Match against the module name, file name, search pattern and |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3645 // text of the entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3646 filter_entry = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3647 if (qfp->qf_module != NULL && *qfp->qf_module != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3648 filter_entry &= message_filtered(qfp->qf_module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3649 if (filter_entry && fname != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3650 filter_entry &= message_filtered(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3651 if (filter_entry && qfp->qf_pattern != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3652 filter_entry &= message_filtered(qfp->qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3653 if (filter_entry) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3654 filter_entry &= message_filtered(qfp->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3655 if (filter_entry) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3656 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3657 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3658 msg_putchar('\n'); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3659 msg_outtrans_attr(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3660 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3661 if (qfp->qf_lnum != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3662 msg_puts_attr(":", qfSepAttr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3663 gap = qfga_get(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3664 if (qfp->qf_lnum != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3665 qf_range_text(gap, qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3666 ga_concat(gap, qf_types(qfp->qf_type, qfp->qf_nr)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3667 ga_append(gap, NUL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3668 msg_puts_attr((char *)gap->ga_data, qfLineAttr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3669 msg_puts_attr(":", qfSepAttr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3670 if (qfp->qf_pattern != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3671 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3672 gap = qfga_get(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3673 qf_fmt_text(gap, qfp->qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3674 ga_append(gap, NUL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3675 msg_puts((char *)gap->ga_data); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3676 msg_puts_attr(":", qfSepAttr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3677 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3678 msg_puts(" "); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3679 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3680 // Remove newlines and leading whitespace from the text. For an |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3681 // unrecognized line keep the indent, the compiler may mark a word |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3682 // with ^^^^. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3683 gap = qfga_get(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3684 qf_fmt_text(gap, (fname != NULL || qfp->qf_lnum != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3685 ? skipwhite(qfp->qf_text) : qfp->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3686 ga_append(gap, NUL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3687 msg_prt_line((char_u *)gap->ga_data, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3688 out_flush(); // show one line at a time |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3689 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3690 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3691 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3692 * ":clist": list all errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3693 * ":llist": list all locations |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3694 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3695 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3696 qf_list(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3697 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3698 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3699 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3700 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3701 int idx1 = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3702 int idx2 = -1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3703 char_u *arg = eap->arg; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3704 int plus = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3705 int all = eap->forceit; // if not :cl!, only show |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3706 // recognised errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3707 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3708 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3709 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3710 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3711 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3712 if (qf_stack_empty(qi) || qf_list_empty(qf_get_curlist(qi))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3713 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3714 emsg(_(e_no_errors)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3715 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3716 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3717 if (*arg == '+') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3718 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3719 ++arg; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3720 plus = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3721 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3722 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3723 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3724 semsg(_(e_trailing_characters_str), arg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3725 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3726 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3727 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3728 if (plus) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3729 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3730 i = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3731 idx2 = i + idx1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3732 idx1 = i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3733 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3734 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3735 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3736 i = qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3737 if (idx1 < 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3738 idx1 = (-idx1 > i) ? 0 : idx1 + i + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3739 if (idx2 < 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3740 idx2 = (-idx2 > i) ? 0 : idx2 + i + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3741 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3742 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3743 // Shorten all the file names, so that it is easy to read |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3744 shorten_fnames(FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3745 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3746 // Get the attributes for the different quickfix highlight items. Note |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3747 // that this depends on syntax items defined in the qf.vim syntax file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3748 qfFileAttr = syn_name2attr((char_u *)"qfFileName"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3749 if (qfFileAttr == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3750 qfFileAttr = HL_ATTR(HLF_D); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3751 qfSepAttr = syn_name2attr((char_u *)"qfSeparator"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3752 if (qfSepAttr == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3753 qfSepAttr = HL_ATTR(HLF_D); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3754 qfLineAttr = syn_name2attr((char_u *)"qfLineNr"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3755 if (qfLineAttr == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3756 qfLineAttr = HL_ATTR(HLF_N); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3757 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3758 if (qfl->qf_nonevalid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3759 all = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3760 FOR_ALL_QFL_ITEMS(qfl, qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3761 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3762 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3763 qf_list_entry(qfp, i, i == qfl->qf_index); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3764 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3765 ui_breakcheck(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3766 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3767 qfga_clear(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3768 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3769 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3770 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3771 * Remove newlines and leading whitespace from an error message. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3772 * Add the result to the grow array "gap". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3773 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3774 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3775 qf_fmt_text(garray_T *gap, char_u *text) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3776 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3777 char_u *p = text; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3778 while (*p != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3779 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3780 if (*p == '\n') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3781 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3782 ga_append(gap, ' '); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3783 while (*++p != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3784 if (!VIM_ISWHITE(*p) && *p != '\n') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3785 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3786 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3787 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3788 ga_append(gap, *p++); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3789 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3790 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3791 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3792 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3793 * Add the range information from the lnum, col, end_lnum, and end_col values |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3794 * of a quickfix entry to the grow array "gap". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3795 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3796 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3797 qf_range_text(garray_T *gap, qfline_T *qfp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3798 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3799 char_u *buf = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3800 int bufsize = IOSIZE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3801 int len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3802 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3803 vim_snprintf((char *)buf, bufsize, "%ld", qfp->qf_lnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3804 len = (int)STRLEN(buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3805 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3806 if (qfp->qf_end_lnum > 0 && qfp->qf_lnum != qfp->qf_end_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3807 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3808 vim_snprintf((char *)buf + len, bufsize - len, "-%ld", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3809 qfp->qf_end_lnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3810 len += (int)STRLEN(buf + len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3811 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3812 if (qfp->qf_col > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3813 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3814 vim_snprintf((char *)buf + len, bufsize - len, " col %d", qfp->qf_col); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3815 len += (int)STRLEN(buf + len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3816 if (qfp->qf_end_col > 0 && qfp->qf_col != qfp->qf_end_col) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3817 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3818 vim_snprintf((char *)buf + len, bufsize - len, "-%d", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3819 qfp->qf_end_col); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3820 len += (int)STRLEN(buf + len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3821 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3822 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3823 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3824 ga_concat_len(gap, buf, len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3825 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3826 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3827 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3828 * Display information (list number, list size and the title) about a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3829 * quickfix/location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3830 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3831 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3832 qf_msg(qf_info_T *qi, int which, char *lead) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3833 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3834 char *title = (char *)qi->qf_lists[which].qf_title; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3835 int count = qi->qf_lists[which].qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3836 char_u buf[IOSIZE]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3837 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3838 vim_snprintf((char *)buf, IOSIZE, _("%serror list %d of %d; %d errors "), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3839 lead, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3840 which + 1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3841 qi->qf_listcount, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3842 count); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3843 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3844 if (title != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3845 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3846 size_t len = STRLEN(buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3847 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3848 if (len < 34) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3849 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3850 vim_memset(buf + len, ' ', 34 - len); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3851 buf[34] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3852 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3853 vim_strcat(buf, (char_u *)title, IOSIZE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3854 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3855 trunc_string(buf, buf, Columns - 1, IOSIZE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3856 msg((char *)buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3857 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3858 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3859 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3860 * ":colder [count]": Up in the quickfix stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3861 * ":cnewer [count]": Down in the quickfix stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3862 * ":lolder [count]": Up in the location list stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3863 * ":lnewer [count]": Down in the location list stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3864 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3865 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3866 qf_age(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3867 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3868 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3869 int count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3870 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3871 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3872 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3873 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3874 if (eap->addr_count != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3875 count = eap->line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3876 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3877 count = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3878 while (count--) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3879 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3880 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3881 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3882 if (qi->qf_curlist == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3883 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3884 emsg(_(e_at_bottom_of_quickfix_stack)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3885 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3886 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3887 --qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3888 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3889 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3890 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3891 if (qi->qf_curlist >= qi->qf_listcount - 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3892 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3893 emsg(_(e_at_top_of_quickfix_stack)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3894 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3895 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3896 ++qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3897 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3898 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3899 qf_msg(qi, qi->qf_curlist, ""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3900 qf_update_buffer(qi, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3901 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3902 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3903 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3904 * Display the information about all the quickfix/location lists in the stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3905 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3906 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3907 qf_history(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3908 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3909 qf_info_T *qi = qf_cmd_get_stack(eap, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3910 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3911 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3912 if (eap->addr_count > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3913 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3914 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3915 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3916 emsg(_(e_no_location_list)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3917 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3918 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3919 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3920 // Jump to the specified quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3921 if (eap->line2 > 0 && eap->line2 <= qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3922 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3923 qi->qf_curlist = eap->line2 - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3924 qf_msg(qi, qi->qf_curlist, ""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3925 qf_update_buffer(qi, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3926 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3927 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3928 emsg(_(e_invalid_range)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3929 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3930 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3931 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3932 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3933 if (qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3934 msg(_("No entries")); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3935 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3936 for (i = 0; i < qi->qf_listcount; ++i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3937 qf_msg(qi, i, i == qi->qf_curlist ? "> " : " "); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3938 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3939 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3940 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3941 * Free all the entries in the error list "idx". Note that other information |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3942 * associated with the list like context and title are not freed. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3943 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3944 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3945 qf_free_items(qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3946 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3947 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3948 qfline_T *qfpnext; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3949 int stop = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3950 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3951 while (qfl->qf_count && qfl->qf_start != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3952 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3953 qfp = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3954 qfpnext = qfp->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3955 if (!stop) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3956 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3957 vim_free(qfp->qf_module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3958 vim_free(qfp->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3959 vim_free(qfp->qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3960 stop = (qfp == qfpnext); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3961 vim_free(qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3962 if (stop) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3963 // Somehow qf_count may have an incorrect value, set it to 1 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3964 // to avoid crashing when it's wrong. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3965 // TODO: Avoid qf_count being incorrect. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3966 qfl->qf_count = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3967 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3968 qfl->qf_start = qfpnext; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3969 --qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3970 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3971 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3972 qfl->qf_index = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3973 qfl->qf_start = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3974 qfl->qf_last = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3975 qfl->qf_ptr = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3976 qfl->qf_nonevalid = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3977 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3978 qf_clean_dir_stack(&qfl->qf_dir_stack); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3979 qfl->qf_directory = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3980 qf_clean_dir_stack(&qfl->qf_file_stack); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3981 qfl->qf_currfile = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3982 qfl->qf_multiline = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3983 qfl->qf_multiignore = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3984 qfl->qf_multiscan = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3985 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3986 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3987 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3988 * Free error list "idx". Frees all the entries in the quickfix list, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3989 * associated context information and the title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3990 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3991 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3992 qf_free(qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3993 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3994 qf_free_items(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3995 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3996 VIM_CLEAR(qfl->qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3997 free_tv(qfl->qf_ctx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3998 qfl->qf_ctx = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
3999 free_callback(&qfl->qf_qftf_cb); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4000 qfl->qf_id = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4001 qfl->qf_changedtick = 0L; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4002 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4003 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4004 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4005 * qf_mark_adjust: adjust marks |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4006 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4007 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4008 qf_mark_adjust( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4009 win_T *wp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4010 linenr_T line1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4011 linenr_T line2, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4012 long amount, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4013 long amount_after) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4014 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4015 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4016 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4017 int idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4018 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4019 int found_one = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4020 int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4021 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4022 if (!(curbuf->b_has_qf_entry & buf_has_flag)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4023 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4024 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4025 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4026 if (wp->w_llist == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4027 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4028 qi = wp->w_llist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4029 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4030 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4031 for (idx = 0; idx < qi->qf_listcount; ++idx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4032 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4033 qf_list_T *qfl = qf_get_list(qi, idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4034 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4035 if (!qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4036 FOR_ALL_QFL_ITEMS(qfl, qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4037 if (qfp->qf_fnum == curbuf->b_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4038 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4039 found_one = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4040 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4041 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4042 if (amount == MAXLNUM) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4043 qfp->qf_cleared = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4044 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4045 qfp->qf_lnum += amount; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4046 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4047 else if (amount_after && qfp->qf_lnum > line2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4048 qfp->qf_lnum += amount_after; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4049 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4050 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4051 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4052 if (!found_one) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4053 curbuf->b_has_qf_entry &= ~buf_has_flag; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4054 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4055 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4056 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4057 * Make a nice message out of the error character and the error number: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4058 * char number message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4059 * e or E 0 " error" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4060 * w or W 0 " warning" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4061 * i or I 0 " info" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4062 * n or N 0 " note" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4063 * 0 0 "" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4064 * other 0 " c" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4065 * e or E n " error n" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4066 * w or W n " warning n" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4067 * i or I n " info n" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4068 * n or N n " note n" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4069 * 0 n " error n" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4070 * other n " c n" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4071 * 1 x "" :helpgrep |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4072 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4073 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4074 qf_types(int c, int nr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4075 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4076 static char_u buf[20]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4077 static char_u cc[3]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4078 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4079 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4080 if (c == 'W' || c == 'w') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4081 p = (char_u *)" warning"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4082 else if (c == 'I' || c == 'i') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4083 p = (char_u *)" info"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4084 else if (c == 'N' || c == 'n') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4085 p = (char_u *)" note"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4086 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4087 p = (char_u *)" error"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4088 else if (c == 0 || c == 1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4089 p = (char_u *)""; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4090 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4091 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4092 cc[0] = ' '; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4093 cc[1] = c; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4094 cc[2] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4095 p = cc; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4096 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4097 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4098 if (nr <= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4099 return p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4100 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4101 sprintf((char *)buf, "%s %3d", (char *)p, nr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4102 return buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4103 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4104 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4105 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4106 * When "split" is FALSE: Open the entry/result under the cursor. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4107 * When "split" is TRUE: Open the entry/result under the cursor in a new window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4108 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4109 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4110 qf_view_result(int split) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4111 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4112 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4113 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4114 if (IS_LL_WINDOW(curwin)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4115 qi = GET_LOC_LIST(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4116 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4117 if (qf_list_empty(qf_get_curlist(qi))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4118 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4119 emsg(_(e_no_errors)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4120 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4121 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4122 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4123 if (split) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4124 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4125 // Open the selected entry in a new window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4126 qf_jump_newwin(qi, 0, (long)curwin->w_cursor.lnum, FALSE, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4127 do_cmdline_cmd((char_u *) "clearjumps"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4128 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4129 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4130 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4131 do_cmdline_cmd((char_u *)(IS_LL_WINDOW(curwin) ? ".ll" : ".cc")); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4132 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4133 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4134 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4135 * ":cwindow": open the quickfix window if we have errors to display, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4136 * close it if not. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4137 * ":lwindow": open the location list window if we have locations to display, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4138 * close it if not. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4139 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4140 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4141 ex_cwindow(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4142 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4143 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4144 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4145 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4146 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4147 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4148 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4149 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4150 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4151 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4152 // Look for an existing quickfix window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4153 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4154 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4155 // If a quickfix window is open but we have no errors to display, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4156 // close the window. If a quickfix window is not open, then open |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4157 // it if we have errors; otherwise, leave it closed. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4158 if (qf_stack_empty(qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4159 || qfl->qf_nonevalid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4160 || qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4161 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4162 if (win != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4163 ex_cclose(eap); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4164 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4165 else if (win == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4166 ex_copen(eap); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4167 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4168 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4169 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4170 * ":cclose": close the window showing the list of errors. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4171 * ":lclose": close the window showing the location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4172 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4173 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4174 ex_cclose(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4175 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4176 win_T *win = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4177 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4178 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4179 if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4180 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4181 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4182 // Find existing quickfix window and close it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4183 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4184 if (win != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4185 win_close(win, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4186 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4187 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4188 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4189 * Set "w:quickfix_title" if "qi" has a title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4190 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4191 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4192 qf_set_title_var(qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4193 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4194 if (qfl->qf_title != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4195 set_internal_string_var((char_u *)"w:quickfix_title", qfl->qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4196 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4197 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4198 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4199 * Goto a quickfix or location list window (if present). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4200 * Returns OK if the window is found, FAIL otherwise. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4201 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4202 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4203 qf_goto_cwindow(qf_info_T *qi, int resize, int sz, int vertsplit) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4204 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4205 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4206 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4207 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4208 if (win == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4209 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4210 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4211 win_goto(win); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4212 if (resize) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4213 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4214 if (vertsplit) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4215 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4216 if (sz != win->w_width) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4217 win_setwidth(sz); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4218 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4219 else if (sz != win->w_height && win->w_height |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4220 + win->w_status_height + tabline_height() < cmdline_row) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4221 win_setheight(sz); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4222 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4223 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4224 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4225 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4226 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4227 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4228 * Set options for the buffer in the quickfix or location list window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4229 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4230 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4231 qf_set_cwindow_options(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4232 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4233 // switch off 'swapfile' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4234 set_option_value_give_err((char_u *)"swf", 0L, NULL, OPT_LOCAL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4235 set_option_value_give_err((char_u *)"bt", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4236 0L, (char_u *)"quickfix", OPT_LOCAL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4237 set_option_value_give_err((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4238 RESET_BINDING(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4239 #ifdef FEAT_DIFF |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4240 curwin->w_p_diff = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4241 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4242 #ifdef FEAT_FOLDING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4243 set_option_value_give_err((char_u *)"fdm", 0L, (char_u *)"manual", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4244 OPT_LOCAL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4245 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4246 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4247 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4248 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4249 * Open a new quickfix or location list window, load the quickfix buffer and |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4250 * set the appropriate options for the window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4251 * Returns FAIL if the window could not be opened. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4252 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4253 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4254 qf_open_new_cwindow(qf_info_T *qi, int height) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4255 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4256 buf_T *qf_buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4257 win_T *oldwin = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4258 tabpage_T *prevtab = curtab; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4259 int flags = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4260 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4261 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4262 qf_buf = qf_find_buf(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4263 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4264 // The current window becomes the previous window afterwards. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4265 win = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4266 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4267 if (IS_QF_STACK(qi) && cmdmod.cmod_split == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4268 // Create the new quickfix window at the very bottom, except when |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4269 // :belowright or :aboveleft is used. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4270 win_goto(lastwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4271 // Default is to open the window below the current window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4272 if (cmdmod.cmod_split == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4273 flags = WSP_BELOW; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4274 flags |= WSP_NEWLOC; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4275 if (win_split(height, flags) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4276 return FAIL; // not enough room for window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4277 RESET_BINDING(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4278 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4279 if (IS_LL_STACK(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4280 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4281 // For the location list window, create a reference to the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4282 // location list stack from the window 'win'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4283 curwin->w_llist_ref = qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4284 qi->qf_refcount++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4285 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4286 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4287 if (oldwin != curwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4288 oldwin = NULL; // don't store info when in another window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4289 if (qf_buf != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4290 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4291 // Use the existing quickfix buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4292 if (do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4293 ECMD_HIDE + ECMD_OLDBUF + ECMD_NOWINENTER, oldwin) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4294 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4295 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4296 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4297 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4298 // Create a new quickfix buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4299 if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE + ECMD_NOWINENTER, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4300 oldwin) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4301 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4302 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4303 // save the number of the new buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4304 qi->qf_bufnr = curbuf->b_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4305 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4306 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4307 // Set the options for the quickfix buffer/window (if not already done) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4308 // Do this even if the quickfix buffer was already present, as an autocmd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4309 // might have previously deleted (:bdelete) the quickfix buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4310 if (!bt_quickfix(curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4311 qf_set_cwindow_options(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4312 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4313 // Only set the height when still in the same tab page and there is no |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4314 // window to the side. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4315 if (curtab == prevtab && curwin->w_width == Columns) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4316 win_setheight(height); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4317 curwin->w_p_wfh = TRUE; // set 'winfixheight' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4318 if (win_valid(win)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4319 prevwin = win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4320 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4321 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4322 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4323 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4324 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4325 * ":copen": open a window that shows the list of errors. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4326 * ":lopen": open a window that shows the location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4327 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4328 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4329 ex_copen(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4330 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4331 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4332 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4333 int height; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4334 int status = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4335 int lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4336 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4337 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4338 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4339 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4340 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4341 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4342 if (eap->addr_count != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4343 height = eap->line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4344 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4345 height = QF_WINHEIGHT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4346 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4347 reset_VIsual_and_resel(); // stop Visual mode |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4348 #ifdef FEAT_GUI |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4349 need_mouse_correct = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4350 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4351 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4352 // Find an existing quickfix window, or open a new one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4353 if (cmdmod.cmod_tab == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4354 status = qf_goto_cwindow(qi, eap->addr_count != 0, height, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4355 cmdmod.cmod_split & WSP_VERT); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4356 if (status == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4357 if (qf_open_new_cwindow(qi, height) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4358 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4359 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4360 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4361 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4362 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4363 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4364 qf_set_title_var(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4365 // Save the current index here, as updating the quickfix buffer may free |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4366 // the quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4367 lnum = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4368 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4369 // Fill the buffer with the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4370 qf_fill_buffer(qfl, curbuf, NULL, curwin->w_id); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4371 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4372 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4373 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4374 curwin->w_cursor.lnum = lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4375 curwin->w_cursor.col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4376 check_cursor(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4377 update_topline(); // scroll to show the line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4378 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4379 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4380 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4381 * Move the cursor in the quickfix window to "lnum". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4382 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4383 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4384 qf_win_goto(win_T *win, linenr_T lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4385 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4386 win_T *old_curwin = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4387 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4388 curwin = win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4389 curbuf = win->w_buffer; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4390 curwin->w_cursor.lnum = lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4391 curwin->w_cursor.col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4392 curwin->w_cursor.coladd = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4393 curwin->w_curswant = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4394 update_topline(); // scroll to show the line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4395 redraw_later(UPD_VALID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4396 curwin->w_redr_status = TRUE; // update ruler |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4397 curwin = old_curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4398 curbuf = curwin->w_buffer; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4399 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4400 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4401 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4402 * :cbottom/:lbottom commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4403 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4404 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4405 ex_cbottom(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4406 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4407 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4408 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4409 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4410 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4411 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4412 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4413 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4414 if (win != NULL && win->w_cursor.lnum != win->w_buffer->b_ml.ml_line_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4415 qf_win_goto(win, win->w_buffer->b_ml.ml_line_count); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4416 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4417 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4418 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4419 * Return the number of the current entry (line number in the quickfix |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4420 * window). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4421 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4422 linenr_T |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4423 qf_current_entry(win_T *wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4424 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4425 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4426 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4427 if (IS_LL_WINDOW(wp)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4428 // In the location list window, use the referenced location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4429 qi = wp->w_llist_ref; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4430 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4431 return qf_get_curlist(qi)->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4432 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4433 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4434 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4435 * Update the cursor position in the quickfix window to the current error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4436 * Return TRUE if there is a quickfix window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4437 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4438 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4439 qf_win_pos_update( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4440 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4441 int old_qf_index) // previous qf_index or zero |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4442 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4443 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4444 int qf_index = qf_get_curlist(qi)->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4445 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4446 // Put the cursor on the current error in the quickfix window, so that |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4447 // it's viewable. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4448 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4449 if (win != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4450 && qf_index <= win->w_buffer->b_ml.ml_line_count |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4451 && old_qf_index != qf_index) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4452 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4453 if (qf_index > old_qf_index) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4454 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4455 win->w_redraw_top = old_qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4456 win->w_redraw_bot = qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4457 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4458 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4459 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4460 win->w_redraw_top = qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4461 win->w_redraw_bot = old_qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4462 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4463 qf_win_goto(win, qf_index); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4464 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4465 return win != NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4466 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4467 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4468 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4469 * Check whether the given window is displaying the specified quickfix/location |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4470 * stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4471 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4472 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4473 is_qf_win(win_T *win, qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4474 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4475 // A window displaying the quickfix buffer will have the w_llist_ref field |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4476 // set to NULL. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4477 // A window displaying a location list buffer will have the w_llist_ref |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4478 // pointing to the location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4479 if (bt_quickfix(win->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4480 if ((IS_QF_STACK(qi) && win->w_llist_ref == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4481 || (IS_LL_STACK(qi) && win->w_llist_ref == qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4482 return TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4483 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4484 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4485 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4486 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4487 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4488 * Find a window displaying the quickfix/location stack 'qi' in the current tab |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4489 * page. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4490 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4491 static win_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4492 qf_find_win(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4493 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4494 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4495 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4496 FOR_ALL_WINDOWS(win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4497 if (is_qf_win(win, qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4498 return win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4499 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4500 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4501 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4502 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4503 * Find a quickfix buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4504 * Searches in windows opened in all the tab pages. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4505 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4506 static buf_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4507 qf_find_buf(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4508 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4509 tabpage_T *tp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4510 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4511 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4512 if (qi->qf_bufnr != INVALID_QFBUFNR) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4513 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4514 buf_T *qfbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4515 qfbuf = buflist_findnr(qi->qf_bufnr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4516 if (qfbuf != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4517 return qfbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4518 // buffer is no longer present |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4519 qi->qf_bufnr = INVALID_QFBUFNR; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4520 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4521 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4522 FOR_ALL_TAB_WINDOWS(tp, win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4523 if (is_qf_win(win, qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4524 return win->w_buffer; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4525 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4526 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4527 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4528 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4529 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4530 * Process the 'quickfixtextfunc' option value. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4531 * Returns OK or FAIL. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4532 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4533 char * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4534 did_set_quickfixtextfunc(optset_T *args UNUSED) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4535 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4536 if (option_set_callback_func(p_qftf, &qftf_cb) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4537 return e_invalid_argument; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4538 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4539 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4540 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4541 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4542 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4543 * Update the w:quickfix_title variable in the quickfix/location list window in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4544 * all the tab pages. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4545 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4546 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4547 qf_update_win_titlevar(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4548 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4549 qf_list_T *qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4550 tabpage_T *tp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4551 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4552 win_T *save_curwin = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4553 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4554 FOR_ALL_TAB_WINDOWS(tp, win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4555 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4556 if (is_qf_win(win, qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4557 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4558 curwin = win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4559 qf_set_title_var(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4560 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4561 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4562 curwin = save_curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4563 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4564 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4565 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4566 * Find the quickfix buffer. If it exists, update the contents. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4567 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4568 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4569 qf_update_buffer(qf_info_T *qi, qfline_T *old_last) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4570 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4571 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4572 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4573 aco_save_T aco; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4574 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4575 // Check if a buffer for the quickfix list exists. Update it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4576 buf = qf_find_buf(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4577 if (buf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4578 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4579 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4580 linenr_T old_line_count = buf->b_ml.ml_line_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4581 int qf_winid = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4582 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4583 if (IS_LL_STACK(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4584 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4585 if (curwin->w_llist == qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4586 win = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4587 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4588 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4589 // Find the file window (non-quickfix) with this location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4590 win = qf_find_win_with_loclist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4591 if (win == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4592 // File window is not found. Find the location list window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4593 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4594 if (win == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4595 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4596 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4597 qf_winid = win->w_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4598 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4599 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4600 // autocommands may cause trouble |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4601 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4602 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4603 int do_fill = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4604 if (old_last == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4605 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4606 // set curwin/curbuf to buf and save a few things |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4607 aucmd_prepbuf(&aco, buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4608 if (curbuf != buf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4609 do_fill = FALSE; // failed to find a window for "buf" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4610 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4611 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4612 if (do_fill) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4613 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4614 qf_update_win_titlevar(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4615 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4616 qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4617 ++CHANGEDTICK(buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4618 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4619 if (old_last == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4620 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4621 (void)qf_win_pos_update(qi, 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4622 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4623 // restore curwin/curbuf and a few other things |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4624 aucmd_restbuf(&aco); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4625 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4626 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4627 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4628 // Only redraw when added lines are visible. This avoids flickering |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4629 // when the added lines are not visible. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4630 if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4631 redraw_buf_later(buf, UPD_NOT_VALID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4632 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4633 // always called after incr_quickfix_busy() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4634 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4635 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4636 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4637 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4638 * Add an error line to the quickfix buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4639 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4640 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4641 qf_buf_add_line( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4642 buf_T *buf, // quickfix window buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4643 linenr_T lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4644 qfline_T *qfp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4645 char_u *dirname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4646 int first_bufline, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4647 char_u *qftf_str) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4648 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4649 buf_T *errbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4650 garray_T *gap; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4651 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4652 gap = qfga_get(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4653 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4654 // If the 'quickfixtextfunc' function returned a non-empty custom string |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4655 // for this entry, then use it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4656 if (qftf_str != NULL && *qftf_str != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4657 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4658 ga_concat(gap, qftf_str); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4659 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4660 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4661 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4662 if (qfp->qf_module != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4663 ga_concat(gap, qfp->qf_module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4664 else if (qfp->qf_fnum != 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4665 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4666 && errbuf->b_fname != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4667 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4668 if (qfp->qf_type == 1) // :helpgrep |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4669 ga_concat(gap, gettail(errbuf->b_fname)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4670 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4671 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4672 // Shorten the file name if not done already. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4673 // For optimization, do this only for the first entry in a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4674 // buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4675 if (first_bufline && (errbuf->b_sfname == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4676 || mch_isFullName(errbuf->b_sfname))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4677 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4678 if (*dirname == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4679 mch_dirname(dirname, MAXPATHL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4680 shorten_buf_fname(errbuf, dirname, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4681 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4682 ga_concat(gap, errbuf->b_fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4683 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4684 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4685 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4686 ga_append(gap, '|'); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4687 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4688 if (qfp->qf_lnum > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4689 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4690 qf_range_text(gap, qfp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4691 ga_concat(gap, qf_types(qfp->qf_type, qfp->qf_nr)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4692 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4693 else if (qfp->qf_pattern != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4694 qf_fmt_text(gap, qfp->qf_pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4695 ga_append(gap, '|'); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4696 ga_append(gap, ' '); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4697 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4698 // Remove newlines and leading whitespace from the text. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4699 // For an unrecognized line keep the indent, the compiler may |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4700 // mark a word with ^^^^. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4701 qf_fmt_text(gap, gap->ga_len > 3 ? skipwhite(qfp->qf_text) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4702 : qfp->qf_text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4703 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4704 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4705 ga_append(gap, NUL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4706 if (ml_append_buf(buf, lnum, gap->ga_data, gap->ga_len, FALSE) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4707 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4708 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4709 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4710 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4711 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4712 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4713 * Call the 'quickfixtextfunc' function to get the list of lines to display in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4714 * the quickfix window for the entries 'start_idx' to 'end_idx'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4715 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4716 static list_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4717 call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long end_idx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4718 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4719 callback_T *cb = &qftf_cb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4720 list_T *qftf_list = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4721 static int recursive = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4722 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4723 if (recursive) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4724 return NULL; // this doesn't work properly recursively |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4725 recursive = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4726 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4727 // If 'quickfixtextfunc' is set, then use the user-supplied function to get |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4728 // the text to display. Use the local value of 'quickfixtextfunc' if it is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4729 // set. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4730 if (qfl->qf_qftf_cb.cb_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4731 cb = &qfl->qf_qftf_cb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4732 if (cb->cb_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4733 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4734 typval_T args[1]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4735 dict_T *d; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4736 typval_T rettv; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4737 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4738 // create the dict argument |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4739 if ((d = dict_alloc_lock(VAR_FIXED)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4740 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4741 recursive = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4742 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4743 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4744 dict_add_number(d, "quickfix", (long)IS_QF_LIST(qfl)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4745 dict_add_number(d, "winid", (long)qf_winid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4746 dict_add_number(d, "id", (long)qfl->qf_id); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4747 dict_add_number(d, "start_idx", start_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4748 dict_add_number(d, "end_idx", end_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4749 ++d->dv_refcount; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4750 args[0].v_type = VAR_DICT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4751 args[0].vval.v_dict = d; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4752 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4753 qftf_list = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4754 if (call_callback(cb, 0, &rettv, 1, args) != FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4755 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4756 if (rettv.v_type == VAR_LIST) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4757 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4758 qftf_list = rettv.vval.v_list; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4759 qftf_list->lv_refcount++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4760 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4761 clear_tv(&rettv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4762 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4763 dict_unref(d); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4764 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4765 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4766 recursive = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4767 return qftf_list; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4768 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4769 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4770 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4771 * Fill current buffer with quickfix errors, replacing any previous contents. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4772 * curbuf must be the quickfix buffer! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4773 * If "old_last" is not NULL append the items after this one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4774 * When "old_last" is NULL then "buf" must equal "curbuf"! Because |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4775 * ml_delete() is used and autocommands will be triggered. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4776 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4777 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4778 qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4779 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4780 linenr_T lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4781 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4782 int old_KeyTyped = KeyTyped; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4783 list_T *qftf_list = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4784 listitem_T *qftf_li = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4785 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4786 if (old_last == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4787 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4788 if (buf != curbuf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4789 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4790 internal_error("qf_fill_buffer()"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4791 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4792 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4793 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4794 // delete all existing lines |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4795 while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4796 (void)ml_delete((linenr_T)1); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4797 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4798 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4799 // Check if there is anything to display |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4800 if (qfl != NULL && qfl->qf_start != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4801 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4802 char_u dirname[MAXPATHL]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4803 int invalid_val = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4804 int prev_bufnr = -1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4805 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4806 *dirname = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4807 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4808 // Add one line for each error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4809 if (old_last == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4810 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4811 qfp = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4812 lnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4813 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4814 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4815 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4816 if (old_last->qf_next != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4817 qfp = old_last->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4818 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4819 qfp = old_last; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4820 lnum = buf->b_ml.ml_line_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4821 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4822 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4823 qftf_list = call_qftf_func(qfl, qf_winid, (long)(lnum + 1), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4824 (long)qfl->qf_count); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4825 if (qftf_list != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4826 qftf_li = qftf_list->lv_first; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4827 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4828 while (lnum < qfl->qf_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4829 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4830 char_u *qftf_str = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4831 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4832 // Use the text supplied by the user defined function (if any). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4833 // If the returned value is not string, then ignore the rest |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4834 // of the returned values and use the default. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4835 if (qftf_li != NULL && !invalid_val) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4836 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4837 qftf_str = tv_get_string_chk(&qftf_li->li_tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4838 if (qftf_str == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4839 invalid_val = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4840 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4841 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4842 if (qf_buf_add_line(buf, lnum, qfp, dirname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4843 prev_bufnr != qfp->qf_fnum, qftf_str) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4844 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4845 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4846 prev_bufnr = qfp->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4847 ++lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4848 qfp = qfp->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4849 if (qfp == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4850 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4851 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4852 if (qftf_li != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4853 qftf_li = qftf_li->li_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4854 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4855 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4856 if (old_last == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4857 // Delete the empty line which is now at the end |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4858 (void)ml_delete(lnum + 1); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4859 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4860 qfga_clear(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4861 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4862 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4863 // correct cursor position |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4864 check_lnums(TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4865 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4866 if (old_last == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4867 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4868 // Set the 'filetype' to "qf" each time after filling the buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4869 // This resembles reading a file into a buffer, it's more logical when |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4870 // using autocommands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4871 ++curbuf_lock; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4872 set_option_value_give_err((char_u *)"ft", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4873 0L, (char_u *)"qf", OPT_LOCAL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4874 curbuf->b_p_ma = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4875 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4876 keep_filetype = TRUE; // don't detect 'filetype' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4877 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4878 FALSE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4879 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4880 FALSE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4881 keep_filetype = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4882 --curbuf_lock; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4883 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4884 // make sure it will be redrawn |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4885 redraw_curbuf_later(UPD_NOT_VALID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4886 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4887 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4888 // Restore KeyTyped, setting 'filetype' may reset it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4889 KeyTyped = old_KeyTyped; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4890 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4891 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4892 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4893 * For every change made to the quickfix list, update the changed tick. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4894 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4895 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4896 qf_list_changed(qf_list_T *qfl) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4897 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4898 qfl->qf_changedtick++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4899 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4900 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4901 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4902 * Return the quickfix/location list number with the given identifier. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4903 * Returns -1 if list is not found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4904 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4905 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4906 qf_id2nr(qf_info_T *qi, int_u qfid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4907 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4908 int qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4909 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4910 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4911 if (qi->qf_lists[qf_idx].qf_id == qfid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4912 return qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4913 return INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4914 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4915 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4916 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4917 * If the current list is not "save_qfid" and we can find the list with that ID |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4918 * then make it the current list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4919 * This is used when autocommands may have changed the current list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4920 * Returns OK if successfully restored the list. Returns FAIL if the list with |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4921 * the specified identifier (save_qfid) is not found in the stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4922 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4923 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4924 qf_restore_list(qf_info_T *qi, int_u save_qfid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4925 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4926 int curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4927 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4928 if (qf_get_curlist(qi)->qf_id == save_qfid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4929 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4930 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4931 curlist = qf_id2nr(qi, save_qfid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4932 if (curlist < 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4933 // list is not present |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4934 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4935 qi->qf_curlist = curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4936 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4937 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4938 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4939 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4940 * Jump to the first entry if there is one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4941 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4942 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4943 qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4944 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4945 if (qf_restore_list(qi, save_qfid) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4946 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4947 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4948 // Autocommands might have cleared the list, check for that. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4949 if (!qf_list_empty(qf_get_curlist(qi))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4950 qf_jump(qi, 0, 0, forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4951 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4952 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4953 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4954 * Return TRUE when using ":vimgrep" for ":grep". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4955 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4956 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4957 grep_internal(cmdidx_T cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4958 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4959 return ((cmdidx == CMD_grep |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4960 || cmdidx == CMD_lgrep |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4961 || cmdidx == CMD_grepadd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4962 || cmdidx == CMD_lgrepadd) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4963 && STRCMP("internal", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4964 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4965 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4966 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4967 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4968 * Return the make/grep autocmd name. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4969 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4970 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4971 make_get_auname(cmdidx_T cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4972 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4973 switch (cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4974 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4975 case CMD_make: return (char_u *)"make"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4976 case CMD_lmake: return (char_u *)"lmake"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4977 case CMD_grep: return (char_u *)"grep"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4978 case CMD_lgrep: return (char_u *)"lgrep"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4979 case CMD_grepadd: return (char_u *)"grepadd"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4980 case CMD_lgrepadd: return (char_u *)"lgrepadd"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4981 default: return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4982 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4983 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4984 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4985 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4986 * Return the name for the errorfile, in allocated memory. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4987 * Find a new unique name when 'makeef' contains "##". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4988 * Returns NULL for error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4989 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4990 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4991 get_mef_name(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4992 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4993 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4994 char_u *name; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4995 static int start = -1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4996 static int off = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4997 #ifdef HAVE_LSTAT |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4998 stat_T sb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
4999 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5000 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5001 if (*p_mef == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5002 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5003 name = vim_tempname('e', FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5004 if (name == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5005 emsg(_(e_cant_get_temp_file_name)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5006 return name; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5007 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5008 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5009 for (p = p_mef; *p; ++p) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5010 if (p[0] == '#' && p[1] == '#') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5011 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5012 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5013 if (*p == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5014 return vim_strsave(p_mef); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5015 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5016 // Keep trying until the name doesn't exist yet. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5017 for (;;) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5018 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5019 if (start == -1) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5020 start = mch_get_pid(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5021 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5022 off += 19; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5023 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5024 name = alloc_id(STRLEN(p_mef) + 30, aid_qf_mef_name); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5025 if (name == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5026 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5027 STRCPY(name, p_mef); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5028 sprintf((char *)name + (p - p_mef), "%d%d", start, off); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5029 STRCAT(name, p + 2); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5030 if (mch_getperm(name) < 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5031 #ifdef HAVE_LSTAT |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5032 // Don't accept a symbolic link, it's a security risk. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5033 && mch_lstat((char *)name, &sb) < 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5034 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5035 ) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5036 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5037 vim_free(name); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5038 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5039 return name; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5040 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5041 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5042 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5043 * Form the complete command line to invoke 'make'/'grep'. Quote the command |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5044 * using 'shellquote' and append 'shellpipe'. Echo the fully formed command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5045 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5046 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5047 make_get_fullcmd(char_u *makecmd, char_u *fname) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5048 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5049 char_u *cmd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5050 unsigned len; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5051 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5052 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(makecmd) + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5053 if (*p_sp != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5054 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5055 cmd = alloc_id(len, aid_qf_makecmd); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5056 if (cmd == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5057 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5058 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)makecmd, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5059 (char *)p_shq); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5060 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5061 // If 'shellpipe' empty: don't redirect to 'errorfile'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5062 if (*p_sp != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5063 append_redir(cmd, len, p_sp, fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5064 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5065 // Display the fully formed command. Output a newline if there's something |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5066 // else than the :make command that was typed (in which case the cursor is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5067 // in column 0). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5068 if (msg_col == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5069 msg_didout = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5070 msg_start(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5071 msg_puts(":!"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5072 msg_outtrans(cmd); // show what we are doing |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5073 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5074 return cmd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5075 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5076 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5077 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5078 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5079 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5080 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5081 ex_make(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5082 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5083 char_u *fname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5084 char_u *cmd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5085 char_u *enc = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5086 win_T *wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5087 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5088 int res; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5089 char_u *au_name = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5090 int_u save_qfid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5091 char_u *errorformat = p_efm; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5092 int newlist = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5093 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5094 // Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5095 if (grep_internal(eap->cmdidx)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5096 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5097 ex_vimgrep(eap); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5098 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5099 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5100 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5101 au_name = make_get_auname(eap->cmdidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5102 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5103 curbuf->b_fname, TRUE, curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5104 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5105 #ifdef FEAT_EVAL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5106 if (aborting()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5107 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5108 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5109 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5110 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5111 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5112 if (is_loclist_cmd(eap->cmdidx)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5113 wp = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5114 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5115 autowrite_all(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5116 fname = get_mef_name(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5117 if (fname == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5118 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5119 mch_remove(fname); // in case it's not unique |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5120 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5121 cmd = make_get_fullcmd(eap->arg, fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5122 if (cmd == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5123 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5124 vim_free(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5125 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5126 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5127 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5128 // let the shell know if we are redirecting output or not |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5129 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5130 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5131 #ifdef AMIGA |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5132 out_flush(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5133 // read window status report and redraw before message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5134 (void)char_avail(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5135 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5136 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5137 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5138 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5139 if (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5140 errorformat = p_gefm; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5141 if (eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5142 newlist = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5143 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5144 res = qf_init(wp, fname, errorformat, newlist, qf_cmdtitle(*eap->cmdlinep), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5145 enc); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5146 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5147 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5148 qi = GET_LOC_LIST(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5149 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5150 goto cleanup; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5151 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5152 if (res >= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5153 qf_list_changed(qf_get_curlist(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5154 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5155 // Remember the current quickfix list identifier, so that we can |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5156 // check for autocommands changing the current quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5157 save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5158 if (au_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5159 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5160 curbuf->b_fname, TRUE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5161 if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5162 // display the first error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5163 qf_jump_first(qi, save_qfid, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5164 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5165 cleanup: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5166 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5167 mch_remove(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5168 vim_free(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5169 vim_free(cmd); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5170 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5171 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5172 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5173 * Returns the number of entries in the current quickfix/location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5174 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5175 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5176 qf_get_size(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5177 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5178 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5179 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5180 if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5181 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5182 return qf_get_curlist(qi)->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5183 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5184 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5185 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5186 * Returns the number of valid entries in the current quickfix/location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5187 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5188 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5189 qf_get_valid_size(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5190 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5191 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5192 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5193 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5194 int i, sz = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5195 int prev_fnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5196 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5197 if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5198 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5199 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5200 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5201 FOR_ALL_QFL_ITEMS(qfl, qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5202 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5203 if (qfp->qf_valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5204 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5205 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5206 sz++; // Count all valid entries |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5207 else if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5208 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5209 // Count the number of files |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5210 sz++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5211 prev_fnum = qfp->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5212 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5213 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5214 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5215 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5216 return sz; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5217 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5218 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5219 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5220 * Returns the current index of the quickfix/location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5221 * Returns 0 if there is an error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5222 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5223 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5224 qf_get_cur_idx(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5225 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5226 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5227 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5228 if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5229 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5230 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5231 return qf_get_curlist(qi)->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5232 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5233 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5234 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5235 * Returns the current index in the quickfix/location list (counting only valid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5236 * entries). If no valid entries are in the list, then returns 1. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5237 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5238 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5239 qf_get_cur_valid_idx(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5240 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5241 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5242 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5243 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5244 int i, eidx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5245 int prev_fnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5246 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5247 if ((qi = qf_cmd_get_stack(eap, FALSE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5248 return 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5249 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5250 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5251 qfp = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5252 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5253 // check if the list has valid errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5254 if (!qf_list_has_valid_entries(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5255 return 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5256 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5257 for (i = 1; i <= qfl->qf_index && qfp!= NULL; i++, qfp = qfp->qf_next) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5258 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5259 if (qfp->qf_valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5260 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5261 if (eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5262 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5263 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5264 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5265 // Count the number of files |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5266 eidx++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5267 prev_fnum = qfp->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5268 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5269 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5270 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5271 eidx++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5272 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5273 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5274 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5275 return eidx ? eidx : 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5276 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5277 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5278 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5279 * Get the 'n'th valid error entry in the quickfix or location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5280 * Used by :cdo, :ldo, :cfdo and :lfdo commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5281 * For :cdo and :ldo returns the 'n'th valid error entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5282 * For :cfdo and :lfdo returns the 'n'th valid file entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5283 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5284 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5285 qf_get_nth_valid_entry(qf_list_T *qfl, int n, int fdo) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5286 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5287 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5288 int i, eidx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5289 int prev_fnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5290 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5291 // check if the list has valid errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5292 if (!qf_list_has_valid_entries(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5293 return 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5294 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5295 eidx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5296 FOR_ALL_QFL_ITEMS(qfl, qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5297 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5298 if (qfp->qf_valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5299 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5300 if (fdo) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5301 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5302 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5303 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5304 // Count the number of files |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5305 eidx++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5306 prev_fnum = qfp->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5307 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5308 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5309 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5310 eidx++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5311 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5312 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5313 if (eidx == n) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5314 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5315 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5316 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5317 if (i <= qfl->qf_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5318 return i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5319 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5320 return 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5321 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5322 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5323 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5324 * ":cc", ":crewind", ":cfirst" and ":clast". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5325 * ":ll", ":lrewind", ":lfirst" and ":llast". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5326 * ":cdo", ":ldo", ":cfdo" and ":lfdo" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5327 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5328 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5329 ex_cc(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5330 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5331 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5332 int errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5333 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5334 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5335 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5336 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5337 if (eap->addr_count > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5338 errornr = (int)eap->line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5339 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5340 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5341 switch (eap->cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5342 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5343 case CMD_cc: case CMD_ll: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5344 errornr = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5345 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5346 case CMD_crewind: case CMD_lrewind: case CMD_cfirst: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5347 case CMD_lfirst: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5348 errornr = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5349 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5350 default: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5351 errornr = 32767; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5352 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5353 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5354 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5355 // For cdo and ldo commands, jump to the nth valid error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5356 // For cfdo and lfdo commands, jump to the nth valid file entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5357 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5358 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5359 errornr = qf_get_nth_valid_entry(qf_get_curlist(qi), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5360 eap->addr_count > 0 ? (int)eap->line1 : 1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5361 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5362 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5363 qf_jump(qi, 0, errornr, eap->forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5364 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5365 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5366 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5367 * ":cnext", ":cnfile", ":cNext" and ":cprevious". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5368 * ":lnext", ":lNext", ":lprevious", ":lnfile", ":lNfile" and ":lpfile". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5369 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5370 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5371 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5372 ex_cnext(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5373 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5374 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5375 int errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5376 int dir; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5377 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5378 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5379 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5380 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5381 if (eap->addr_count > 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5382 && (eap->cmdidx != CMD_cdo && eap->cmdidx != CMD_ldo |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5383 && eap->cmdidx != CMD_cfdo && eap->cmdidx != CMD_lfdo)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5384 errornr = (int)eap->line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5385 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5386 errornr = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5387 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5388 // Depending on the command jump to either next or previous entry/file. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5389 switch (eap->cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5390 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5391 case CMD_cnext: case CMD_lnext: case CMD_cdo: case CMD_ldo: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5392 dir = FORWARD; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5393 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5394 case CMD_cprevious: case CMD_lprevious: case CMD_cNext: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5395 case CMD_lNext: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5396 dir = BACKWARD; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5397 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5398 case CMD_cnfile: case CMD_lnfile: case CMD_cfdo: case CMD_lfdo: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5399 dir = FORWARD_FILE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5400 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5401 case CMD_cpfile: case CMD_lpfile: case CMD_cNfile: case CMD_lNfile: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5402 dir = BACKWARD_FILE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5403 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5404 default: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5405 dir = FORWARD; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5406 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5407 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5408 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5409 qf_jump(qi, dir, errornr, eap->forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5410 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5411 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5412 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5413 * Find the first entry in the quickfix list 'qfl' from buffer 'bnr'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5414 * The index of the entry is stored in 'errornr'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5415 * Returns NULL if an entry is not found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5416 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5417 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5418 qf_find_first_entry_in_buf(qf_list_T *qfl, int bnr, int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5419 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5420 qfline_T *qfp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5421 int idx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5422 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5423 // Find the first entry in this file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5424 FOR_ALL_QFL_ITEMS(qfl, qfp, idx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5425 if (qfp->qf_fnum == bnr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5426 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5427 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5428 *errornr = idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5429 return qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5430 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5431 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5432 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5433 * Find the first quickfix entry on the same line as 'entry'. Updates 'errornr' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5434 * with the error number for the first entry. Assumes the entries are sorted in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5435 * the quickfix list by line number. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5436 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5437 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5438 qf_find_first_entry_on_line(qfline_T *entry, int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5439 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5440 while (!got_int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5441 && entry->qf_prev != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5442 && entry->qf_fnum == entry->qf_prev->qf_fnum |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5443 && entry->qf_lnum == entry->qf_prev->qf_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5444 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5445 entry = entry->qf_prev; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5446 --*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5447 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5448 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5449 return entry; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5450 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5451 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5452 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5453 * Find the last quickfix entry on the same line as 'entry'. Updates 'errornr' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5454 * with the error number for the last entry. Assumes the entries are sorted in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5455 * the quickfix list by line number. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5456 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5457 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5458 qf_find_last_entry_on_line(qfline_T *entry, int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5459 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5460 while (!got_int && |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5461 entry->qf_next != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5462 && entry->qf_fnum == entry->qf_next->qf_fnum |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5463 && entry->qf_lnum == entry->qf_next->qf_lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5464 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5465 entry = entry->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5466 ++*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5467 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5468 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5469 return entry; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5470 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5471 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5472 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5473 * Returns TRUE if the specified quickfix entry is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5474 * after the given line (linewise is TRUE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5475 * or after the line and column. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5476 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5477 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5478 qf_entry_after_pos(qfline_T *qfp, pos_T *pos, int linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5479 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5480 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5481 return qfp->qf_lnum > pos->lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5482 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5483 return (qfp->qf_lnum > pos->lnum || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5484 (qfp->qf_lnum == pos->lnum && qfp->qf_col > pos->col)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5485 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5486 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5487 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5488 * Returns TRUE if the specified quickfix entry is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5489 * before the given line (linewise is TRUE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5490 * or before the line and column. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5491 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5492 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5493 qf_entry_before_pos(qfline_T *qfp, pos_T *pos, int linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5494 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5495 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5496 return qfp->qf_lnum < pos->lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5497 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5498 return (qfp->qf_lnum < pos->lnum || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5499 (qfp->qf_lnum == pos->lnum && qfp->qf_col < pos->col)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5500 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5501 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5502 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5503 * Returns TRUE if the specified quickfix entry is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5504 * on or after the given line (linewise is TRUE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5505 * or on or after the line and column. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5506 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5507 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5508 qf_entry_on_or_after_pos(qfline_T *qfp, pos_T *pos, int linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5509 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5510 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5511 return qfp->qf_lnum >= pos->lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5512 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5513 return (qfp->qf_lnum > pos->lnum || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5514 (qfp->qf_lnum == pos->lnum && qfp->qf_col >= pos->col)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5515 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5516 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5517 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5518 * Returns TRUE if the specified quickfix entry is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5519 * on or before the given line (linewise is TRUE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5520 * or on or before the line and column. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5521 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5522 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5523 qf_entry_on_or_before_pos(qfline_T *qfp, pos_T *pos, int linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5524 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5525 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5526 return qfp->qf_lnum <= pos->lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5527 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5528 return (qfp->qf_lnum < pos->lnum || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5529 (qfp->qf_lnum == pos->lnum && qfp->qf_col <= pos->col)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5530 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5531 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5532 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5533 * Find the first quickfix entry after position 'pos' in buffer 'bnr'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5534 * If 'linewise' is TRUE, returns the entry after the specified line and treats |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5535 * multiple entries on a single line as one. Otherwise returns the entry after |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5536 * the specified line and column. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5537 * 'qfp' points to the very first entry in the buffer and 'errornr' is the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5538 * index of the very first entry in the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5539 * Returns NULL if an entry is not found after 'pos'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5540 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5541 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5542 qf_find_entry_after_pos( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5543 int bnr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5544 pos_T *pos, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5545 int linewise, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5546 qfline_T *qfp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5547 int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5548 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5549 if (qf_entry_after_pos(qfp, pos, linewise)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5550 // First entry is after position 'pos' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5551 return qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5552 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5553 // Find the entry just before or at the position 'pos' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5554 while (qfp->qf_next != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5555 && qfp->qf_next->qf_fnum == bnr |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5556 && qf_entry_on_or_before_pos(qfp->qf_next, pos, linewise)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5557 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5558 qfp = qfp->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5559 ++*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5560 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5561 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5562 if (qfp->qf_next == NULL || qfp->qf_next->qf_fnum != bnr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5563 // No entries found after position 'pos' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5564 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5565 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5566 // Use the entry just after position 'pos' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5567 qfp = qfp->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5568 ++*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5569 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5570 return qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5571 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5572 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5573 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5574 * Find the first quickfix entry before position 'pos' in buffer 'bnr'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5575 * If 'linewise' is TRUE, returns the entry before the specified line and |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5576 * treats multiple entries on a single line as one. Otherwise returns the entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5577 * before the specified line and column. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5578 * 'qfp' points to the very first entry in the buffer and 'errornr' is the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5579 * index of the very first entry in the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5580 * Returns NULL if an entry is not found before 'pos'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5581 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5582 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5583 qf_find_entry_before_pos( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5584 int bnr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5585 pos_T *pos, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5586 int linewise, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5587 qfline_T *qfp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5588 int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5589 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5590 // Find the entry just before the position 'pos' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5591 while (qfp->qf_next != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5592 && qfp->qf_next->qf_fnum == bnr |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5593 && qf_entry_before_pos(qfp->qf_next, pos, linewise)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5594 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5595 qfp = qfp->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5596 ++*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5597 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5598 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5599 if (qf_entry_on_or_after_pos(qfp, pos, linewise)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5600 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5601 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5602 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5603 // If multiple entries are on the same line, then use the first entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5604 qfp = qf_find_first_entry_on_line(qfp, errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5605 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5606 return qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5607 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5608 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5609 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5610 * Find a quickfix entry in 'qfl' closest to position 'pos' in buffer 'bnr' in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5611 * the direction 'dir'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5612 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5613 static qfline_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5614 qf_find_closest_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5615 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5616 int bnr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5617 pos_T *pos, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5618 int dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5619 int linewise, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5620 int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5621 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5622 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5623 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5624 *errornr = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5625 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5626 // Find the first entry in this file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5627 qfp = qf_find_first_entry_in_buf(qfl, bnr, errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5628 if (qfp == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5629 return NULL; // no entry in this file |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5630 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5631 if (dir == FORWARD) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5632 qfp = qf_find_entry_after_pos(bnr, pos, linewise, qfp, errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5633 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5634 qfp = qf_find_entry_before_pos(bnr, pos, linewise, qfp, errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5635 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5636 return qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5637 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5638 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5639 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5640 * Get the nth quickfix entry below the specified entry. Searches forward in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5641 * the list. If linewise is TRUE, then treat multiple entries on a single line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5642 * as one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5643 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5644 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5645 qf_get_nth_below_entry(qfline_T *entry_arg, int n, int linewise, int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5646 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5647 qfline_T *entry = entry_arg; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5648 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5649 while (n-- > 0 && !got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5650 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5651 int first_errornr = *errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5652 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5653 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5654 // Treat all the entries on the same line in this file as one |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5655 entry = qf_find_last_entry_on_line(entry, errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5656 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5657 if (entry->qf_next == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5658 || entry->qf_next->qf_fnum != entry->qf_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5659 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5660 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5661 *errornr = first_errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5662 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5663 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5664 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5665 entry = entry->qf_next; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5666 ++*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5667 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5668 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5669 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5670 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5671 * Get the nth quickfix entry above the specified entry. Searches backwards in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5672 * the list. If linewise is TRUE, then treat multiple entries on a single line |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5673 * as one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5674 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5675 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5676 qf_get_nth_above_entry(qfline_T *entry, int n, int linewise, int *errornr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5677 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5678 while (n-- > 0 && !got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5679 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5680 if (entry->qf_prev == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5681 || entry->qf_prev->qf_fnum != entry->qf_fnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5682 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5683 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5684 entry = entry->qf_prev; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5685 --*errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5686 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5687 // If multiple entries are on the same line, then use the first entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5688 if (linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5689 entry = qf_find_first_entry_on_line(entry, errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5690 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5691 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5692 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5693 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5694 * Find the n'th quickfix entry adjacent to position 'pos' in buffer 'bnr' in |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5695 * the specified direction. Returns the error number in the quickfix list or 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5696 * if an entry is not found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5697 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5698 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5699 qf_find_nth_adj_entry( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5700 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5701 int bnr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5702 pos_T *pos, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5703 int n, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5704 int dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5705 int linewise) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5706 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5707 qfline_T *adj_entry; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5708 int errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5709 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5710 // Find an entry closest to the specified position |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5711 adj_entry = qf_find_closest_entry(qfl, bnr, pos, dir, linewise, &errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5712 if (adj_entry == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5713 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5714 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5715 if (--n > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5716 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5717 // Go to the n'th entry in the current buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5718 if (dir == FORWARD) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5719 qf_get_nth_below_entry(adj_entry, n, linewise, &errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5720 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5721 qf_get_nth_above_entry(adj_entry, n, linewise, &errornr); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5722 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5723 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5724 return errornr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5725 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5726 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5727 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5728 * Jump to a quickfix entry in the current file nearest to the current line or |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5729 * current line/col. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5730 * ":cabove", ":cbelow", ":labove", ":lbelow", ":cafter", ":cbefore", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5731 * ":lafter" and ":lbefore" commands |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5732 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5733 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5734 ex_cbelow(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5735 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5736 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5737 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5738 int dir; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5739 int buf_has_flag; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5740 int errornr = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5741 pos_T pos; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5742 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5743 if (eap->addr_count > 0 && eap->line2 <= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5744 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5745 emsg(_(e_invalid_range)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5746 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5747 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5748 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5749 // Check whether the current buffer has any quickfix entries |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5750 if (eap->cmdidx == CMD_cabove || eap->cmdidx == CMD_cbelow |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5751 || eap->cmdidx == CMD_cbefore || eap->cmdidx == CMD_cafter) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5752 buf_has_flag = BUF_HAS_QF_ENTRY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5753 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5754 buf_has_flag = BUF_HAS_LL_ENTRY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5755 if (!(curbuf->b_has_qf_entry & buf_has_flag)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5756 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5757 emsg(_(e_no_errors)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5758 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5759 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5760 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5761 if ((qi = qf_cmd_get_stack(eap, TRUE)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5762 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5763 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5764 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5765 // check if the list has valid errors |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5766 if (!qf_list_has_valid_entries(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5767 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5768 emsg(_(e_no_errors)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5769 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5770 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5771 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5772 if (eap->cmdidx == CMD_cbelow |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5773 || eap->cmdidx == CMD_lbelow |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5774 || eap->cmdidx == CMD_cafter |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5775 || eap->cmdidx == CMD_lafter) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5776 // Forward motion commands |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5777 dir = FORWARD; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5778 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5779 dir = BACKWARD; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5780 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5781 pos = curwin->w_cursor; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5782 // A quickfix entry column number is 1 based whereas cursor column |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5783 // number is 0 based. Adjust the column number. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5784 pos.col++; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5785 errornr = qf_find_nth_adj_entry(qfl, curbuf->b_fnum, &pos, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5786 eap->addr_count > 0 ? eap->line2 : 0, dir, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5787 eap->cmdidx == CMD_cbelow |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5788 || eap->cmdidx == CMD_lbelow |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5789 || eap->cmdidx == CMD_cabove |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5790 || eap->cmdidx == CMD_labove); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5791 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5792 if (errornr > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5793 qf_jump(qi, 0, errornr, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5794 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5795 emsg(_(e_no_more_items)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5796 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5797 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5798 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5799 * Return the autocmd name for the :cfile Ex commands |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5800 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5801 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5802 cfile_get_auname(cmdidx_T cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5803 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5804 switch (cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5805 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5806 case CMD_cfile: return (char_u *)"cfile"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5807 case CMD_cgetfile: return (char_u *)"cgetfile"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5808 case CMD_caddfile: return (char_u *)"caddfile"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5809 case CMD_lfile: return (char_u *)"lfile"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5810 case CMD_lgetfile: return (char_u *)"lgetfile"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5811 case CMD_laddfile: return (char_u *)"laddfile"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5812 default: return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5813 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5814 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5815 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5816 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5817 * ":cfile"/":cgetfile"/":caddfile" commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5818 * ":lfile"/":lgetfile"/":laddfile" commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5819 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5820 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5821 ex_cfile(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5822 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5823 char_u *enc = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5824 win_T *wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5825 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5826 char_u *au_name = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5827 int_u save_qfid = 0; // init for gcc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5828 int res; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5829 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5830 au_name = cfile_get_auname(eap->cmdidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5831 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5832 NULL, FALSE, curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5833 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5834 #ifdef FEAT_EVAL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5835 if (aborting()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5836 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5837 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5838 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5839 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5840 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5841 #ifdef FEAT_BROWSE |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5842 if (cmdmod.cmod_flags & CMOD_BROWSE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5843 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5844 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5845 NULL, NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5846 (char_u *)_(BROWSE_FILTER_ALL_FILES), NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5847 if (browse_file == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5848 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5849 set_string_option_direct((char_u *)"ef", -1, browse_file, OPT_FREE, 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5850 vim_free(browse_file); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5851 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5852 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5853 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5854 if (*eap->arg != NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5855 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5856 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5857 if (is_loclist_cmd(eap->cmdidx)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5858 wp = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5859 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5860 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5861 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5862 // This function is used by the :cfile, :cgetfile and :caddfile |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5863 // commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5864 // :cfile always creates a new quickfix list and jumps to the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5865 // first error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5866 // :cgetfile creates a new quickfix list but doesn't jump to the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5867 // first error. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5868 // :caddfile adds to an existing quickfix list. If there is no |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5869 // quickfix list then a new list is created. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5870 res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5871 && eap->cmdidx != CMD_laddfile), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5872 qf_cmdtitle(*eap->cmdlinep), enc); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5873 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5874 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5875 qi = GET_LOC_LIST(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5876 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5877 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5878 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5879 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5880 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5881 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5882 if (res >= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5883 qf_list_changed(qf_get_curlist(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5884 save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5885 if (au_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5886 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5887 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5888 // Jump to the first error for a new list and if autocmds didn't |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5889 // free the list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5890 if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5891 && qflist_valid(wp, save_qfid)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5892 // display the first error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5893 qf_jump_first(qi, save_qfid, eap->forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5894 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5895 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5896 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5897 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5898 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5899 * Return the vimgrep autocmd name. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5900 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5901 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5902 vgr_get_auname(cmdidx_T cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5903 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5904 switch (cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5905 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5906 case CMD_vimgrep: return (char_u *)"vimgrep"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5907 case CMD_lvimgrep: return (char_u *)"lvimgrep"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5908 case CMD_vimgrepadd: return (char_u *)"vimgrepadd"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5909 case CMD_lvimgrepadd: return (char_u *)"lvimgrepadd"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5910 case CMD_grep: return (char_u *)"grep"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5911 case CMD_lgrep: return (char_u *)"lgrep"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5912 case CMD_grepadd: return (char_u *)"grepadd"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5913 case CMD_lgrepadd: return (char_u *)"lgrepadd"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5914 default: return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5915 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5916 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5917 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5918 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5919 * Initialize the regmatch used by vimgrep for pattern "s". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5920 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5921 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5922 vgr_init_regmatch(regmmatch_T *regmatch, char_u *s) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5923 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5924 // Get the search pattern: either white-separated or enclosed in // |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5925 regmatch->regprog = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5926 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5927 if (s == NULL || *s == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5928 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5929 // Pattern is empty, use last search pattern. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5930 if (last_search_pat() == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5931 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5932 emsg(_(e_no_previous_regular_expression)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5933 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5934 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5935 regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5936 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5937 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5938 regmatch->regprog = vim_regcomp(s, RE_MAGIC); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5939 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5940 regmatch->rmm_ic = p_ic; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5941 regmatch->rmm_maxcol = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5942 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5943 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5944 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5945 * Display a file name when vimgrep is running. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5946 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5947 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5948 vgr_display_fname(char_u *fname) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5949 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5950 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5951 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5952 msg_start(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5953 p = msg_strtrunc(fname, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5954 if (p == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5955 msg_outtrans(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5956 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5957 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5958 msg_outtrans(p); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5959 vim_free(p); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5960 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5961 msg_clr_eos(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5962 msg_didout = FALSE; // overwrite this message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5963 msg_nowait = TRUE; // don't wait for this message |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5964 msg_col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5965 out_flush(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5966 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5967 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5968 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5969 * Load a dummy buffer to search for a pattern using vimgrep. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5970 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5971 static buf_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5972 vgr_load_dummy_buf( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5973 char_u *fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5974 char_u *dirname_start, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5975 char_u *dirname_now) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5976 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5977 int save_mls; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5978 #if defined(FEAT_SYN_HL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5979 char_u *save_ei = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5980 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5981 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5982 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5983 #if defined(FEAT_SYN_HL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5984 // Don't do Filetype autocommands to avoid loading syntax and |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5985 // indent scripts, a great speed improvement. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5986 save_ei = au_event_disable(",Filetype"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5987 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5988 // Don't use modelines here, it's useless. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5989 save_mls = p_mls; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5990 p_mls = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5991 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5992 // Load file into a buffer, so that 'fileencoding' is detected, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5993 // autocommands applied, etc. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5994 buf = load_dummy_buffer(fname, dirname_start, dirname_now); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5995 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5996 p_mls = save_mls; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5997 #if defined(FEAT_SYN_HL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5998 au_event_restore(save_ei); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
5999 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6000 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6001 return buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6002 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6003 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6004 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6005 * Check whether a quickfix/location list is valid. Autocmds may remove or |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6006 * change a quickfix list when vimgrep is running. If the list is not found, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6007 * create a new list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6008 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6009 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6010 vgr_qflist_valid( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6011 win_T *wp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6012 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6013 int_u qfid, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6014 char_u *title) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6015 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6016 // Verify that the quickfix/location list was not freed by an autocmd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6017 if (!qflist_valid(wp, qfid)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6018 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6019 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6020 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6021 // An autocmd has freed the location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6022 emsg(_(e_current_location_list_was_changed)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6023 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6024 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6025 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6026 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6027 // Quickfix list is not found, create a new one. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6028 qf_new_list(qi, title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6029 return TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6030 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6031 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6032 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6033 if (qf_restore_list(qi, qfid) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6034 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6035 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6036 return TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6037 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6038 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6039 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6040 * Search for a pattern in all the lines in a buffer and add the matching lines |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6041 * to a quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6042 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6043 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6044 vgr_match_buflines( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6045 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6046 char_u *fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6047 buf_T *buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6048 char_u *spat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6049 regmmatch_T *regmatch, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6050 long *tomatch, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6051 int duplicate_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6052 int flags) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6053 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6054 int found_match = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6055 long lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6056 colnr_T col; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6057 int pat_len = (int)STRLEN(spat); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6058 if (pat_len > MAX_FUZZY_MATCHES) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6059 pat_len = MAX_FUZZY_MATCHES; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6060 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6061 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; ++lnum) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6062 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6063 col = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6064 if (!(flags & VGR_FUZZY)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6065 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6066 // Regular expression match |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6067 while (vim_regexec_multi(regmatch, curwin, buf, lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6068 col, NULL) > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6069 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6070 // Pass the buffer number so that it gets used even for a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6071 // dummy buffer, unless duplicate_name is set, then the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6072 // buffer will be wiped out below. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6073 if (qf_add_entry(qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6074 NULL, // dir |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6075 fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6076 NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6077 duplicate_name ? 0 : buf->b_fnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6078 ml_get_buf(buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6079 regmatch->startpos[0].lnum + lnum, FALSE), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6080 regmatch->startpos[0].lnum + lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6081 regmatch->endpos[0].lnum + lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6082 regmatch->startpos[0].col + 1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6083 regmatch->endpos[0].col + 1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6084 FALSE, // vis_col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6085 NULL, // search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6086 0, // nr |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6087 0, // type |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6088 TRUE // valid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6089 ) == QF_FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6090 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6091 got_int = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6092 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6093 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6094 found_match = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6095 if (--*tomatch == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6096 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6097 if ((flags & VGR_GLOBAL) == 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6098 || regmatch->endpos[0].lnum > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6099 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6100 col = regmatch->endpos[0].col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6101 + (col == regmatch->endpos[0].col); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6102 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6103 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6104 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6105 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6106 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6107 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6108 char_u *str = ml_get_buf(buf, lnum, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6109 int score; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6110 int_u matches[MAX_FUZZY_MATCHES]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6111 int_u sz = ARRAY_LENGTH(matches); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6112 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6113 // Fuzzy string match |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6114 CLEAR_FIELD(matches); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6115 while (fuzzy_match(str + col, spat, FALSE, &score, matches, sz) > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6116 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6117 // Pass the buffer number so that it gets used even for a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6118 // dummy buffer, unless duplicate_name is set, then the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6119 // buffer will be wiped out below. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6120 if (qf_add_entry(qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6121 NULL, // dir |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6122 fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6123 NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6124 duplicate_name ? 0 : buf->b_fnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6125 str, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6126 lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6127 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6128 matches[0] + col + 1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6129 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6130 FALSE, // vis_col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6131 NULL, // search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6132 0, // nr |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6133 0, // type |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6134 TRUE // valid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6135 ) == QF_FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6136 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6137 got_int = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6138 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6139 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6140 found_match = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6141 if (--*tomatch == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6142 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6143 if ((flags & VGR_GLOBAL) == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6144 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6145 col = matches[pat_len - 1] + col + 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6146 if (col > (colnr_T)STRLEN(str)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6147 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6148 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6149 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6150 line_breakcheck(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6151 if (got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6152 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6153 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6154 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6155 return found_match; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6156 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6157 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6158 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6159 * Jump to the first match and update the directory. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6160 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6161 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6162 vgr_jump_to_match( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6163 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6164 int forceit, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6165 int *redraw_for_dummy, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6166 buf_T *first_match_buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6167 char_u *target_dir) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6168 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6169 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6170 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6171 buf = curbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6172 qf_jump(qi, 0, 0, forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6173 if (buf != curbuf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6174 // If we jumped to another buffer redrawing will already be |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6175 // taken care of. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6176 *redraw_for_dummy = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6177 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6178 // Jump to the directory used after loading the buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6179 if (curbuf == first_match_buf && target_dir != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6180 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6181 exarg_T ea; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6182 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6183 CLEAR_FIELD(ea); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6184 ea.arg = target_dir; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6185 ea.cmdidx = CMD_lcd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6186 ex_cd(&ea); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6187 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6188 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6189 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6190 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6191 * :vimgrep command arguments |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6192 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6193 typedef struct |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6194 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6195 long tomatch; // maximum number of matches to find |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6196 char_u *spat; // search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6197 int flags; // search modifier |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6198 char_u **fnames; // list of files to search |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6199 int fcount; // number of files |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6200 regmmatch_T regmatch; // compiled search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6201 char_u *qf_title; // quickfix list title |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6202 } vgr_args_T; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6203 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6204 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6205 * Process :vimgrep command arguments. The command syntax is: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6206 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6207 * :{count}vimgrep /{pattern}/[g][j] {file} ... |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6208 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6209 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6210 vgr_process_args( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6211 exarg_T *eap, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6212 vgr_args_T *args) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6213 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6214 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6215 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6216 CLEAR_POINTER(args); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6217 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6218 args->regmatch.regprog = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6219 args->qf_title = vim_strsave(qf_cmdtitle(*eap->cmdlinep)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6220 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6221 if (eap->addr_count > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6222 args->tomatch = eap->line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6223 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6224 args->tomatch = MAXLNUM; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6225 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6226 // Get the search pattern: either white-separated or enclosed in // |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6227 p = skip_vimgrep_pat(eap->arg, &args->spat, &args->flags); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6228 if (p == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6229 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6230 emsg(_(e_invalid_search_pattern_or_delimiter)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6231 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6232 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6233 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6234 vgr_init_regmatch(&args->regmatch, args->spat); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6235 if (args->regmatch.regprog == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6236 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6237 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6238 p = skipwhite(p); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6239 if (*p == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6240 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6241 emsg(_(e_file_name_missing_or_invalid_pattern)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6242 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6243 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6244 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6245 // Parse the list of arguments, wildcards have already been expanded. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6246 if ((get_arglist_exp(p, &args->fcount, &args->fnames, TRUE) == FAIL) || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6247 args->fcount == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6248 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6249 emsg(_(e_no_match)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6250 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6251 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6252 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6253 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6254 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6255 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6256 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6257 * Return TRUE if "buf" had an existing swap file, the current swap file does |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6258 * not end in ".swp". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6259 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6260 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6261 existing_swapfile(buf_T *buf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6262 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6263 if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6264 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6265 char_u *fname = buf->b_ml.ml_mfp->mf_fname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6266 size_t len = STRLEN(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6267 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6268 return fname[len - 1] != 'p' || fname[len - 2] != 'w'; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6269 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6270 return FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6271 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6272 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6273 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6274 * Search for a pattern in a list of files and populate the quickfix list with |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6275 * the matches. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6276 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6277 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6278 vgr_process_files( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6279 win_T *wp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6280 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6281 vgr_args_T *cmd_args, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6282 int *redraw_for_dummy, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6283 buf_T **first_match_buf, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6284 char_u **target_dir) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6285 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6286 int status = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6287 int_u save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6288 time_t seconds = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6289 char_u *fname; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6290 int fi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6291 buf_T *buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6292 int duplicate_name = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6293 int using_dummy; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6294 char_u *dirname_start = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6295 char_u *dirname_now = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6296 int found_match; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6297 aco_save_T aco; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6298 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6299 dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6300 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6301 if (dirname_start == NULL || dirname_now == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6302 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6303 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6304 // Remember the current directory, because a BufRead autocommand that does |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6305 // ":lcd %:p:h" changes the meaning of short path names. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6306 mch_dirname(dirname_start, MAXPATHL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6307 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6308 seconds = (time_t)0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6309 for (fi = 0; fi < cmd_args->fcount && !got_int && cmd_args->tomatch > 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6310 ++fi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6311 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6312 fname = shorten_fname1(cmd_args->fnames[fi]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6313 if (time(NULL) > seconds) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6314 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6315 // Display the file name every second or so, show the user we are |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6316 // working on it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6317 seconds = time(NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6318 vgr_display_fname(fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6319 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6320 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6321 buf = buflist_findname_exp(cmd_args->fnames[fi]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6322 if (buf == NULL || buf->b_ml.ml_mfp == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6323 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6324 // Remember that a buffer with this name already exists. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6325 duplicate_name = (buf != NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6326 using_dummy = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6327 *redraw_for_dummy = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6328 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6329 buf = vgr_load_dummy_buf(fname, dirname_start, dirname_now); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6330 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6331 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6332 // Use existing, loaded buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6333 using_dummy = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6334 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6335 // Check whether the quickfix list is still valid. When loading a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6336 // buffer above, autocommands might have changed the quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6337 if (!vgr_qflist_valid(wp, qi, save_qfid, cmd_args->qf_title)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6338 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6339 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6340 save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6341 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6342 if (buf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6343 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6344 if (!got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6345 smsg(_("Cannot open file \"%s\""), fname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6346 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6347 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6348 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6349 // Try for a match in all lines of the buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6350 // For ":1vimgrep" look for first match only. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6351 found_match = vgr_match_buflines(qf_get_curlist(qi), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6352 fname, buf, cmd_args->spat, &cmd_args->regmatch, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6353 &cmd_args->tomatch, duplicate_name, cmd_args->flags); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6354 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6355 if (using_dummy) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6356 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6357 if (found_match && *first_match_buf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6358 *first_match_buf = buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6359 if (duplicate_name) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6360 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6361 // Never keep a dummy buffer if there is another buffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6362 // with the same name. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6363 wipe_dummy_buffer(buf, dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6364 buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6365 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6366 else if ((cmdmod.cmod_flags & CMOD_HIDE) == 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6367 || buf->b_p_bh[0] == 'u' // "unload" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6368 || buf->b_p_bh[0] == 'w' // "wipe" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6369 || buf->b_p_bh[0] == 'd') // "delete" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6370 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6371 // When no match was found we don't need to remember the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6372 // buffer, wipe it out. If there was a match and it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6373 // wasn't the first one or we won't jump there: only |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6374 // unload the buffer. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6375 // Ignore 'hidden' here, because it may lead to having too |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6376 // many swap files. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6377 if (!found_match) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6378 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6379 wipe_dummy_buffer(buf, dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6380 buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6381 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6382 else if (buf != *first_match_buf |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6383 || (cmd_args->flags & VGR_NOJUMP) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6384 || existing_swapfile(buf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6385 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6386 unload_dummy_buffer(buf, dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6387 // Keeping the buffer, remove the dummy flag. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6388 buf->b_flags &= ~BF_DUMMY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6389 buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6390 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6391 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6392 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6393 if (buf != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6394 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6395 // Keeping the buffer, remove the dummy flag. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6396 buf->b_flags &= ~BF_DUMMY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6397 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6398 // If the buffer is still loaded we need to use the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6399 // directory we jumped to below. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6400 if (buf == *first_match_buf |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6401 && *target_dir == NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6402 && STRCMP(dirname_start, dirname_now) != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6403 *target_dir = vim_strsave(dirname_now); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6404 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6405 // The buffer is still loaded, the Filetype autocommands |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6406 // need to be done now, in that buffer. And the modelines |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6407 // need to be done (again). But not the window-local |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6408 // options! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6409 aucmd_prepbuf(&aco, buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6410 if (curbuf == buf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6411 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6412 #if defined(FEAT_SYN_HL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6413 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6414 buf->b_fname, TRUE, buf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6415 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6416 do_modelines(OPT_NOWIN); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6417 aucmd_restbuf(&aco); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6418 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6419 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6420 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6421 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6422 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6423 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6424 status = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6425 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6426 theend: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6427 vim_free(dirname_now); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6428 vim_free(dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6429 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6430 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6431 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6432 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6433 * ":vimgrep {pattern} file(s)" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6434 * ":vimgrepadd {pattern} file(s)" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6435 * ":lvimgrep {pattern} file(s)" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6436 * ":lvimgrepadd {pattern} file(s)" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6437 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6438 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6439 ex_vimgrep(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6440 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6441 vgr_args_T args; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6442 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6443 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6444 int_u save_qfid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6445 win_T *wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6446 int redraw_for_dummy = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6447 buf_T *first_match_buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6448 char_u *target_dir = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6449 char_u *au_name = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6450 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6451 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6452 au_name = vgr_get_auname(eap->cmdidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6453 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6454 curbuf->b_fname, TRUE, curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6455 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6456 #ifdef FEAT_EVAL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6457 if (aborting()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6458 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6459 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6460 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6461 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6462 qi = qf_cmd_get_or_alloc_stack(eap, &wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6463 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6464 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6465 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6466 if (vgr_process_args(eap, &args) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6467 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6468 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6469 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6470 && eap->cmdidx != CMD_vimgrepadd |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6471 && eap->cmdidx != CMD_lvimgrepadd) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6472 || qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6473 // make place for a new list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6474 qf_new_list(qi, args.qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6475 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6476 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6477 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6478 status = vgr_process_files(wp, qi, &args, &redraw_for_dummy, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6479 &first_match_buf, &target_dir); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6480 if (status != OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6481 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6482 FreeWild(args.fcount, args.fnames); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6483 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6484 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6485 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6486 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6487 FreeWild(args.fcount, args.fnames); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6488 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6489 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6490 qfl->qf_nonevalid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6491 qfl->qf_ptr = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6492 qfl->qf_index = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6493 qf_list_changed(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6494 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6495 qf_update_buffer(qi, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6496 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6497 // Remember the current quickfix list identifier, so that we can check for |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6498 // autocommands changing the current quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6499 save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6500 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6501 if (au_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6502 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6503 curbuf->b_fname, TRUE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6504 // The QuickFixCmdPost autocmd may free the quickfix list. Check the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6505 // is still valid. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6506 if (!qflist_valid(wp, save_qfid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6507 || qf_restore_list(qi, save_qfid) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6508 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6509 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6510 goto theend; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6511 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6512 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6513 // Jump to first match. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6514 if (!qf_list_empty(qf_get_curlist(qi))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6515 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6516 if ((args.flags & VGR_NOJUMP) == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6517 vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6518 first_match_buf, target_dir); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6519 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6520 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6521 semsg(_(e_no_match_str_2), args.spat); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6522 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6523 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6524 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6525 // If we loaded a dummy buffer into the current window, the autocommands |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6526 // may have messed up things, need to redraw and recompute folds. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6527 if (redraw_for_dummy) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6528 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6529 #ifdef FEAT_FOLDING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6530 foldUpdateAll(curwin); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6531 #else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6532 redraw_later(UPD_NOT_VALID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6533 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6534 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6535 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6536 theend: |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6537 vim_free(args.qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6538 vim_free(target_dir); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6539 vim_regfree(args.regmatch.regprog); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6540 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6541 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6542 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6543 * Restore current working directory to "dirname_start" if they differ, taking |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6544 * into account whether it is set locally or globally. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6545 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6546 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6547 restore_start_dir(char_u *dirname_start) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6548 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6549 char_u *dirname_now = alloc(MAXPATHL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6550 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6551 if (dirname_now == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6552 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6553 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6554 mch_dirname(dirname_now, MAXPATHL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6555 if (STRCMP(dirname_start, dirname_now) != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6556 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6557 // If the directory has changed, change it back by building up an |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6558 // appropriate ex command and executing it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6559 exarg_T ea; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6560 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6561 CLEAR_FIELD(ea); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6562 ea.arg = dirname_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6563 ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6564 ex_cd(&ea); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6565 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6566 vim_free(dirname_now); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6567 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6568 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6569 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6570 * Load file "fname" into a dummy buffer and return the buffer pointer, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6571 * placing the directory resulting from the buffer load into the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6572 * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6573 * prior to calling this function. Restores directory to "dirname_start" prior |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6574 * to returning, if autocmds or the 'autochdir' option have changed it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6575 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6576 * If creating the dummy buffer does not fail, must call unload_dummy_buffer() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6577 * or wipe_dummy_buffer() later! |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6578 * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6579 * Returns NULL if it fails. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6580 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6581 static buf_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6582 load_dummy_buffer( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6583 char_u *fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6584 char_u *dirname_start, // in: old directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6585 char_u *resulting_dir) // out: new directory |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6586 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6587 buf_T *newbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6588 bufref_T newbufref; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6589 bufref_T newbuf_to_wipe; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6590 int failed = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6591 aco_save_T aco; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6592 int readfile_result; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6593 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6594 // Allocate a buffer without putting it in the buffer list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6595 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6596 if (newbuf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6597 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6598 set_bufref(&newbufref, newbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6599 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6600 // Init the options. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6601 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6602 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6603 // need to open the memfile before putting the buffer in a window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6604 if (ml_open(newbuf) == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6605 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6606 // Make sure this buffer isn't wiped out by autocommands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6607 ++newbuf->b_locked; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6608 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6609 // set curwin/curbuf to buf and save a few things |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6610 aucmd_prepbuf(&aco, newbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6611 if (curbuf == newbuf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6612 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6613 // Need to set the filename for autocommands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6614 (void)setfname(curbuf, fname, NULL, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6615 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6616 // Create swap file now to avoid the ATTENTION message. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6617 check_need_swap(TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6618 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6619 // Remove the "dummy" flag, otherwise autocommands may not |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6620 // work. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6621 curbuf->b_flags &= ~BF_DUMMY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6622 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6623 newbuf_to_wipe.br_buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6624 readfile_result = readfile(fname, NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6625 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6626 NULL, READ_NEW | READ_DUMMY); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6627 --newbuf->b_locked; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6628 if (readfile_result == OK |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6629 && !got_int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6630 && !(curbuf->b_flags & BF_NEW)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6631 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6632 failed = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6633 if (curbuf != newbuf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6634 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6635 // Bloody autocommands changed the buffer! Can happen when |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6636 // using netrw and editing a remote file. Use the current |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6637 // buffer instead, delete the dummy one after restoring the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6638 // window stuff. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6639 set_bufref(&newbuf_to_wipe, newbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6640 newbuf = curbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6641 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6642 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6643 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6644 // restore curwin/curbuf and a few other things |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6645 aucmd_restbuf(&aco); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6646 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6647 if (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6648 wipe_buffer(newbuf_to_wipe.br_buf, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6649 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6650 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6651 // Add back the "dummy" flag, otherwise buflist_findname_stat() won't |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6652 // skip it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6653 newbuf->b_flags |= BF_DUMMY; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6654 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6655 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6656 // When autocommands/'autochdir' option changed directory: go back. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6657 // Let the caller know what the resulting dir was first, in case it is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6658 // important. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6659 mch_dirname(resulting_dir, MAXPATHL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6660 restore_start_dir(dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6661 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6662 if (!bufref_valid(&newbufref)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6663 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6664 if (failed) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6665 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6666 wipe_dummy_buffer(newbuf, dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6667 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6668 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6669 return newbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6670 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6671 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6672 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6673 * Wipe out the dummy buffer that load_dummy_buffer() created. Restores |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6674 * directory to "dirname_start" prior to returning, if autocmds or the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6675 * 'autochdir' option have changed it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6676 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6677 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6678 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6679 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6680 // If any autocommand opened a window on the dummy buffer, close that |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6681 // window. If we can't close them all then give up. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6682 while (buf->b_nwindows > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6683 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6684 int did_one = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6685 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6686 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6687 if (firstwin->w_next != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6688 FOR_ALL_WINDOWS(wp) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6689 if (wp->w_buffer == buf) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6690 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6691 if (win_close(wp, FALSE) == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6692 did_one = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6693 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6694 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6695 if (!did_one) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6696 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6697 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6698 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6699 if (curbuf != buf && buf->b_nwindows == 0) // safety check |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6700 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6701 #if defined(FEAT_EVAL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6702 cleanup_T cs; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6703 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6704 // Reset the error/interrupt/exception state here so that aborting() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6705 // returns FALSE when wiping out the buffer. Otherwise it doesn't |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6706 // work when got_int is set. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6707 enter_cleanup(&cs); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6708 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6709 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6710 wipe_buffer(buf, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6711 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6712 #if defined(FEAT_EVAL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6713 // Restore the error/interrupt/exception state if not discarded by a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6714 // new aborting error, interrupt, or uncaught exception. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6715 leave_cleanup(&cs); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6716 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6717 // When autocommands/'autochdir' option changed directory: go back. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6718 restore_start_dir(dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6719 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6720 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6721 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6722 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6723 * Unload the dummy buffer that load_dummy_buffer() created. Restores |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6724 * directory to "dirname_start" prior to returning, if autocmds or the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6725 * 'autochdir' option have changed it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6726 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6727 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6728 unload_dummy_buffer(buf_T *buf, char_u *dirname_start) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6729 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6730 if (curbuf == buf) // safety check |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6731 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6732 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6733 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE, TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6734 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6735 // When autocommands/'autochdir' option changed directory: go back. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6736 restore_start_dir(dirname_start); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6737 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6738 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6739 #if defined(FEAT_EVAL) || defined(PROTO) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6740 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6741 * Copy the specified quickfix entry items into a new dict and append the dict |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6742 * to 'list'. Returns OK on success. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6743 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6744 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6745 get_qfline_items(qfline_T *qfp, list_T *list) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6746 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6747 int bufnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6748 dict_T *dict; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6749 char_u buf[2]; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6750 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6751 // Handle entries with a non-existing buffer number. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6752 bufnum = qfp->qf_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6753 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6754 bufnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6755 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6756 if ((dict = dict_alloc()) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6757 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6758 if (list_append_dict(list, dict) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6759 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6760 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6761 buf[0] = qfp->qf_type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6762 buf[1] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6763 if (dict_add_number(dict, "bufnr", (long)bufnum) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6764 || dict_add_number(dict, "lnum", (long)qfp->qf_lnum) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6765 || dict_add_number(dict, "end_lnum", (long)qfp->qf_end_lnum) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6766 || dict_add_number(dict, "col", (long)qfp->qf_col) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6767 || dict_add_number(dict, "end_col", (long)qfp->qf_end_col) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6768 || dict_add_number(dict, "vcol", (long)qfp->qf_viscol) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6769 || dict_add_number(dict, "nr", (long)qfp->qf_nr) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6770 || dict_add_string(dict, "module", qfp->qf_module) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6771 || dict_add_string(dict, "pattern", qfp->qf_pattern) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6772 || dict_add_string(dict, "text", qfp->qf_text) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6773 || dict_add_string(dict, "type", buf) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6774 || dict_add_number(dict, "valid", (long)qfp->qf_valid) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6775 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6776 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6777 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6778 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6779 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6780 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6781 * Add each quickfix error to list "list" as a dictionary. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6782 * If qf_idx is -1, use the current list. Otherwise, use the specified list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6783 * If eidx is not 0, then return only the specified entry. Otherwise return |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6784 * all the entries. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6785 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6786 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6787 get_errorlist( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6788 qf_info_T *qi_arg, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6789 win_T *wp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6790 int qf_idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6791 int eidx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6792 list_T *list) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6793 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6794 qf_info_T *qi = qi_arg; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6795 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6796 qfline_T *qfp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6797 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6798 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6799 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6800 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6801 qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6802 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6803 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6804 qi = GET_LOC_LIST(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6805 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6806 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6807 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6808 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6809 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6810 if (eidx < 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6811 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6812 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6813 if (qf_idx == INVALID_QFIDX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6814 qf_idx = qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6815 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6816 if (qf_idx >= qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6817 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6818 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6819 qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6820 if (qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6821 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6822 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6823 FOR_ALL_QFL_ITEMS(qfl, qfp, i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6824 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6825 if (eidx > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6826 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6827 if (eidx == i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6828 return get_qfline_items(qfp, list); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6829 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6830 else if (get_qfline_items(qfp, list) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6831 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6832 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6833 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6834 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6835 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6836 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6837 // Flags used by getqflist()/getloclist() to determine which fields to return. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6838 enum { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6839 QF_GETLIST_NONE = 0x0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6840 QF_GETLIST_TITLE = 0x1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6841 QF_GETLIST_ITEMS = 0x2, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6842 QF_GETLIST_NR = 0x4, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6843 QF_GETLIST_WINID = 0x8, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6844 QF_GETLIST_CONTEXT = 0x10, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6845 QF_GETLIST_ID = 0x20, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6846 QF_GETLIST_IDX = 0x40, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6847 QF_GETLIST_SIZE = 0x80, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6848 QF_GETLIST_TICK = 0x100, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6849 QF_GETLIST_FILEWINID = 0x200, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6850 QF_GETLIST_QFBUFNR = 0x400, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6851 QF_GETLIST_QFTF = 0x800, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6852 QF_GETLIST_ALL = 0xFFF, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6853 }; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6854 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6855 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6856 * Parse text from 'di' and return the quickfix list items. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6857 * Existing quickfix lists are not modified. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6858 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6859 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6860 qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6861 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6862 int status = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6863 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6864 char_u *errorformat = p_efm; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6865 dictitem_T *efm_di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6866 list_T *l; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6867 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6868 // Only a List value is supported |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6869 if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6870 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6871 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6872 // If errorformat is supplied then use it, otherwise use the 'efm' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6873 // option setting |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6874 if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6875 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6876 if (efm_di->di_tv.v_type != VAR_STRING || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6877 efm_di->di_tv.vval.v_string == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6878 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6879 errorformat = efm_di->di_tv.vval.v_string; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6880 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6881 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6882 l = list_alloc(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6883 if (l == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6884 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6885 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6886 qi = qf_alloc_stack(QFLT_INTERNAL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6887 if (qi != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6888 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6889 if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6890 TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6891 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6892 (void)get_errorlist(qi, NULL, 0, 0, l); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6893 qf_free(&qi->qf_lists[0]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6894 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6895 free(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6896 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6897 dict_add_list(retdict, "items", l); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6898 status = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6899 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6900 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6901 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6902 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6903 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6904 * Return the quickfix/location list window identifier in the current tabpage. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6905 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6906 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6907 qf_winid(qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6908 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6909 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6910 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6911 // The quickfix window can be opened even if the quickfix list is not set |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6912 // using ":copen". This is not true for location lists. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6913 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6914 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6915 win = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6916 if (win != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6917 return win->w_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6918 return 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6919 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6920 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6921 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6922 * Returns the number of the buffer displayed in the quickfix/location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6923 * window. If there is no buffer associated with the list or the buffer is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6924 * wiped out, then returns 0. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6925 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6926 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6927 qf_getprop_qfbufnr(qf_info_T *qi, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6928 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6929 int bufnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6930 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6931 if (qi != NULL && buflist_findnr(qi->qf_bufnr) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6932 bufnum = qi->qf_bufnr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6933 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6934 return dict_add_number(retdict, "qfbufnr", bufnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6935 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6936 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6937 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6938 * Convert the keys in 'what' to quickfix list property flags. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6939 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6940 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6941 qf_getprop_keys2flags(dict_T *what, int loclist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6942 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6943 int flags = QF_GETLIST_NONE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6944 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6945 if (dict_has_key(what, "all")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6946 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6947 flags |= QF_GETLIST_ALL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6948 if (!loclist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6949 // File window ID is applicable only to location list windows |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6950 flags &= ~ QF_GETLIST_FILEWINID; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6951 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6952 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6953 if (dict_has_key(what, "title")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6954 flags |= QF_GETLIST_TITLE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6955 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6956 if (dict_has_key(what, "nr")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6957 flags |= QF_GETLIST_NR; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6958 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6959 if (dict_has_key(what, "winid")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6960 flags |= QF_GETLIST_WINID; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6961 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6962 if (dict_has_key(what, "context")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6963 flags |= QF_GETLIST_CONTEXT; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6964 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6965 if (dict_has_key(what, "id")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6966 flags |= QF_GETLIST_ID; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6967 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6968 if (dict_has_key(what, "items")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6969 flags |= QF_GETLIST_ITEMS; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6970 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6971 if (dict_has_key(what, "idx")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6972 flags |= QF_GETLIST_IDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6973 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6974 if (dict_has_key(what, "size")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6975 flags |= QF_GETLIST_SIZE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6976 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6977 if (dict_has_key(what, "changedtick")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6978 flags |= QF_GETLIST_TICK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6979 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6980 if (loclist && dict_has_key(what, "filewinid")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6981 flags |= QF_GETLIST_FILEWINID; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6982 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6983 if (dict_has_key(what, "qfbufnr")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6984 flags |= QF_GETLIST_QFBUFNR; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6985 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6986 if (dict_has_key(what, "quickfixtextfunc")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6987 flags |= QF_GETLIST_QFTF; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6988 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6989 return flags; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6990 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6991 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6992 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6993 * Return the quickfix list index based on 'nr' or 'id' in 'what'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6994 * If 'nr' and 'id' are not present in 'what' then return the current |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6995 * quickfix list index. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6996 * If 'nr' is zero then return the current quickfix list index. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6997 * If 'nr' is '$' then return the last quickfix list index. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6998 * If 'id' is present then return the index of the quickfix list with that id. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
6999 * If 'id' is zero then return the quickfix list index specified by 'nr'. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7000 * Return -1, if quickfix list is not present or if the stack is empty. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7001 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7002 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7003 qf_getprop_qfidx(qf_info_T *qi, dict_T *what) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7004 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7005 int qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7006 dictitem_T *di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7007 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7008 qf_idx = qi->qf_curlist; // default is the current list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7009 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7010 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7011 // Use the specified quickfix/location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7012 if (di->di_tv.v_type == VAR_NUMBER) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7013 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7014 // for zero use the current list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7015 if (di->di_tv.vval.v_number != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7016 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7017 qf_idx = di->di_tv.vval.v_number - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7018 if (qf_idx < 0 || qf_idx >= qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7019 qf_idx = INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7020 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7021 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7022 else if (di->di_tv.v_type == VAR_STRING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7023 && di->di_tv.vval.v_string != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7024 && STRCMP(di->di_tv.vval.v_string, "$") == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7025 // Get the last quickfix list number |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7026 qf_idx = qi->qf_listcount - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7027 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7028 qf_idx = INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7029 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7030 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7031 if ((di = dict_find(what, (char_u *)"id", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7032 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7033 // Look for a list with the specified id |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7034 if (di->di_tv.v_type == VAR_NUMBER) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7035 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7036 // For zero, use the current list or the list specified by 'nr' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7037 if (di->di_tv.vval.v_number != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7038 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7039 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7040 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7041 qf_idx = INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7042 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7043 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7044 return qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7045 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7046 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7047 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7048 * Return default values for quickfix list properties in retdict. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7049 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7050 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7051 qf_getprop_defaults(qf_info_T *qi, int flags, int locstack, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7052 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7053 int status = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7054 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7055 if (flags & QF_GETLIST_TITLE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7056 status = dict_add_string(retdict, "title", (char_u *)""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7057 if ((status == OK) && (flags & QF_GETLIST_ITEMS)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7058 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7059 list_T *l = list_alloc(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7060 if (l != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7061 status = dict_add_list(retdict, "items", l); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7062 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7063 status = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7064 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7065 if ((status == OK) && (flags & QF_GETLIST_NR)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7066 status = dict_add_number(retdict, "nr", 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7067 if ((status == OK) && (flags & QF_GETLIST_WINID)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7068 status = dict_add_number(retdict, "winid", qf_winid(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7069 if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7070 status = dict_add_string(retdict, "context", (char_u *)""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7071 if ((status == OK) && (flags & QF_GETLIST_ID)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7072 status = dict_add_number(retdict, "id", 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7073 if ((status == OK) && (flags & QF_GETLIST_IDX)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7074 status = dict_add_number(retdict, "idx", 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7075 if ((status == OK) && (flags & QF_GETLIST_SIZE)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7076 status = dict_add_number(retdict, "size", 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7077 if ((status == OK) && (flags & QF_GETLIST_TICK)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7078 status = dict_add_number(retdict, "changedtick", 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7079 if ((status == OK) && locstack && (flags & QF_GETLIST_FILEWINID)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7080 status = dict_add_number(retdict, "filewinid", 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7081 if ((status == OK) && (flags & QF_GETLIST_QFBUFNR)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7082 status = qf_getprop_qfbufnr(qi, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7083 if ((status == OK) && (flags & QF_GETLIST_QFTF)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7084 status = dict_add_string(retdict, "quickfixtextfunc", (char_u *)""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7085 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7086 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7087 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7088 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7089 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7090 * Return the quickfix list title as 'title' in retdict |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7091 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7092 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7093 qf_getprop_title(qf_list_T *qfl, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7094 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7095 return dict_add_string(retdict, "title", qfl->qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7096 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7097 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7098 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7099 * Returns the identifier of the window used to display files from a location |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7100 * list. If there is no associated window, then returns 0. Useful only when |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7101 * called from a location list window. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7102 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7103 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7104 qf_getprop_filewinid(win_T *wp, qf_info_T *qi, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7105 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7106 int winid = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7107 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7108 if (wp != NULL && IS_LL_WINDOW(wp)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7109 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7110 win_T *ll_wp = qf_find_win_with_loclist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7111 if (ll_wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7112 winid = ll_wp->w_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7113 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7114 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7115 return dict_add_number(retdict, "filewinid", winid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7116 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7117 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7118 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7119 * Return the quickfix list items/entries as 'items' in retdict. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7120 * If eidx is not 0, then return the item at the specified index. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7121 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7122 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7123 qf_getprop_items(qf_info_T *qi, int qf_idx, int eidx, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7124 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7125 int status = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7126 list_T *l = list_alloc(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7127 if (l != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7128 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7129 (void)get_errorlist(qi, NULL, qf_idx, eidx, l); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7130 dict_add_list(retdict, "items", l); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7131 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7132 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7133 status = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7134 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7135 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7136 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7137 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7138 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7139 * Return the quickfix list context (if any) as 'context' in retdict. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7140 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7141 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7142 qf_getprop_ctx(qf_list_T *qfl, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7143 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7144 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7145 dictitem_T *di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7146 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7147 if (qfl->qf_ctx != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7148 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7149 di = dictitem_alloc((char_u *)"context"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7150 if (di != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7151 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7152 copy_tv(qfl->qf_ctx, &di->di_tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7153 status = dict_add(retdict, di); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7154 if (status == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7155 dictitem_free(di); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7156 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7157 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7158 status = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7159 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7160 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7161 status = dict_add_string(retdict, "context", (char_u *)""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7162 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7163 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7164 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7165 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7166 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7167 * Return the current quickfix list index as 'idx' in retdict. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7168 * If a specific entry index (eidx) is supplied, then use that. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7169 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7170 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7171 qf_getprop_idx(qf_list_T *qfl, int eidx, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7172 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7173 if (eidx == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7174 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7175 eidx = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7176 if (qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7177 // For empty lists, current index is set to 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7178 eidx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7179 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7180 return dict_add_number(retdict, "idx", eidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7181 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7182 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7183 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7184 * Return the 'quickfixtextfunc' function of a quickfix/location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7185 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7186 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7187 qf_getprop_qftf(qf_list_T *qfl, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7188 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7189 int status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7190 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7191 if (qfl->qf_qftf_cb.cb_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7192 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7193 typval_T tv; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7194 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7195 put_callback(&qfl->qf_qftf_cb, &tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7196 status = dict_add_tv(retdict, "quickfixtextfunc", &tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7197 clear_tv(&tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7198 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7199 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7200 status = dict_add_string(retdict, "quickfixtextfunc", (char_u *)""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7201 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7202 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7203 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7204 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7205 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7206 * Return quickfix/location list details (title) as a |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7207 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7208 * then current list is used. Otherwise the specified list is used. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7209 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7210 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7211 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7212 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7213 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7214 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7215 int status = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7216 int qf_idx = INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7217 int eidx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7218 dictitem_T *di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7219 int flags = QF_GETLIST_NONE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7220 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7221 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7222 return qf_get_list_from_lines(what, di, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7223 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7224 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7225 qi = GET_LOC_LIST(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7226 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7227 flags = qf_getprop_keys2flags(what, (wp != NULL)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7228 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7229 if (!qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7230 qf_idx = qf_getprop_qfidx(qi, what); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7231 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7232 // List is not present or is empty |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7233 if (qf_stack_empty(qi) || qf_idx == INVALID_QFIDX) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7234 return qf_getprop_defaults(qi, flags, wp != NULL, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7235 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7236 qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7237 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7238 // If an entry index is specified, use that |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7239 if ((di = dict_find(what, (char_u *)"idx", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7240 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7241 if (di->di_tv.v_type != VAR_NUMBER) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7242 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7243 eidx = di->di_tv.vval.v_number; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7244 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7245 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7246 if (flags & QF_GETLIST_TITLE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7247 status = qf_getprop_title(qfl, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7248 if ((status == OK) && (flags & QF_GETLIST_NR)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7249 status = dict_add_number(retdict, "nr", qf_idx + 1); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7250 if ((status == OK) && (flags & QF_GETLIST_WINID)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7251 status = dict_add_number(retdict, "winid", qf_winid(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7252 if ((status == OK) && (flags & QF_GETLIST_ITEMS)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7253 status = qf_getprop_items(qi, qf_idx, eidx, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7254 if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7255 status = qf_getprop_ctx(qfl, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7256 if ((status == OK) && (flags & QF_GETLIST_ID)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7257 status = dict_add_number(retdict, "id", qfl->qf_id); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7258 if ((status == OK) && (flags & QF_GETLIST_IDX)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7259 status = qf_getprop_idx(qfl, eidx, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7260 if ((status == OK) && (flags & QF_GETLIST_SIZE)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7261 status = dict_add_number(retdict, "size", qfl->qf_count); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7262 if ((status == OK) && (flags & QF_GETLIST_TICK)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7263 status = dict_add_number(retdict, "changedtick", qfl->qf_changedtick); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7264 if ((status == OK) && (wp != NULL) && (flags & QF_GETLIST_FILEWINID)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7265 status = qf_getprop_filewinid(wp, qi, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7266 if ((status == OK) && (flags & QF_GETLIST_QFBUFNR)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7267 status = qf_getprop_qfbufnr(qi, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7268 if ((status == OK) && (flags & QF_GETLIST_QFTF)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7269 status = qf_getprop_qftf(qfl, retdict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7270 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7271 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7272 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7273 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7274 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7275 * Add a new quickfix entry to list at 'qf_idx' in the stack 'qi' from the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7276 * items in the dict 'd'. If it is a valid error entry, then set 'valid_entry' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7277 * to TRUE. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7278 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7279 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7280 qf_add_entry_from_dict( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7281 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7282 dict_T *d, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7283 int first_entry, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7284 int *valid_entry) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7285 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7286 static int did_bufnr_emsg; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7287 char_u *filename, *module, *pattern, *text, *type; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7288 int bufnum, valid, status, col, end_col, vcol, nr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7289 long lnum, end_lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7290 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7291 if (first_entry) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7292 did_bufnr_emsg = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7293 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7294 filename = dict_get_string(d, "filename", TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7295 module = dict_get_string(d, "module", TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7296 bufnum = (int)dict_get_number(d, "bufnr"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7297 lnum = (int)dict_get_number(d, "lnum"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7298 end_lnum = (int)dict_get_number(d, "end_lnum"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7299 col = (int)dict_get_number(d, "col"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7300 end_col = (int)dict_get_number(d, "end_col"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7301 vcol = (int)dict_get_number(d, "vcol"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7302 nr = (int)dict_get_number(d, "nr"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7303 type = dict_get_string(d, "type", TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7304 pattern = dict_get_string(d, "pattern", TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7305 text = dict_get_string(d, "text", TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7306 if (text == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7307 text = vim_strsave((char_u *)""); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7308 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7309 valid = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7310 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7311 valid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7312 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7313 // Mark entries with non-existing buffer number as not valid. Give the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7314 // error message only once. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7315 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7316 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7317 if (!did_bufnr_emsg) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7318 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7319 did_bufnr_emsg = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7320 semsg(_(e_buffer_nr_not_found), bufnum); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7321 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7322 valid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7323 bufnum = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7324 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7325 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7326 // If the 'valid' field is present it overrules the detected value. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7327 if (dict_has_key(d, "valid")) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7328 valid = (int)dict_get_bool(d, "valid", FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7329 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7330 status = qf_add_entry(qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7331 NULL, // dir |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7332 filename, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7333 module, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7334 bufnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7335 text, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7336 lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7337 end_lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7338 col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7339 end_col, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7340 vcol, // vis_col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7341 pattern, // search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7342 nr, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7343 type == NULL ? NUL : *type, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7344 valid); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7345 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7346 vim_free(filename); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7347 vim_free(module); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7348 vim_free(pattern); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7349 vim_free(text); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7350 vim_free(type); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7351 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7352 if (valid) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7353 *valid_entry = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7354 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7355 return status; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7356 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7357 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7358 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7359 * Add list of entries to quickfix/location list. Each list entry is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7360 * a dictionary with item information. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7361 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7362 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7363 qf_add_entries( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7364 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7365 int qf_idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7366 list_T *list, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7367 char_u *title, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7368 int action) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7369 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7370 qf_list_T *qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7371 listitem_T *li; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7372 dict_T *d; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7373 qfline_T *old_last = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7374 int retval = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7375 int valid_entry = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7376 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7377 if (action == ' ' || qf_idx == qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7378 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7379 // make place for a new list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7380 qf_new_list(qi, title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7381 qf_idx = qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7382 qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7383 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7384 else if (action == 'a' && !qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7385 // Adding to existing list, use last entry. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7386 old_last = qfl->qf_last; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7387 else if (action == 'r') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7388 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7389 qf_free_items(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7390 qf_store_title(qfl, title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7391 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7392 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7393 FOR_ALL_LIST_ITEMS(list, li) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7394 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7395 if (li->li_tv.v_type != VAR_DICT) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7396 continue; // Skip non-dict items |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7397 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7398 d = li->li_tv.vval.v_dict; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7399 if (d == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7400 continue; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7401 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7402 retval = qf_add_entry_from_dict(qfl, d, li == list->lv_first, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7403 &valid_entry); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7404 if (retval == QF_FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7405 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7406 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7407 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7408 // Check if any valid error entries are added to the list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7409 if (valid_entry) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7410 qfl->qf_nonevalid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7411 else if (qfl->qf_index == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7412 // no valid entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7413 qfl->qf_nonevalid = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7414 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7415 // If not appending to the list, set the current error to the first entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7416 if (action != 'a') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7417 qfl->qf_ptr = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7418 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7419 // Update the current error index if not appending to the list or if the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7420 // list was empty before and it is not empty now. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7421 if ((action != 'a' || qfl->qf_index == 0) && !qf_list_empty(qfl)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7422 qfl->qf_index = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7423 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7424 // Don't update the cursor in quickfix window when appending entries |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7425 qf_update_buffer(qi, old_last); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7426 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7427 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7428 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7429 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7430 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7431 * Get the quickfix list index from 'nr' or 'id' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7432 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7433 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7434 qf_setprop_get_qfidx( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7435 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7436 dict_T *what, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7437 int action, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7438 int *newlist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7439 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7440 dictitem_T *di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7441 int qf_idx = qi->qf_curlist; // default is the current list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7442 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7443 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7444 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7445 // Use the specified quickfix/location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7446 if (di->di_tv.v_type == VAR_NUMBER) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7447 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7448 // for zero use the current list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7449 if (di->di_tv.vval.v_number != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7450 qf_idx = di->di_tv.vval.v_number - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7451 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7452 if ((action == ' ' || action == 'a') && qf_idx == qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7453 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7454 // When creating a new list, accept qf_idx pointing to the next |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7455 // non-available list and add the new list at the end of the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7456 // stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7457 *newlist = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7458 qf_idx = qf_stack_empty(qi) ? 0 : qi->qf_listcount - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7459 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7460 else if (qf_idx < 0 || qf_idx >= qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7461 return INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7462 else if (action != ' ') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7463 *newlist = FALSE; // use the specified list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7464 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7465 else if (di->di_tv.v_type == VAR_STRING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7466 && di->di_tv.vval.v_string != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7467 && STRCMP(di->di_tv.vval.v_string, "$") == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7468 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7469 if (!qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7470 qf_idx = qi->qf_listcount - 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7471 else if (*newlist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7472 qf_idx = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7473 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7474 return INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7475 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7476 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7477 return INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7478 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7479 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7480 if (!*newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7481 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7482 // Use the quickfix/location list with the specified id |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7483 if (di->di_tv.v_type != VAR_NUMBER) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7484 return INVALID_QFIDX; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7485 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7486 return qf_id2nr(qi, di->di_tv.vval.v_number); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7487 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7488 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7489 return qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7490 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7491 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7492 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7493 * Set the quickfix list title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7494 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7495 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7496 qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7497 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7498 qf_list_T *qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7499 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7500 if (di->di_tv.v_type != VAR_STRING) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7501 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7502 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7503 vim_free(qfl->qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7504 qfl->qf_title = dict_get_string(what, "title", TRUE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7505 if (qf_idx == qi->qf_curlist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7506 qf_update_win_titlevar(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7507 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7508 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7509 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7510 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7511 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7512 * Set quickfix list items/entries. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7513 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7514 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7515 qf_setprop_items(qf_info_T *qi, int qf_idx, dictitem_T *di, int action) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7516 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7517 int retval = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7518 char_u *title_save; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7519 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7520 if (di->di_tv.v_type != VAR_LIST) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7521 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7522 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7523 title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7524 retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7525 title_save, action == ' ' ? 'a' : action); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7526 vim_free(title_save); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7527 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7528 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7529 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7530 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7531 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7532 * Set quickfix list items/entries from a list of lines. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7533 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7534 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7535 qf_setprop_items_from_lines( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7536 qf_info_T *qi, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7537 int qf_idx, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7538 dict_T *what, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7539 dictitem_T *di, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7540 int action) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7541 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7542 char_u *errorformat = p_efm; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7543 dictitem_T *efm_di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7544 int retval = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7545 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7546 // Use the user supplied errorformat settings (if present) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7547 if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7548 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7549 if (efm_di->di_tv.v_type != VAR_STRING || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7550 efm_di->di_tv.vval.v_string == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7551 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7552 errorformat = efm_di->di_tv.vval.v_string; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7553 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7554 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7555 // Only a List value is supported |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7556 if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7557 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7558 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7559 if (action == 'r') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7560 qf_free_items(&qi->qf_lists[qf_idx]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7561 if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7562 FALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) >= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7563 retval = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7564 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7565 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7566 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7567 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7568 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7569 * Set quickfix list context. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7570 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7571 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7572 qf_setprop_context(qf_list_T *qfl, dictitem_T *di) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7573 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7574 typval_T *ctx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7575 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7576 free_tv(qfl->qf_ctx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7577 ctx = alloc_tv(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7578 if (ctx != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7579 copy_tv(&di->di_tv, ctx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7580 qfl->qf_ctx = ctx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7581 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7582 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7583 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7584 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7585 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7586 * Set the current index in the specified quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7587 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7588 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7589 qf_setprop_curidx(qf_info_T *qi, qf_list_T *qfl, dictitem_T *di) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7590 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7591 int denote = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7592 int newidx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7593 int old_qfidx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7594 qfline_T *qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7595 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7596 // If the specified index is '$', then use the last entry |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7597 if (di->di_tv.v_type == VAR_STRING |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7598 && di->di_tv.vval.v_string != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7599 && STRCMP(di->di_tv.vval.v_string, "$") == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7600 newidx = qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7601 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7602 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7603 // Otherwise use the specified index |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7604 newidx = tv_get_number_chk(&di->di_tv, &denote); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7605 if (denote) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7606 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7607 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7608 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7609 if (newidx < 1) // sanity check |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7610 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7611 if (newidx > qfl->qf_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7612 newidx = qfl->qf_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7613 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7614 old_qfidx = qfl->qf_index; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7615 qf_ptr = get_nth_entry(qfl, newidx, &newidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7616 if (qf_ptr == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7617 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7618 qfl->qf_ptr = qf_ptr; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7619 qfl->qf_index = newidx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7620 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7621 // If the current list is modified and it is displayed in the quickfix |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7622 // window, then Update it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7623 if (qf_get_curlist(qi)->qf_id == qfl->qf_id) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7624 qf_win_pos_update(qi, old_qfidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7625 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7626 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7627 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7628 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7629 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7630 * Set the current index in the specified quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7631 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7632 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7633 qf_setprop_qftf(qf_info_T *qi UNUSED, qf_list_T *qfl, dictitem_T *di) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7634 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7635 callback_T cb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7636 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7637 free_callback(&qfl->qf_qftf_cb); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7638 cb = get_callback(&di->di_tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7639 if (cb.cb_name == NULL || *cb.cb_name == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7640 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7641 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7642 set_callback(&qfl->qf_qftf_cb, &cb); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7643 if (cb.cb_free_name) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7644 vim_free(cb.cb_name); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7645 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7646 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7647 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7648 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7649 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7650 * Set quickfix/location list properties (title, items, context). |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7651 * Also used to add items from parsing a list of lines. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7652 * Used by the setqflist() and setloclist() Vim script functions. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7653 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7654 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7655 qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7656 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7657 dictitem_T *di; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7658 int retval = FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7659 int qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7660 int newlist = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7661 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7662 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7663 if (action == ' ' || qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7664 newlist = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7665 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7666 qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7667 if (qf_idx == INVALID_QFIDX) // List not found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7668 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7669 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7670 if (newlist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7671 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7672 qi->qf_curlist = qf_idx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7673 qf_new_list(qi, title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7674 qf_idx = qi->qf_curlist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7675 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7676 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7677 qfl = qf_get_list(qi, qf_idx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7678 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7679 retval = qf_setprop_title(qi, qf_idx, what, di); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7680 if ((di = dict_find(what, (char_u *)"items", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7681 retval = qf_setprop_items(qi, qf_idx, di, action); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7682 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7683 retval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7684 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7685 retval = qf_setprop_context(qfl, di); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7686 if ((di = dict_find(what, (char_u *)"idx", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7687 retval = qf_setprop_curidx(qi, qfl, di); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7688 if ((di = dict_find(what, (char_u *)"quickfixtextfunc", -1)) != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7689 retval = qf_setprop_qftf(qi, qfl, di); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7690 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7691 if (newlist || retval == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7692 qf_list_changed(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7693 if (newlist) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7694 qf_update_buffer(qi, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7695 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7696 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7697 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7698 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7699 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7700 * Free the entire quickfix/location list stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7701 * If the quickfix/location list window is open, then clear it. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7702 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7703 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7704 qf_free_stack(win_T *wp, qf_info_T *qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7705 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7706 win_T *qfwin = qf_find_win(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7707 win_T *llwin = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7708 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7709 if (qfwin != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7710 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7711 // If the quickfix/location list window is open, then clear it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7712 if (qi->qf_curlist < qi->qf_listcount) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7713 qf_free(qf_get_curlist(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7714 qf_update_buffer(qi, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7715 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7716 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7717 if (wp != NULL && IS_LL_WINDOW(wp)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7718 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7719 // If in the location list window, then use the non-location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7720 // window with this location list (if present) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7721 llwin = qf_find_win_with_loclist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7722 if (llwin != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7723 wp = llwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7724 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7725 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7726 qf_free_all(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7727 if (wp == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7728 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7729 // quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7730 qi->qf_curlist = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7731 qi->qf_listcount = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7732 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7733 else if (qfwin != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7734 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7735 // If the location list window is open, then create a new empty |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7736 // location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7737 qf_info_T *new_ll = qf_alloc_stack(QFLT_LOCATION); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7738 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7739 if (new_ll != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7740 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7741 new_ll->qf_bufnr = qfwin->w_buffer->b_fnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7742 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7743 // first free the list reference in the location list window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7744 ll_free_all(&qfwin->w_llist_ref); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7745 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7746 qfwin->w_llist_ref = new_ll; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7747 if (wp != qfwin) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7748 win_set_loclist(wp, new_ll); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7749 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7750 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7751 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7752 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7753 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7754 * Populate the quickfix list with the items supplied in the list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7755 * of dictionaries. "title" will be copied to w:quickfix_title. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7756 * "action" is 'a' for add, 'r' for replace. Otherwise create a new list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7757 * When "what" is not NULL then only set some properties. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7758 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7759 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7760 set_errorlist( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7761 win_T *wp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7762 list_T *list, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7763 int action, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7764 char_u *title, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7765 dict_T *what) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7766 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7767 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7768 int retval = OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7769 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7770 if (wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7771 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7772 qi = ll_get_or_alloc_list(wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7773 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7774 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7775 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7776 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7777 if (action == 'f') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7778 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7779 // Free the entire quickfix or location list stack |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7780 qf_free_stack(wp, qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7781 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7782 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7783 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7784 // A dict argument cannot be specified with a non-empty list argument |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7785 if (list->lv_len != 0 && what != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7786 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7787 semsg(_(e_invalid_argument_str), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7788 _("cannot have both a list and a \"what\" argument")); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7789 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7790 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7791 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7792 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7793 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7794 if (what != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7795 retval = qf_set_properties(qi, what, action, title); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7796 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7797 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7798 retval = qf_add_entries(qi, qi->qf_curlist, list, title, action); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7799 if (retval == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7800 qf_list_changed(qf_get_curlist(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7801 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7802 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7803 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7804 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7805 return retval; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7806 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7807 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7808 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7809 * Mark the quickfix context and callback function as in use for all the lists |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7810 * in a quickfix stack. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7811 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7812 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7813 mark_quickfix_ctx(qf_info_T *qi, int copyID) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7814 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7815 int i; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7816 int abort = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7817 typval_T *ctx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7818 callback_T *cb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7819 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7820 for (i = 0; i < LISTCOUNT && !abort; ++i) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7821 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7822 ctx = qi->qf_lists[i].qf_ctx; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7823 if (ctx != NULL && ctx->v_type != VAR_NUMBER |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7824 && ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7825 abort = abort || set_ref_in_item(ctx, copyID, NULL, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7826 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7827 cb = &qi->qf_lists[i].qf_qftf_cb; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7828 abort = abort || set_ref_in_callback(cb, copyID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7829 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7830 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7831 return abort; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7832 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7833 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7834 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7835 * Mark the context of the quickfix list and the location lists (if present) as |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7836 * "in use". So that garbage collection doesn't free the context. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7837 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7838 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7839 set_ref_in_quickfix(int copyID) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7840 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7841 int abort = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7842 tabpage_T *tp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7843 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7844 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7845 abort = mark_quickfix_ctx(&ql_info, copyID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7846 if (abort) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7847 return abort; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7848 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7849 abort = set_ref_in_callback(&qftf_cb, copyID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7850 if (abort) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7851 return abort; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7852 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7853 FOR_ALL_TAB_WINDOWS(tp, win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7854 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7855 if (win->w_llist != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7856 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7857 abort = mark_quickfix_ctx(win->w_llist, copyID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7858 if (abort) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7859 return abort; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7860 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7861 if (IS_LL_WINDOW(win) && (win->w_llist_ref->qf_refcount == 1)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7862 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7863 // In a location list window and none of the other windows is |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7864 // referring to this location list. Mark the location list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7865 // context as still in use. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7866 abort = mark_quickfix_ctx(win->w_llist_ref, copyID); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7867 if (abort) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7868 return abort; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7869 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7870 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7871 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7872 return abort; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7873 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7874 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7875 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7876 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7877 * Return the autocmd name for the :cbuffer Ex commands |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7878 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7879 static char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7880 cbuffer_get_auname(cmdidx_T cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7881 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7882 switch (cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7883 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7884 case CMD_cbuffer: return (char_u *)"cbuffer"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7885 case CMD_cgetbuffer: return (char_u *)"cgetbuffer"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7886 case CMD_caddbuffer: return (char_u *)"caddbuffer"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7887 case CMD_lbuffer: return (char_u *)"lbuffer"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7888 case CMD_lgetbuffer: return (char_u *)"lgetbuffer"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7889 case CMD_laddbuffer: return (char_u *)"laddbuffer"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7890 default: return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7891 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7892 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7893 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7894 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7895 * Process and validate the arguments passed to the :cbuffer, :caddbuffer, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7896 * :cgetbuffer, :lbuffer, :laddbuffer, :lgetbuffer Ex commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7897 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7898 static int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7899 cbuffer_process_args( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7900 exarg_T *eap, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7901 buf_T **bufp, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7902 linenr_T *line1, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7903 linenr_T *line2) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7904 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7905 buf_T *buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7906 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7907 if (*eap->arg == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7908 buf = curbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7909 else if (*skipwhite(skipdigits(eap->arg)) == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7910 buf = buflist_findnr(atoi((char *)eap->arg)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7911 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7912 if (buf == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7913 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7914 emsg(_(e_invalid_argument)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7915 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7916 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7917 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7918 if (buf->b_ml.ml_mfp == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7919 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7920 emsg(_(e_buffer_is_not_loaded)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7921 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7922 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7923 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7924 if (eap->addr_count == 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7925 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7926 eap->line1 = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7927 eap->line2 = buf->b_ml.ml_line_count; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7928 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7929 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7930 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7931 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7932 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7933 emsg(_(e_invalid_range)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7934 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7935 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7936 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7937 *line1 = eap->line1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7938 *line2 = eap->line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7939 *bufp = buf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7940 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7941 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7942 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7943 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7944 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7945 * ":[range]cbuffer [bufnr]" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7946 * ":[range]caddbuffer [bufnr]" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7947 * ":[range]cgetbuffer [bufnr]" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7948 * ":[range]lbuffer [bufnr]" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7949 * ":[range]laddbuffer [bufnr]" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7950 * ":[range]lgetbuffer [bufnr]" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7951 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7952 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7953 ex_cbuffer(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7954 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7955 buf_T *buf = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7956 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7957 char_u *au_name = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7958 int res; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7959 int_u save_qfid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7960 win_T *wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7961 char_u *qf_title; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7962 linenr_T line1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7963 linenr_T line2; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7964 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7965 au_name = cbuffer_get_auname(eap->cmdidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7966 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7967 curbuf->b_fname, TRUE, curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7968 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7969 #ifdef FEAT_EVAL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7970 if (aborting()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7971 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7972 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7973 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7974 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7975 // Must come after autocommands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7976 qi = qf_cmd_get_or_alloc_stack(eap, &wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7977 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7978 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7979 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7980 if (cbuffer_process_args(eap, &buf, &line1, &line2) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7981 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7982 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7983 qf_title = qf_cmdtitle(*eap->cmdlinep); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7984 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7985 if (buf->b_sfname) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7986 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7987 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7988 (char *)qf_title, (char *)buf->b_sfname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7989 qf_title = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7990 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7991 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7992 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7993 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7994 res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7995 (eap->cmdidx != CMD_caddbuffer |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7996 && eap->cmdidx != CMD_laddbuffer), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7997 line1, line2, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7998 qf_title, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
7999 if (qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8000 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8001 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8002 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8003 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8004 if (res >= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8005 qf_list_changed(qf_get_curlist(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8006 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8007 // Remember the current quickfix list identifier, so that we can |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8008 // check for autocommands changing the current quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8009 save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8010 if (au_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8011 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8012 buf_T *curbuf_old = curbuf; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8013 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8014 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8015 TRUE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8016 if (curbuf != curbuf_old) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8017 // Autocommands changed buffer, don't jump now, "qi" may |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8018 // be invalid. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8019 res = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8020 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8021 // Jump to the first error for a new list and if autocmds didn't |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8022 // free the list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8023 if (res > 0 && (eap->cmdidx == CMD_cbuffer || |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8024 eap->cmdidx == CMD_lbuffer) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8025 && qflist_valid(wp, save_qfid)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8026 // display the first error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8027 qf_jump_first(qi, save_qfid, eap->forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8028 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8029 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8030 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8031 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8032 #if defined(FEAT_EVAL) || defined(PROTO) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8033 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8034 * Return the autocmd name for the :cexpr Ex commands. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8035 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8036 char_u * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8037 cexpr_get_auname(cmdidx_T cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8038 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8039 switch (cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8040 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8041 case CMD_cexpr: return (char_u *)"cexpr"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8042 case CMD_cgetexpr: return (char_u *)"cgetexpr"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8043 case CMD_caddexpr: return (char_u *)"caddexpr"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8044 case CMD_lexpr: return (char_u *)"lexpr"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8045 case CMD_lgetexpr: return (char_u *)"lgetexpr"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8046 case CMD_laddexpr: return (char_u *)"laddexpr"; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8047 default: return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8048 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8049 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8050 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8051 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8052 trigger_cexpr_autocmd(int cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8053 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8054 char_u *au_name = cexpr_get_auname(cmdidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8055 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8056 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8057 curbuf->b_fname, TRUE, curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8058 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8059 if (aborting()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8060 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8061 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8062 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8063 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8064 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8065 int |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8066 cexpr_core(exarg_T *eap, typval_T *tv) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8067 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8068 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8069 win_T *wp = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8070 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8071 qi = qf_cmd_get_or_alloc_stack(eap, &wp); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8072 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8073 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8074 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8075 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8076 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8077 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8078 int res; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8079 int_u save_qfid; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8080 char_u *au_name = cexpr_get_auname(eap->cmdidx); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8081 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8082 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8083 res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8084 (eap->cmdidx != CMD_caddexpr |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8085 && eap->cmdidx != CMD_laddexpr), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8086 (linenr_T)0, (linenr_T)0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8087 qf_cmdtitle(*eap->cmdlinep), NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8088 if (qf_stack_empty(qi)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8089 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8090 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8091 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8092 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8093 if (res >= 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8094 qf_list_changed(qf_get_curlist(qi)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8095 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8096 // Remember the current quickfix list identifier, so that we can |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8097 // check for autocommands changing the current quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8098 save_qfid = qf_get_curlist(qi)->qf_id; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8099 if (au_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8100 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8101 curbuf->b_fname, TRUE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8102 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8103 // Jump to the first error for a new list and if autocmds didn't |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8104 // free the list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8105 if (res > 0 && (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8106 && qflist_valid(wp, save_qfid)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8107 // display the first error |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8108 qf_jump_first(qi, save_qfid, eap->forceit); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8109 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8110 return OK; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8111 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8112 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8113 emsg(_(e_string_or_list_expected)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8114 return FAIL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8115 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8116 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8117 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8118 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8119 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8120 * Also: ":caddexpr", ":cgetexpr", "laddexpr" and "laddexpr". |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8121 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8122 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8123 ex_cexpr(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8124 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8125 typval_T *tv; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8126 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8127 if (trigger_cexpr_autocmd(eap->cmdidx) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8128 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8129 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8130 // Evaluate the expression. When the result is a string or a list we can |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8131 // use it to fill the errorlist. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8132 tv = eval_expr(eap->arg, eap); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8133 if (tv == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8134 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8135 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8136 (void)cexpr_core(eap, tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8137 free_tv(tv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8138 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8139 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8140 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8141 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8142 * Get the location list for ":lhelpgrep" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8143 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8144 static qf_info_T * |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8145 hgr_get_ll(int *new_ll) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8146 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8147 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8148 qf_info_T *qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8149 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8150 // If the current window is a help window, then use it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8151 if (bt_help(curwin->w_buffer)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8152 wp = curwin; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8153 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8154 // Find an existing help window |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8155 wp = qf_find_help_win(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8156 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8157 if (wp == NULL) // Help window not found |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8158 qi = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8159 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8160 qi = wp->w_llist; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8161 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8162 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8163 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8164 // Allocate a new location list for help text matches |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8165 if ((qi = qf_alloc_stack(QFLT_LOCATION)) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8166 return NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8167 *new_ll = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8168 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8169 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8170 return qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8171 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8172 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8173 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8174 * Search for a pattern in a help file. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8175 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8176 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8177 hgr_search_file( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8178 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8179 char_u *fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8180 vimconv_T *p_vc, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8181 regmatch_T *p_regmatch) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8182 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8183 FILE *fd; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8184 long lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8185 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8186 fd = mch_fopen((char *)fname, "r"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8187 if (fd == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8188 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8189 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8190 lnum = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8191 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8192 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8193 char_u *line = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8194 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8195 // Convert a line if 'encoding' is not utf-8 and |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8196 // the line contains a non-ASCII character. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8197 if (p_vc->vc_type != CONV_NONE && has_non_ascii(IObuff)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8198 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8199 line = string_convert(p_vc, IObuff, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8200 if (line == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8201 line = IObuff; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8202 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8203 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8204 if (vim_regexec(p_regmatch, line, (colnr_T)0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8205 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8206 int l = (int)STRLEN(line); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8207 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8208 // remove trailing CR, LF, spaces, etc. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8209 while (l > 0 && line[l - 1] <= ' ') |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8210 line[--l] = NUL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8211 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8212 if (qf_add_entry(qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8213 NULL, // dir |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8214 fname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8215 NULL, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8216 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8217 line, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8218 lnum, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8219 0, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8220 (int)(p_regmatch->startp[0] - line) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8221 + 1, // col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8222 (int)(p_regmatch->endp[0] - line) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8223 + 1, // end_col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8224 FALSE, // vis_col |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8225 NULL, // search pattern |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8226 0, // nr |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8227 1, // type |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8228 TRUE // valid |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8229 ) == QF_FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8230 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8231 got_int = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8232 if (line != IObuff) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8233 vim_free(line); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8234 break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8235 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8236 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8237 if (line != IObuff) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8238 vim_free(line); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8239 ++lnum; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8240 line_breakcheck(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8241 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8242 fclose(fd); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8243 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8244 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8245 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8246 * Search for a pattern in all the help files in the doc directory under |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8247 * the given directory. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8248 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8249 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8250 hgr_search_files_in_dir( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8251 qf_list_T *qfl, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8252 char_u *dirname, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8253 regmatch_T *p_regmatch, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8254 vimconv_T *p_vc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8255 #ifdef FEAT_MULTI_LANG |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8256 , char_u *lang |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8257 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8258 ) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8259 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8260 int fcount; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8261 char_u **fnames; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8262 int fi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8263 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8264 // Find all "*.txt" and "*.??x" files in the "doc" directory. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8265 add_pathsep(dirname); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8266 STRCAT(dirname, "doc/*.\\(txt\\|??x\\)"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8267 if (gen_expand_wildcards(1, &dirname, &fcount, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8268 &fnames, EW_FILE|EW_SILENT) == OK |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8269 && fcount > 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8270 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8271 for (fi = 0; fi < fcount && !got_int; ++fi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8272 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8273 #ifdef FEAT_MULTI_LANG |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8274 // Skip files for a different language. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8275 if (lang != NULL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8276 && STRNICMP(lang, fnames[fi] |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8277 + STRLEN(fnames[fi]) - 3, 2) != 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8278 && !(STRNICMP(lang, "en", 2) == 0 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8279 && STRNICMP("txt", fnames[fi] |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8280 + STRLEN(fnames[fi]) - 3, 3) == 0)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8281 continue; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8282 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8283 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8284 hgr_search_file(qfl, fnames[fi], p_vc, p_regmatch); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8285 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8286 FreeWild(fcount, fnames); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8287 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8288 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8289 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8290 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8291 * Search for a pattern in all the help files in the 'runtimepath' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8292 * and add the matches to a quickfix list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8293 * 'lang' is the language specifier. If supplied, then only matches in the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8294 * specified language are found. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8295 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8296 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8297 hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, char_u *lang) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8298 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8299 char_u *p; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8300 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8301 vimconv_T vc; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8302 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8303 // Help files are in utf-8 or latin1, convert lines when 'encoding' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8304 // differs. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8305 vc.vc_type = CONV_NONE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8306 if (!enc_utf8) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8307 convert_setup(&vc, (char_u *)"utf-8", p_enc); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8308 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8309 // Go through all the directories in 'runtimepath' |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8310 p = p_rtp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8311 while (*p != NUL && !got_int) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8312 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8313 copy_option_part(&p, NameBuff, MAXPATHL, ","); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8314 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8315 hgr_search_files_in_dir(qfl, NameBuff, p_regmatch, &vc |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8316 #ifdef FEAT_MULTI_LANG |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8317 , lang |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8318 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8319 ); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8320 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8321 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8322 if (vc.vc_type != CONV_NONE) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8323 convert_setup(&vc, NULL, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8324 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8325 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8326 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8327 * ":helpgrep {pattern}" |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8328 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8329 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8330 ex_helpgrep(exarg_T *eap) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8331 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8332 regmatch_T regmatch; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8333 char_u *save_cpo; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8334 int save_cpo_allocated; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8335 qf_info_T *qi = &ql_info; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8336 int new_qi = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8337 char_u *au_name = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8338 char_u *lang = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8339 int updated = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8340 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8341 switch (eap->cmdidx) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8342 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8343 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8344 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8345 default: break; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8346 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8347 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8348 curbuf->b_fname, TRUE, curbuf)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8349 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8350 #ifdef FEAT_EVAL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8351 if (aborting()) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8352 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8353 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8354 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8355 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8356 if (is_loclist_cmd(eap->cmdidx)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8357 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8358 qi = hgr_get_ll(&new_qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8359 if (qi == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8360 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8361 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8362 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8363 // Make 'cpoptions' empty, the 'l' flag should not be used here. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8364 save_cpo = p_cpo; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8365 save_cpo_allocated = is_option_allocated("cpo"); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8366 p_cpo = empty_option; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8367 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8368 incr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8369 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8370 #ifdef FEAT_MULTI_LANG |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8371 // Check for a specified language |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8372 lang = check_help_lang(eap->arg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8373 #endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8374 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8375 regmatch.rm_ic = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8376 if (regmatch.regprog != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8377 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8378 qf_list_T *qfl; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8379 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8380 // create a new quickfix list |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8381 qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8382 qfl = qf_get_curlist(qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8383 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8384 hgr_search_in_rtp(qfl, ®match, lang); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8385 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8386 vim_regfree(regmatch.regprog); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8387 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8388 qfl->qf_nonevalid = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8389 qfl->qf_ptr = qfl->qf_start; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8390 qfl->qf_index = 1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8391 qf_list_changed(qfl); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8392 updated = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8393 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8394 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8395 if (p_cpo == empty_option) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8396 p_cpo = save_cpo; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8397 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8398 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8399 // Darn, some plugin changed the value. If it's still empty it was |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8400 // changed and restored, need to restore in the complicated way. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8401 if (*p_cpo == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8402 set_option_value_give_err((char_u *)"cpo", 0L, save_cpo, 0); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8403 if (save_cpo_allocated) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8404 free_string_option(save_cpo); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8405 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8406 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8407 if (updated) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8408 // This may open a window and source scripts, do this after 'cpo' was |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8409 // restored. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8410 qf_update_buffer(qi, NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8411 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8412 if (au_name != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8413 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8414 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8415 curbuf->b_fname, TRUE, curbuf); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8416 // When adding a location list to an existing location list stack, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8417 // if the autocmd made the stack invalid, then just return. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8418 if (!new_qi && IS_LL_STACK(qi) && qf_find_win_with_loclist(qi) == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8419 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8420 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8421 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8422 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8423 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8424 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8425 // Jump to first match. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8426 if (!qf_list_empty(qf_get_curlist(qi))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8427 qf_jump(qi, 0, 0, FALSE); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8428 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8429 semsg(_(e_no_match_str_2), eap->arg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8430 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8431 decr_quickfix_busy(); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8432 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8433 if (eap->cmdidx == CMD_lhelpgrep) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8434 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8435 // If the help window is not opened or if it already points to the |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8436 // correct location list, then free the new location list. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8437 if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8438 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8439 if (new_qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8440 ll_free_all(&qi); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8441 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8442 else if (curwin->w_llist == NULL && new_qi) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8443 // current window didn't have a location list associated with it |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8444 // before. Associate the new location list now. |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8445 curwin->w_llist = qi; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8446 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8447 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8448 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8449 # if defined(EXITFREE) || defined(PROTO) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8450 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8451 free_quickfix(void) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8452 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8453 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8454 tabpage_T *tab; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8455 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8456 qf_free_all(NULL); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8457 // Free all location lists |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8458 FOR_ALL_TAB_WINDOWS(tab, win) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8459 qf_free_all(win); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8460 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8461 ga_clear(&qfga); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8462 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8463 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8464 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8465 #endif // FEAT_QUICKFIX |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8466 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8467 #if defined(FEAT_EVAL) || defined(PROTO) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8468 # ifdef FEAT_QUICKFIX |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8469 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8470 get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8471 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8472 if (what_arg->v_type == VAR_UNKNOWN) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8473 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8474 if (rettv_list_alloc(rettv) == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8475 if (is_qf || wp != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8476 (void)get_errorlist(NULL, wp, -1, 0, rettv->vval.v_list); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8477 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8478 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8479 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8480 if (rettv_dict_alloc(rettv) == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8481 if (is_qf || (wp != NULL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8482 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8483 if (what_arg->v_type == VAR_DICT) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8484 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8485 dict_T *d = what_arg->vval.v_dict; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8486 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8487 if (d != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8488 qf_get_properties(wp, d, rettv->vval.v_dict); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8489 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8490 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8491 emsg(_(e_dictionary_required)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8492 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8493 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8494 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8495 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8496 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8497 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8498 * "getloclist()" function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8499 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8500 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8501 f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8502 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8503 # ifdef FEAT_QUICKFIX |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8504 win_T *wp; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8505 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8506 if (in_vim9script() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8507 && (check_for_number_arg(argvars, 0) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8508 || check_for_opt_dict_arg(argvars, 1) == FAIL)) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8509 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8510 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8511 wp = find_win_by_nr_or_id(&argvars[0]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8512 get_qf_loc_list(FALSE, wp, &argvars[1], rettv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8513 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8514 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8515 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8516 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8517 * "getqflist()" function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8518 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8519 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8520 f_getqflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8521 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8522 # ifdef FEAT_QUICKFIX |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8523 if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8524 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8525 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8526 get_qf_loc_list(TRUE, NULL, &argvars[0], rettv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8527 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8528 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8529 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8530 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8531 * Used by "setqflist()" and "setloclist()" functions |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8532 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8533 static void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8534 set_qf_ll_list( |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8535 win_T *wp UNUSED, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8536 typval_T *list_arg UNUSED, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8537 typval_T *action_arg UNUSED, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8538 typval_T *what_arg UNUSED, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8539 typval_T *rettv) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8540 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8541 # ifdef FEAT_QUICKFIX |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8542 char_u *act; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8543 int action = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8544 static int recursive = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8545 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8546 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8547 rettv->vval.v_number = -1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8548 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8549 # ifdef FEAT_QUICKFIX |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8550 if (list_arg->v_type != VAR_LIST) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8551 emsg(_(e_list_required)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8552 else if (recursive != 0) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8553 emsg(_(e_autocommand_caused_recursive_behavior)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8554 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8555 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8556 list_T *l = list_arg->vval.v_list; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8557 dict_T *what = NULL; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8558 int valid_dict = TRUE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8559 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8560 if (action_arg->v_type == VAR_STRING) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8561 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8562 act = tv_get_string_chk(action_arg); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8563 if (act == NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8564 return; // type error; errmsg already given |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8565 if ((*act == 'a' || *act == 'r' || *act == ' ' || *act == 'f') && |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8566 act[1] == NUL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8567 action = *act; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8568 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8569 semsg(_(e_invalid_action_str_1), act); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8570 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8571 else if (action_arg->v_type == VAR_UNKNOWN) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8572 action = ' '; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8573 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8574 emsg(_(e_string_required)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8575 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8576 if (action_arg->v_type != VAR_UNKNOWN |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8577 && what_arg->v_type != VAR_UNKNOWN) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8578 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8579 if (what_arg->v_type == VAR_DICT && what_arg->vval.v_dict != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8580 what = what_arg->vval.v_dict; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8581 else |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8582 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8583 emsg(_(e_dictionary_required)); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8584 valid_dict = FALSE; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8585 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8586 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8587 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8588 ++recursive; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8589 if (l != NULL && action && valid_dict |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8590 && set_errorlist(wp, l, action, |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8591 (char_u *)(wp == NULL ? ":setqflist()" : ":setloclist()"), |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8592 what) == OK) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8593 rettv->vval.v_number = 0; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8594 --recursive; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8595 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8596 # endif |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8597 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8598 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8599 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8600 * "setloclist()" function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8601 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8602 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8603 f_setloclist(typval_T *argvars, typval_T *rettv) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8604 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8605 win_T *win; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8606 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8607 rettv->vval.v_number = -1; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8608 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8609 if (in_vim9script() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8610 && (check_for_number_arg(argvars, 0) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8611 || check_for_list_arg(argvars, 1) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8612 || check_for_opt_string_arg(argvars, 2) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8613 || (argvars[2].v_type != VAR_UNKNOWN |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8614 && check_for_opt_dict_arg(argvars, 3) == FAIL))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8615 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8616 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8617 win = find_win_by_nr_or_id(&argvars[0]); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8618 if (win != NULL) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8619 set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8620 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8621 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8622 /* |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8623 * "setqflist()" function |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8624 */ |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8625 void |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8626 f_setqflist(typval_T *argvars, typval_T *rettv) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8627 { |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8628 if (in_vim9script() |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8629 && (check_for_list_arg(argvars, 0) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8630 || check_for_opt_string_arg(argvars, 1) == FAIL |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8631 || (argvars[1].v_type != VAR_UNKNOWN |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8632 && check_for_opt_dict_arg(argvars, 2) == FAIL))) |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8633 return; |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8634 |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8635 set_qf_ll_list(NULL, &argvars[0], &argvars[1], &argvars[2], rettv); |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8636 } |
448aef880252
normalize line endings
Christian Brabandt <cb@256bit.org>
parents:
32568
diff
changeset
|
8637 #endif |