annotate src/quickfix.c @ 788:b5aed52a4881

updated for version 7.0230
author vimboss
date Mon, 20 Mar 2006 21:47:49 +0000
parents 3d0ca316efab
children b29b006d52d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * quickfix.c: functions for quickfix mode, using a file with error messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #if defined(FEAT_QUICKFIX) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 struct dir_stack_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 struct dir_stack_T *next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char_u *dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 static struct dir_stack_T *dir_stack = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 /*
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
27 * For each error the next struct is allocated and linked in a list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
29 typedef struct qfline_S qfline_T;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
30 struct qfline_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
32 qfline_T *qf_next; /* pointer to next error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
33 qfline_T *qf_prev; /* pointer to previous error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
34 linenr_T qf_lnum; /* line number where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
35 int qf_fnum; /* file number for the line */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
36 int qf_col; /* column where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
37 int qf_nr; /* error number */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
38 char_u *qf_pattern; /* search pattern for the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
39 char_u *qf_text; /* description of the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
40 char_u qf_viscol; /* set to TRUE if qf_col is screen column */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
41 char_u qf_cleared; /* set to TRUE if line has been deleted */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
42 char_u qf_type; /* type of the error (mostly 'E'); 1 for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 :helpgrep */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
44 char_u qf_valid; /* valid error message detected */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 * There is a stack of error lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 #define LISTCOUNT 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
52 typedef struct qf_list_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
54 qfline_T *qf_start; /* pointer to the first error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
55 qfline_T *qf_ptr; /* pointer to the current error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
56 int qf_count; /* number of errors (0 means no error list) */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
57 int qf_index; /* current index in the error list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
58 int qf_nonevalid; /* TRUE if not a single valid entry found */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
59 } qf_list_T;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
60
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
61 struct qf_info_S
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
62 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
63 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
64 * Count of references to this list. Used only for location lists.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
65 * When a location list window reference this list, qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
66 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
67 * reaches 0, the list is freed.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
68 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
69 int qf_refcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
70 int qf_listcount; /* current number of lists */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
71 int qf_curlist; /* current error list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
72 qf_list_T qf_lists[LISTCOUNT];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
73 };
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
74
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
75 static qf_info_T ql_info; /* global quickfix list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
77 #define FMT_PATTERNS 10 /* maximum number of % recognized */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 * Structure used to hold the info of one part of 'errorformat'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 struct eformat
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 regprog_T *prog; /* pre-formatted part of 'errorformat' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 struct eformat *next; /* pointer to next (NULL if last) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 char_u prefix; /* prefix of this format line: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 /* 'D' enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 /* 'X' leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 /* 'A' start of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 /* 'E' error message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 /* 'W' warning message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 /* 'I' informational message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 /* 'C' continuation line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 /* 'Z' end of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 /* 'G' general, unspecific message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 /* 'P' push file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 /* 'Q' pop/quit file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 /* 'O' overread (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 char_u flags; /* additional flags given in prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 /* '-' do not include this line */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
102 /* '+' include whole line in message */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
105 static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
106 static void qf_new_list __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
107 static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
108 static void qf_msg __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
109 static void qf_free __ARGS((qf_info_T *qi, int idx));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 static char_u *qf_types __ARGS((int, int));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 static int qf_get_fnum __ARGS((char_u *, char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 static char_u *qf_push_dir __ARGS((char_u *, struct dir_stack_T **));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 static char_u *qf_pop_dir __ARGS((struct dir_stack_T **));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 static char_u *qf_guess_filepath __ARGS((char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 static void qf_fmt_text __ARGS((char_u *text, char_u *buf, int bufsize));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 static void qf_clean_dir_stack __ARGS((struct dir_stack_T **));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
118 static int qf_win_pos_update __ARGS((qf_info_T *qi, int old_qf_index));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
119 static win_T *qf_find_win __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
120 static buf_T *qf_find_buf __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
121 static void qf_update_buffer __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
122 static void qf_fill_buffer __ARGS((qf_info_T *qi));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 static char_u *get_mef_name __ARGS((void));
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
125 static buf_T *load_dummy_buffer __ARGS((char_u *fname));
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
126 static void wipe_dummy_buffer __ARGS((buf_T *buf));
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
127 static void unload_dummy_buffer __ARGS((buf_T *buf));
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
128 static qf_info_T *ll_get_or_alloc_list __ARGS((win_T *));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
130 /* Quickfix window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
131 #define IS_QF_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
132 /* Location list window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
133 #define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
134 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
135 * Return location list for window 'wp'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
136 * For location list window, return the referenced location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
137 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
138 #define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
139
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
141 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
142 * list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 * Return -1 for error, number of errors for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 int
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
146 qf_init(wp, efile, errorformat, newlist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
147 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 char_u *efile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 char_u *errorformat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 int newlist; /* TRUE: start a new error list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
152 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
153
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
154 if (efile == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
155 return FAIL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
156
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
157 if (wp != NULL)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
158 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
159 qi = ll_get_or_alloc_list(wp);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
160 if (qi == NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
161 return FAIL;
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
162 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
163
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
164 return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist,
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
165 (linenr_T)0, (linenr_T)0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
166 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
167
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
168 /*
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
169 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
170 * list.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
171 * Alternative: when "efile" is null read errors from buffer "buf".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
172 * Always use 'errorformat' from "buf" if there is a local value.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
173 * Then lnumfirst and lnumlast specify the range of lines to use.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
174 * Return -1 for error, number of errors for success.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
175 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
176 static int
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
177 qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
178 qf_info_T *qi;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
179 char_u *efile;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
180 buf_T *buf;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
181 typval_T *tv;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
182 char_u *errorformat;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
183 int newlist; /* TRUE: start a new error list */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
184 linenr_T lnumfirst; /* first line number to use */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
185 linenr_T lnumlast; /* last line number to use */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
186 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 char_u *namebuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 char_u *errmsg;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
189 char_u *pattern;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 char_u *fmtstr = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 int col = 0;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
192 char_u use_viscol = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 int type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 int valid;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
195 linenr_T buflnum = lnumfirst;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 long lnum = 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 int enr = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
198 FILE *fd = NULL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
199 qfline_T *qfprev = NULL; /* init to make SASC shut up */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 char_u *efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 struct eformat *fmt_first = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 struct eformat *fmt_last = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 struct eformat *fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 char_u *efm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 char_u *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 char_u *srcptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 int round;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 int idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 int multiline = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 int multiignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 int multiscan = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 int retval = -1; /* default: return error flag */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 char_u *directory = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 char_u *currfile = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 char_u *tail = NULL;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
218 char_u *p_str = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
219 listitem_T *p_li = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 struct dir_stack_T *file_stack = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 static struct fmtpattern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 char_u convchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 char *pattern;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 } fmt_pat[FMT_PATTERNS] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
228 {'f', ".\\+"}, /* only used when at end */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 {'n', "\\d\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 {'l', "\\d\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {'c', "\\d\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 {'t', "."},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 {'m', ".\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 {'r', ".*"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 {'p', "[- .]*"},
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
236 {'v', "\\d\\+"},
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
237 {'s', ".\\+"}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 namebuf = alloc(CMDBUFFSIZE + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 errmsg = alloc(CMDBUFFSIZE + 1);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
242 pattern = alloc(CMDBUFFSIZE + 1);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
243 if (namebuf == NULL || errmsg == NULL || pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
246 if (efile != NULL && (fd = mch_fopen((char *)efile, "r")) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 EMSG2(_(e_openerrf), efile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
252 if (newlist || qi->qf_curlist == qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 /* make place for a new list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
254 qf_new_list(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
255 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 /* Adding to existing list, find last entry. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
257 for (qfprev = qi->qf_lists[qi->qf_curlist].qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 qfprev->qf_next != qfprev; qfprev = qfprev->qf_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 * Each part of the format string is copied and modified from errorformat to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 * regex prog. Only a few % characters are allowed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 /* Use the local value of 'errorformat' if it's set. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
266 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
267 efm = buf->b_p_efm;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 efm = errorformat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 * Get some space to modify the format string into.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 for (round = FMT_PATTERNS; round > 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 i += (int)STRLEN(fmt_pat[--round].pattern);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 #ifdef COLON_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 i += 12; /* "%f" can become twelve chars longer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 i += 2; /* "%f" can become two chars longer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 if ((fmtstr = alloc(i)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 while (efm[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 * Allocate a new eformat structure and put it at the end of the list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 fmt_ptr = (struct eformat *)alloc((unsigned)sizeof(struct eformat));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 if (fmt_ptr == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 if (fmt_first == NULL) /* first one */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 fmt_first = fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 fmt_last->next = fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 fmt_last = fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 fmt_ptr->prefix = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 fmt_ptr->flags = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 fmt_ptr->next = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 fmt_ptr->prog = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 for (round = FMT_PATTERNS; round > 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 fmt_ptr->addr[--round] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 /* round is 0 now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 * Isolate one part in the 'errorformat' option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 for (len = 0; efm[len] != NUL && efm[len] != ','; ++len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 if (efm[len] == '\\' && efm[len + 1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 ++len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 * Build regexp pattern from current 'errorformat' option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 ptr = fmtstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 *ptr++ = '^';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 for (efmp = efm; efmp < efm + len; ++efmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 if (*efmp == '%')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 ++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 for (idx = 0; idx < FMT_PATTERNS; ++idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 if (fmt_pat[idx].convchar == *efmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 if (idx < FMT_PATTERNS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 if (fmt_ptr->addr[idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 _("E372: Too many %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 if ((idx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 && idx < 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 && vim_strchr((char_u *)"DXOPQ",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 fmt_ptr->prefix) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 || (idx == 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 && vim_strchr((char_u *)"OPQ",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 fmt_ptr->prefix) == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 _("E373: Unexpected %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 fmt_ptr->addr[idx] = (char_u)++round;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 *ptr++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 *ptr++ = '(';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 #ifdef BACKSLASH_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 if (*efmp == 'f')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 /* Also match "c:" in the file name, even when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 * checking for a colon next: "%f:".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 * "\%(\a:\)\=" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 STRCPY(ptr, "\\%(\\a:\\)\\=");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 ptr += 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 #endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
360 if (*efmp == 'f' && efmp[1] != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
362 if (efmp[1] != '\\' && efmp[1] != '%')
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
363 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
364 /* A file name may contain spaces, but this isn't
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
365 * in "\f". For "%f:%l:%m" there may be a ":" in
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
366 * the file name. Use ".\{-1,}x" instead (x is
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
367 * the next character), the requirement that :999:
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
368 * follows should work. */
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
369 STRCPY(ptr, ".\\{-1,}");
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
370 ptr += 7;
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
371 }
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
372 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
373 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
374 /* File name followed by '\\' or '%': include as
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
375 * many file name chars as possible. */
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
376 STRCPY(ptr, "\\f\\+");
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
377 ptr += 4;
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
378 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 srcptr = (char_u *)fmt_pat[idx].pattern;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 while ((*ptr = *srcptr++) != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 ++ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 *ptr++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 *ptr++ = ')';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 else if (*efmp == '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 if (*++efmp == '[' || *efmp == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 if ((*ptr++ = *efmp) == '[') /* %*[^a-z0-9] etc. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 if (efmp[1] == '^')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 *ptr++ = *++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 if (efmp < efm + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 *ptr++ = *++efmp; /* could be ']' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 while (efmp < efm + len
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 && (*ptr++ = *++efmp) != ']')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 /* skip */;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 if (efmp == efm + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 EMSG(_("E374: Missing ] in format string"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 else if (efmp < efm + len) /* %*\D, %*\s etc. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 *ptr++ = *++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 *ptr++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 *ptr++ = '+';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 _("E375: Unsupported %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 *ptr++ = *efmp; /* regexp magic characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 else if (*efmp == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 *ptr++ = '*';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 else if (efmp == efm + 1) /* analyse prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 if (vim_strchr((char_u *)"+-", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 fmt_ptr->flags = *efmp++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 fmt_ptr->prefix = *efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 _("E376: Invalid %%%c in format string prefix"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 _("E377: Invalid %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 else /* copy normal character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 if (*efmp == '\\' && efmp + 1 < efm + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 ++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 *ptr++ = '\\'; /* escape regexp atoms */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 if (*efmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 *ptr++ = *efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 *ptr++ = '$';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 *ptr = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 * Advance to next part
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 efm = skip_to_option_part(efm + len); /* skip comma and spaces */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 if (fmt_first == NULL) /* nothing found */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 EMSG(_("E378: 'errorformat' contains no pattern"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 * got_int is reset here, because it was probably set when killing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 * ":make" command, but we still want to read the errorfile then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 /* Always ignore case when looking for a matching error. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 regmatch.rm_ic = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
484 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
485 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
486 if (tv->v_type == VAR_STRING)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
487 p_str = tv->vval.v_string;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
488 else if (tv->v_type == VAR_LIST)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
489 p_li = tv->vval.v_list->lv_first;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
490 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
491
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 * Read the lines in the error file one by one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 * Try to recognize one of the error formats in each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
496 while (!got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 {
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
498 /* Get the next line. */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
499 if (fd == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
500 {
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
501 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
502 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
503 int len;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
504
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
505 if (tv->v_type == VAR_STRING)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
506 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
507 /* Get the next line from the supplied string */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
508 char_u *p;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
509
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
510 if (!*p_str) /* Reached the end of the string */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
511 break;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
512
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
513 p = vim_strchr(p_str, '\n');
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
514 if (p)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
515 len = p - p_str + 1;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
516 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
517 len = STRLEN(p_str);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
518
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
519 if (len > CMDBUFFSIZE - 2)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
520 vim_strncpy(IObuff, p_str, CMDBUFFSIZE - 2);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
521 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
522 vim_strncpy(IObuff, p_str, len);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
523
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
524 p_str += len;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
525 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
526 else if (tv->v_type == VAR_LIST)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
527 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
528 /* Get the next line from the supplied list */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
529 while (p_li && p_li->li_tv.v_type != VAR_STRING)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
530 p_li = p_li->li_next; /* Skip non-string items */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
531
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
532 if (!p_li) /* End of the list */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
533 break;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
534
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
535 len = STRLEN(p_li->li_tv.vval.v_string);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
536 if (len > CMDBUFFSIZE - 2)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
537 len = CMDBUFFSIZE - 2;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
538
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
539 vim_strncpy(IObuff, p_li->li_tv.vval.v_string, len);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
540
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
541 p_li = p_li->li_next; /* next item */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
542 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
543 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
544 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
545 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
546 /* Get the next line from the supplied buffer */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
547 if (buflnum > lnumlast)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
548 break;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
549 vim_strncpy(IObuff, ml_get_buf(buf, buflnum++, FALSE),
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
550 CMDBUFFSIZE - 2);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
551 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
552 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
553 else if (fgets((char *)IObuff, CMDBUFFSIZE - 2, fd) == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
554 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
555
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 IObuff[CMDBUFFSIZE - 2] = NUL; /* for very long lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 if ((efmp = vim_strrchr(IObuff, '\n')) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 *efmp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 #ifdef USE_CRNL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 if ((efmp = vim_strrchr(IObuff, '\r')) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 *efmp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 * Try to match each part of 'errorformat' until we find a complete
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 * match or no match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 valid = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 restofline:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 idx = fmt_ptr->prefix;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 if (multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 namebuf[0] = NUL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
576 pattern[0] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 if (!multiscan)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 errmsg[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 col = 0;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
581 use_viscol = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 enr = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 tail = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 regmatch.regprog = fmt_ptr->prog;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 if (vim_regexec(&regmatch, IObuff, (colnr_T)0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 if ((idx == 'C' || idx == 'Z') && !multiline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 if (vim_strchr((char_u *)"EWI", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 type = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 * Extract error message data from matched line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 {
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
600 int c = *regmatch.endp[i];
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
601
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
602 /* Expand ~/file and $HOME/file to full path. */
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
603 *regmatch.endp[i] = NUL;
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
604 expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE);
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
605 *regmatch.endp[i] = c;
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
606
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 if (vim_strchr((char_u *)"OPQ", idx) != NULL
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
608 && mch_getperm(namebuf) == -1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 enr = (int)atol((char *)regmatch.startp[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 lnum = atol((char *)regmatch.startp[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 col = (int)atol((char *)regmatch.startp[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 type = *regmatch.startp[i];
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
619 if (fmt_ptr->flags == '+' && !multiscan) /* %+ */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 STRCPY(errmsg, IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 410
diff changeset
624 vim_strncpy(errmsg, regmatch.startp[i], len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 tail = regmatch.startp[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 col = (int)(regmatch.endp[i] - regmatch.startp[i] + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 if (*((char_u *)regmatch.startp[i]) != TAB)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
632 use_viscol = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 col = (int)atol((char *)regmatch.startp[i]);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
637 use_viscol = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
639 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
640 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
641 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
642 if (len > CMDBUFFSIZE - 5)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
643 len = CMDBUFFSIZE - 5;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
644 STRCPY(pattern, "^\\V");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
645 STRNCAT(pattern, regmatch.startp[i], len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
646 pattern[len + 3] = '\\';
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
647 pattern[len + 4] = '$';
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
648 pattern[len + 5] = NUL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
649 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 multiscan = FALSE;
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
654 if (fmt_ptr == NULL || idx == 'D' || idx == 'X')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 {
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
656 if (fmt_ptr != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 if (idx == 'D') /* enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 if (*namebuf == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 EMSG(_("E379: Missing or empty directory name"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 if ((directory = qf_push_dir(namebuf, &dir_stack)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 else if (idx == 'X') /* leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 directory = qf_pop_dir(&dir_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 namebuf[0] = NUL; /* no match found, remove file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 lnum = 0; /* don't jump to this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 STRCPY(errmsg, IObuff); /* copy whole line to error message */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
675 if (fmt_ptr == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 multiline = multiignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 }
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
678 else if (fmt_ptr != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 if (vim_strchr((char_u *)"AEWI", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 multiline = TRUE; /* start of a multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 else if (vim_strchr((char_u *)"CZ", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 { /* continuation of multi-line msg */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 if (qfprev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 if (*errmsg && !multiignore)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 len = (int)STRLEN(qfprev->qf_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 if ((ptr = alloc((unsigned)(len + STRLEN(errmsg) + 2)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 STRCPY(ptr, qfprev->qf_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 vim_free(qfprev->qf_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 qfprev->qf_text = ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 *(ptr += len) = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 STRCPY(++ptr, errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 if (qfprev->qf_nr == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 qfprev->qf_nr = enr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 if (vim_isprintc(type) && !qfprev->qf_type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 qfprev->qf_type = type; /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 if (!qfprev->qf_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 qfprev->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 if (!qfprev->qf_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 qfprev->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
706 qfprev->qf_viscol = use_viscol;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 if (!qfprev->qf_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 qfprev->qf_fnum = qf_get_fnum(directory,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 *namebuf || directory ? namebuf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 : currfile && valid ? currfile : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 if (idx == 'Z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 multiline = multiignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 else if (vim_strchr((char_u *)"OPQ", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 /* global file names */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 if (*namebuf == NUL || mch_getperm(namebuf) >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 if (*namebuf && idx == 'P')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 currfile = qf_push_dir(namebuf, &file_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 else if (idx == 'Q')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 currfile = qf_pop_dir(&file_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 *namebuf = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 if (tail && *tail)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 STRCPY(IObuff, skipwhite(tail));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 multiscan = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 goto restofline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 if (fmt_ptr->flags == '-') /* generally exclude this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 if (multiline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 multiignore = TRUE; /* also exclude continuation lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
743 if (qf_add_entry(qi, &qfprev,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 directory,
129
2983cde45542 updated for version 7.0044
vimboss
parents: 123
diff changeset
745 (*namebuf || directory)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 ? namebuf
129
2983cde45542 updated for version 7.0044
vimboss
parents: 123
diff changeset
747 : ((currfile && valid) ? currfile : (char_u *)NULL),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 col,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
751 use_viscol,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
752 pattern,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 enr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 valid) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
759 if (fd == NULL || !ferror(fd))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
761 if (qi->qf_lists[qi->qf_curlist].qf_index == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
763 /* no valid entry found */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
764 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
765 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
766 qi->qf_lists[qi->qf_curlist].qf_index = 1;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
767 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
771 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
772 if (qi->qf_lists[qi->qf_curlist].qf_ptr == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
773 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
774 qi->qf_lists[qi->qf_curlist].qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
776 /* return number of matches */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
777 retval = qi->qf_lists[qi->qf_curlist].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 goto qf_init_ok;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 EMSG(_(e_readerrf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 error2:
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
782 qf_free(qi, qi->qf_curlist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
783 qi->qf_listcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
784 if (qi->qf_curlist > 0)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
785 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 qf_init_ok:
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
787 if (fd != NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
788 fclose(fd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_first)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 fmt_first = fmt_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 vim_free(fmt_ptr->prog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 vim_free(fmt_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 qf_clean_dir_stack(&dir_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 qf_clean_dir_stack(&file_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 qf_init_end:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 vim_free(namebuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 vim_free(errmsg);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
800 vim_free(pattern);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 vim_free(fmtstr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
804 qf_update_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 * Prepare for adding a new quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
814 qf_new_list(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
815 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 * If the current entry is not the last entry, delete entries below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 * the current entry. This makes it possible to browse in a tree-like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 * way with ":grep'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
824 while (qi->qf_listcount > qi->qf_curlist + 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
825 qf_free(qi, --qi->qf_listcount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 * When the stack is full, remove to oldest entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 * Otherwise, add a new entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
831 if (qi->qf_listcount == LISTCOUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
833 qf_free(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 for (i = 1; i < LISTCOUNT; ++i)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
835 qi->qf_lists[i - 1] = qi->qf_lists[i];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
836 qi->qf_curlist = LISTCOUNT - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 else
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
839 qi->qf_curlist = qi->qf_listcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
840 qi->qf_lists[qi->qf_curlist].qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
841 qi->qf_lists[qi->qf_curlist].qf_count = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
844 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
845 * Free a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
846 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
847 static void
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
848 ll_free_all(pqi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
849 qf_info_T **pqi;
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
850 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
851 int i;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
852 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
853
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
854 qi = *pqi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
855 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
856 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
857 *pqi = NULL; /* Remove reference to this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
858
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
859 qi->qf_refcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
860 if (qi->qf_refcount < 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
861 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
862 /* No references to this location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
863 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
864 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
865 vim_free(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
866 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
867 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
868
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
869 void
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
870 qf_free_all(wp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
871 win_T *wp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
872 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
873 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
874 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
875
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
876 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
877 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
878 /* location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
879 ll_free_all(&wp->w_llist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
880 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
881 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
882 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
883 /* quickfix list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
884 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
885 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
886 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
887
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 * Add an entry to the end of the list of errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 static int
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
893 qf_add_entry(qi, prevp, dir, fname, mesg, lnum, col, vis_col, pattern, nr, type,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
894 valid)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
895 qf_info_T *qi; /* quickfix list */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
896 qfline_T **prevp; /* pointer to previously added entry or NULL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 char_u *dir; /* optional directory name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 char_u *fname; /* file name or NULL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 char_u *mesg; /* message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 long lnum; /* line number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 int col; /* column */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
902 int vis_col; /* using visual column */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
903 char_u *pattern; /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 int nr; /* error number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 int type; /* type character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 int valid; /* valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
908 qfline_T *qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
910 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 qfp->qf_fnum = qf_get_fnum(dir, fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 vim_free(qfp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 qfp->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 qfp->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
920 qfp->qf_viscol = vis_col;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
921 if (pattern == NULL || *pattern == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
922 qfp->qf_pattern = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
923 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
924 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
925 vim_free(qfp->qf_text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
926 vim_free(qfp);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
927 return FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
928 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 qfp->qf_nr = nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 qfp->qf_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 qfp->qf_valid = valid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
935 if (qi->qf_lists[qi->qf_curlist].qf_count == 0)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
936 /* first element in the list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
938 qi->qf_lists[qi->qf_curlist].qf_start = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 qfp->qf_prev = qfp; /* first element points to itself */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 qfp->qf_prev = *prevp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 (*prevp)->qf_next = qfp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 qfp->qf_next = qfp; /* last element points to itself */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 qfp->qf_cleared = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 *prevp = qfp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
949 ++qi->qf_lists[qi->qf_curlist].qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
950 if (qi->qf_lists[qi->qf_curlist].qf_index == 0 && qfp->qf_valid)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
951 /* first valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
953 qi->qf_lists[qi->qf_curlist].qf_index =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
954 qi->qf_lists[qi->qf_curlist].qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
955 qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 /*
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
962 * Allocate a new location list
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
963 */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
964 static qf_info_T *
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
965 ll_new_list()
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
966 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
967 qf_info_T *qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
968
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
969 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
970 if (qi != NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
971 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
972 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
973 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
974 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
975
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
976 return qi;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
977 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
978
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
979 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
980 * Return the location list for window 'wp'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
981 * If not present, allocate a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
982 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
983 static qf_info_T *
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
984 ll_get_or_alloc_list(wp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
985 win_T *wp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
986 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
987 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
988 /* For a location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
989 return wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
990
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
991 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
992 * For a non-location list window, w_llist_ref should not point to a
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
993 * location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
994 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
995 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
996
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
997 if (wp->w_llist == NULL)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
998 wp->w_llist = ll_new_list(); /* new location list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
999 return wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1000 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1001
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1002 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1003 * Copy the location list from window "from" to window "to".
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1004 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1005 void
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1006 copy_loclist(from, to)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1007 win_T *from;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1008 win_T *to;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1009 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1010 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1011 int idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1012 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1013
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1014 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1015 * When copying from a location list window, copy the referenced
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1016 * location list. For other windows, copy the location list for
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1017 * that window.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1018 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1019 if (IS_LL_WINDOW(from))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1020 qi = from->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1021 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1022 qi = from->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1023
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1024 if (qi == NULL) /* no location list to copy */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1025 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1026
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1027 /* allocate a new location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1028 if ((to->w_llist = ll_new_list()) == NULL)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1029 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1030
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1031 to->w_llist->qf_listcount = qi->qf_listcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1032
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1033 /* Copy the location lists one at a time */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1034 for (idx = 0; idx < qi->qf_listcount; idx++)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1035 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1036 qf_list_T *from_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1037 qf_list_T *to_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1038
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1039 to->w_llist->qf_curlist = idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1040
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1041 from_qfl = &qi->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1042 to_qfl = &to->w_llist->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1043
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1044 /* Some of the fields are populated by qf_add_entry() */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1045 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1046 to_qfl->qf_count = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1047 to_qfl->qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1048 to_qfl->qf_start = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1049 to_qfl->qf_ptr = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1050
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1051 if (from_qfl->qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1052 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1053 qfline_T *from_qfp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1054 qfline_T *prevp = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1055
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1056 /* copy all the location entries in this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1057 for (i = 0, from_qfp = from_qfl->qf_start; i < from_qfl->qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1058 ++i, from_qfp = from_qfp->qf_next)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1059 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1060 if (qf_add_entry(to->w_llist, &prevp,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1061 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1062 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1063 from_qfp->qf_text,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1064 from_qfp->qf_lnum,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1065 from_qfp->qf_col,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1066 from_qfp->qf_viscol,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1067 from_qfp->qf_pattern,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1068 from_qfp->qf_nr,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1069 0,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1070 from_qfp->qf_valid) == FAIL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1071 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1072 qf_free_all(to);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1073 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1074 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1075 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1076 * qf_add_entry() will not set the qf_num field, as the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1077 * directory and file names are not supplied. So the qf_fnum
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1078 * field is copied here.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1079 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1080 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1081 prevp->qf_type = from_qfp->qf_type; /* error type */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1082 if (from_qfl->qf_ptr == from_qfp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1083 to_qfl->qf_ptr = prevp; /* current location */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1084 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1085 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1086
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1087 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1088
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1089 /* When no valid entries are present in the list, qf_ptr points to
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1090 * the first item in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1091 if (to_qfl->qf_nonevalid == TRUE)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1092 to_qfl->qf_ptr = to_qfl->qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1093 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1094
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1095 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1096 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1097
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1098 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 * get buffer number for file "dir.name"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 qf_get_fnum(directory, fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 char_u *directory;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 if (fname == NULL || *fname == NUL) /* no file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 #ifdef RISCOS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 /* Name is reported as `main.c', but file is `c.main' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 return ro_buflist_add(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 char_u *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 int fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 # ifdef VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 vms_remove_version(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 # ifdef BACKSLASH_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 if (directory != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 slash_adjust(directory);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 slash_adjust(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 if (directory != NULL && !vim_isAbsName(fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 * Here we check if the file really exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 * This should normally be true, but if make works without
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 * "leaving directory"-messages we might have missed a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 * directory change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 if (mch_getperm(ptr) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 vim_free(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 directory = qf_guess_filepath(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 if (directory)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 ptr = concat_fnames(directory, fname, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 ptr = vim_strsave(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 /* Use concatenated directory name and file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 fnum = buflist_add(ptr, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 vim_free(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 return fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 return buflist_add(fname, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 * push dirbuf onto the directory stack and return pointer to actual dir or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 * NULL on error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 qf_push_dir(dirbuf, stackptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 char_u *dirbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 struct dir_stack_T **stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 struct dir_stack_T *ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 /* allocate new stack element and hook it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 ds_new->next = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 *stackptr = ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 /* store directory on the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 if (vim_isAbsName(dirbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 || (*stackptr)->next == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 || (*stackptr && dir_stack != *stackptr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 /* Okay we don't have an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 * dirbuf must be a subdir of one of the directories on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 * Let's search...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 ds_new = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 (*stackptr)->dirname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 while (ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 if (mch_isdir((*stackptr)->dirname) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 ds_new = ds_new->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 while ((*stackptr)->next != ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 ds_ptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 (*stackptr)->next = (*stackptr)->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 /* Nothing found -> it must be on top level */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 if ((*stackptr)->dirname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 return (*stackptr)->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 * pop dirbuf from the directory stack and return previous directory or NULL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 * stack is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 qf_pop_dir(stackptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 struct dir_stack_T **stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 /* TODO: Should we check if dirbuf is the directory on top of the stack?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 * What to do if it isn't? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 /* pop top element and free it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 if (*stackptr != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 /* return NEW top element as current dir or NULL if stack is empty*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 return *stackptr ? (*stackptr)->dirname : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 * clean up directory stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 qf_clean_dir_stack(stackptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 struct dir_stack_T **stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 while ((ds_ptr = *stackptr) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 * Check in which directory of the directory stack the given file can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 * found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 * Returns a pointer to the directory name or NULL if not found
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 * Cleans up intermediate directory entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 * TODO: How to solve the following problem?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 * If we have the this directory tree:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 * ./
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 * ./aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 * ./aa/bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 * ./bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 * ./bb/x.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 * and make says:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 * making all in aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 * making all in bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 * x.c:9: Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 * qf_guess_filepath will return NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 qf_guess_filepath(filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 char_u *filename;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 struct dir_stack_T *ds_tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 char_u *fullname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 /* no dirs on the stack - there's nothing we can do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 if (dir_stack == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 ds_ptr = dir_stack->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 fullname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 while (ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 /* If concat_fnames failed, just go on. The worst thing that can happen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 * is that we delete the entire stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 if ((fullname != NULL) && (mch_getperm(fullname) >= 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 ds_ptr = ds_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 while (dir_stack->next != ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 ds_tmp = dir_stack->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 dir_stack->next = dir_stack->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 vim_free(ds_tmp->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 vim_free(ds_tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 return ds_ptr==NULL? NULL: ds_ptr->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 * jump to a quickfix line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 * if dir == FORWARD go "errornr" valid entries forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 * if dir == BACKWARD go "errornr" valid entries backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 * if dir == FORWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 * else if "errornr" is zero, redisplay the same line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 * else go to entry "errornr"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 void
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1341 qf_jump(qi, dir, errornr, forceit)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1342 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 int dir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 int errornr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 int forceit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1347 qf_info_T *ll_ref;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1348 qfline_T *qf_ptr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1349 qfline_T *old_qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 int qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 int old_qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 int old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 int prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 static char_u *e_no_more_items = (char_u *)N_("E553: No more items");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 char_u *err = e_no_more_items;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 linenr_T i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 buf_T *old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 linenr_T old_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 colnr_T screen_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 colnr_T char_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 #ifdef FEAT_WINDOWS
639
c79d4df4686e updated for version 7.0185
vimboss
parents: 634
diff changeset
1363 char_u *old_swb = p_swb;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 int opened_window = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 win_T *altwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 int print_message = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 int old_KeyTyped = KeyTyped; /* getting file may reset it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1373 int ok = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1374 int usable_win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1375
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1376 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1377 qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1378
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1379 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1380 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1386 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 old_qf_ptr = qf_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1388 qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 old_qf_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 if (dir == FORWARD || dir == FORWARD_FILE) /* next valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 while (errornr--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 old_qf_ptr = qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 prev_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 old_qf_fnum = qf_ptr->qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1399 if (qf_index == qi->qf_lists[qi->qf_curlist].qf_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 || qf_ptr->qf_next == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 qf_index = prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 if (err != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 EMSG(_(err));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 errornr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 ++qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 qf_ptr = qf_ptr->qf_next;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1414 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1415 && !qf_ptr->qf_valid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 err = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 else if (dir == BACKWARD || dir == BACKWARD_FILE) /* prev. valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 while (errornr--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 old_qf_ptr = qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 prev_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 old_qf_fnum = qf_ptr->qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 if (qf_index == 1 || qf_ptr->qf_prev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 qf_index = prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 if (err != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 EMSG(_(err));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 errornr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 --qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 qf_ptr = qf_ptr->qf_prev;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1443 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1444 && !qf_ptr->qf_valid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 err = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 else if (errornr != 0) /* go to specified number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 while (errornr < qf_index && qf_index > 1 && qf_ptr->qf_prev != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 --qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 qf_ptr = qf_ptr->qf_prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1456 while (errornr > qf_index && qf_index <
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1457 qi->qf_lists[qi->qf_curlist].qf_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 && qf_ptr->qf_next != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 ++qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 qf_ptr = qf_ptr->qf_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1466 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1467 if (qf_win_pos_update(qi, old_qf_index))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 /* No need to print the error message if it's visible in the error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 * window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 print_message = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 /*
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1473 * For ":helpgrep" find a help window or open one.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1474 */
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1475 if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0))
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1476 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1477 win_T *wp;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1478 int n;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1479
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1480 if (cmdmod.tab != 0)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1481 wp = NULL;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1482 else
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1483 for (wp = firstwin; wp != NULL; wp = wp->w_next)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1484 if (wp->w_buffer != NULL && wp->w_buffer->b_help)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1485 break;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1486 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1487 win_enter(wp, TRUE);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1488 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1489 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1490 /*
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1491 * Split off help window; put it at far top if no position
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1492 * specified, the current window is vertically split and narrow.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1493 */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1494 n = WSP_HELP;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1495 # ifdef FEAT_VERTSPLIT
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1496 if (cmdmod.split == 0 && curwin->w_width != Columns
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1497 && curwin->w_width < 80)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1498 n |= WSP_TOP;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1499 # endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1500 if (win_split(0, n) == FAIL)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1501 goto theend;
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
1502 opened_window = TRUE; /* close it when fail */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1503
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1504 if (curwin->w_height < p_hh)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1505 win_setheight((int)p_hh);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1506
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1507 if (qi != &ql_info) /* not a quickfix list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1508 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1509 /* The new window should use the supplied location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1510 qf_free_all(curwin);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1511 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1512 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1513 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1514 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1515
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1516 if (!p_im)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1517 restart_edit = 0; /* don't want insert mode in help file */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1518 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1519
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1520 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 * If currently in the quickfix window, find another window to show the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 * file in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
1524 if (bt_quickfix(curbuf) && !opened_window)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 * If there is no file specified, we don't know where to go.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 * But do advance, otherwise ":cn" gets stuck.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 if (qf_ptr->qf_fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1533 /* Locate a window showing a normal buffer */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1534 usable_win = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1535 FOR_ALL_WINDOWS(win)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1536 if (win->w_buffer->b_p_bt[0] == NUL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1537 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1538 usable_win = 1;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1539 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1540 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1541
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 * If there is only one window, create a new one above the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 * window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1546 if (firstwin == lastwin || !usable_win)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1548 ll_ref = curwin->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1549
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 if (win_split(0, WSP_ABOVE) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 goto failed; /* not enough room for window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 opened_window = TRUE; /* close it when fail */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 p_swb = empty_option; /* don't split again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 # ifdef FEAT_SCROLLBIND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 curwin->w_p_scb = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 # endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1557 if (ll_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1558 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1559 /* The new window should use the location list from the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1560 * location list window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1561 qf_free_all(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1562 curwin->w_llist = ll_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1563 ll_ref->qf_refcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1564 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1568 if (curwin->w_llist_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1569 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1570 /* In a location window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1571 ll_ref = curwin->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1572
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1573 /* Find the window with the same location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1574 FOR_ALL_WINDOWS(win)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1575 if (win->w_llist == ll_ref)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1576 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1577 if (win == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1578 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1579 /* Find the window showing the selected file */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1580 FOR_ALL_WINDOWS(win)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1581 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1582 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1583 if (win == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1584 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1585 /* Find a previous usable window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1586 win = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1587 do
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1588 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1589 if (win->w_buffer->b_p_bt[0] == NUL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1590 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1591 if (win->w_prev == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1592 win = lastwin; /* wrap around the top */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1593 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1594 win = win->w_prev; /* go to previous window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1595 } while (win != curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1596 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1597 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1598 win_goto(win);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1599
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1600 /* If the location list for the window is not set, then set it
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1601 * to the location list from the location window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1602 if (win->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1603 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1604 win->w_llist = ll_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1605 ll_ref->qf_refcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1606 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1607 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1608 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1609 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1610
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 * Try to find a window that shows the right buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 * Default to the window just above the quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 altwin = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 if (win->w_prev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 win = lastwin; /* wrap around the top */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 win = win->w_prev; /* go to previous window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1626 if (IS_QF_WINDOW(win))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 /* Didn't find it, go to the window before the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 * window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 if (altwin != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 win = altwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 else if (curwin->w_prev != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 win = curwin->w_prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 win = curwin->w_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 /* Remember a usable window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 if (altwin == NULL && !win->w_p_pvw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 && win->w_buffer->b_p_bt[0] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 altwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 win_goto(win);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1646 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 * If there is a file name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 * read the wanted file if needed, and check autowrite etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 old_lnum = curwin->w_cursor.lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1657
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1658 if (qf_ptr->qf_fnum != 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1659 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1660 if (qf_ptr->qf_type == 1)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1661 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1662 /* Open help file (do_ecmd() will set b_help flag, readfile() will
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1663 * set b_p_ro flag). */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1664 if (!can_abandon(curbuf, forceit))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1665 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1666 EMSG(_(e_nowrtmsg));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1667 ok = FALSE;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1668 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1669 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1670 ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1671 ECMD_HIDE + ECMD_SET_HELP);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1672 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1673 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1674 ok = buflist_getfile(qf_ptr->qf_fnum,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1675 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1676 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1677
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1678 if (ok == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 /* When not switched to another buffer, still need to set pc mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 if (curbuf == old_curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1684 if (qf_ptr->qf_pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1686 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1687 * Go to line with error, unless qf_lnum is 0.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1688 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1689 i = qf_ptr->qf_lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1690 if (i > 0)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1691 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1692 if (i > curbuf->b_ml.ml_line_count)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1693 i = curbuf->b_ml.ml_line_count;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1694 curwin->w_cursor.lnum = i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1695 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1696 if (qf_ptr->qf_col > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1698 curwin->w_cursor.col = qf_ptr->qf_col - 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1699 if (qf_ptr->qf_viscol == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1701 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1702 * Check each character from the beginning of the error
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1703 * line up to the error column. For each tab character
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1704 * found, reduce the error column value by the length of
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1705 * a tab character.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1706 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1707 line = ml_get_curline();
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1708 screen_col = 0;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1709 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1711 if (*line == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1712 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1713 if (*line++ == '\t')
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1714 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1715 curwin->w_cursor.col -= 7 - (screen_col % 8);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1716 screen_col += 8 - (screen_col % 8);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1717 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1718 else
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1719 ++screen_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1722 check_cursor();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1724 else
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1725 beginline(BL_WHITE | BL_FIX);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 else
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1728 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1729 pos_T save_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1730
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1731 /* Move the cursor to the first line in the buffer */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1732 save_cursor = curwin->w_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1733 curwin->w_cursor.lnum = 0;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1734 if (!do_search(NULL, '/', qf_ptr->qf_pattern, (long)1, SEARCH_KEEP))
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1735 curwin->w_cursor = save_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1736 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 foldOpenCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 if (print_message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 /* Update the screen before showing the message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 update_topline_redraw();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1747 qi->qf_lists[qi->qf_curlist].qf_count,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 qf_ptr->qf_cleared ? _(" (line deleted)") : "",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 /* Add the message, skipping leading whitespace and newlines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 /* Output the message. Overwrite to avoid scrolling when the 'O'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 * flag is present in 'shortmess'; But when not jumping, print the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 * whole message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 i = msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 msg_scroll = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 else if (!msg_scrolled && shortmess(SHM_OVERALL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 msg_attr_keep(IObuff, 0, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 msg_scroll = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 if (opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 win_close(curwin, TRUE); /* Close opened window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 if (qf_ptr->qf_fnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 * Couldn't open file, so put index back where it was. This could
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 * happen if the file was readonly and we changed something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 failed:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 qf_index = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 theend:
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1786 qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1787 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 if (p_swb != old_swb && opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 /* Restore old 'switchbuf' value, but not when an autocommand or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 * modeline has changed the value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 if (p_swb == empty_option)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 p_swb = old_swb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 free_string_option(old_swb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 * ":clist": list all errors
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1803 * ":llist": list all locations
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 qf_list(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1809 buf_T *buf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1810 char_u *fname;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1811 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1812 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1813 int idx1 = 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1814 int idx2 = -1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1815 int need_return = TRUE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1816 char_u *arg = eap->arg;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1817 int all = eap->forceit; /* if not :cl!, only show
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 recognised errors */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1819 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1820
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1821 if (eap->cmdidx == CMD_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1822 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1823 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1824 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1825 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1826 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1827 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1828 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1829 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1830
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1831 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1832 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1842 i = qi->qf_lists[qi->qf_curlist].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 if (idx1 < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 idx1 = (-idx1 > i) ? 0 : idx1 + i + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 if (idx2 < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 idx2 = (-idx2 > i) ? 0 : idx2 + i + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1848 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 all = TRUE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1850 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1851 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 if (need_return)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 msg_putchar('\n');
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1858 if (got_int)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1859 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 need_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1862
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1863 fname = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1864 if (qfp->qf_fnum != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1866 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1867 fname = buf->b_fname;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1868 if (qfp->qf_type == 1) /* :helpgrep */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1869 fname = gettail(fname);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1870 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1871 if (fname == NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1872 sprintf((char *)IObuff, "%2d", i);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1873 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1874 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 236
diff changeset
1875 i, (char *)fname);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1876 msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1877 ? hl_attr(HLF_L) : hl_attr(HLF_D));
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1878 if (qfp->qf_lnum == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1879 IObuff[0] = NUL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1880 else if (qfp->qf_col == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1881 sprintf((char *)IObuff, ":%ld", qfp->qf_lnum);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1882 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1883 sprintf((char *)IObuff, ":%ld col %d",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 qfp->qf_lnum, qfp->qf_col);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1885 sprintf((char *)IObuff + STRLEN(IObuff), "%s:",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1887 msg_puts_attr(IObuff, hl_attr(HLF_N));
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1888 if (qfp->qf_pattern != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1889 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1890 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1891 STRCAT(IObuff, ":");
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1892 msg_puts(IObuff);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1893 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1894 msg_puts((char_u *)" ");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1895
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1896 /* Remove newlines and leading whitespace from the text. For an
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1897 * unrecognized line keep the indent, the compiler may mark a word
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1898 * with ^^^^. */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1899 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 IObuff, IOSIZE);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1902 msg_prt_line(IObuff, FALSE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1903 out_flush(); /* show one line at a time */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1904 need_return = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1906
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1907 qfp = qfp->qf_next;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1908 ++i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 * Remove newlines and leading whitespace from an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 * Put the result in "buf[bufsize]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 qf_fmt_text(text, buf, bufsize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 int bufsize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 char_u *p = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 for (i = 0; *p != NUL && i < bufsize - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 buf[i] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 while (*++p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 if (!vim_iswhite(*p) && *p != '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 buf[i] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 buf[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 * ":colder [count]": Up in the quickfix stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 * ":cnewer [count]": Down in the quickfix stack.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1944 * ":lolder [count]": Up in the location list stack.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1945 * ":lnewer [count]": Down in the location list stack.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 qf_age(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1951 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1954 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1955 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1956 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1957 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1958 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1959 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1960 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1961 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1962 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1963
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 while (count--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1970 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1972 if (qi->qf_curlist == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 EMSG(_("E380: At bottom of quickfix stack"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1977 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1981 if (qi->qf_curlist >= qi->qf_listcount - 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 EMSG(_("E381: At top of quickfix stack"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1986 ++qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1989 qf_msg(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1990
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1994 qf_msg(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1995 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 smsg((char_u *)_("error list %d of %d; %d errors"),
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1998 qi->qf_curlist + 1, qi->qf_listcount,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1999 qi->qf_lists[qi->qf_curlist].qf_count);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2001 qf_update_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 /*
581
ec04f19aed55 updated for version 7.0165
vimboss
parents: 532
diff changeset
2006 * Free error list "idx".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2009 qf_free(qi, idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2010 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2013 qfline_T *qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2015 while (qi->qf_lists[idx].qf_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2017 qfp = qi->qf_lists[idx].qf_start->qf_next;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2018 vim_free(qi->qf_lists[idx].qf_start->qf_text);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2019 vim_free(qi->qf_lists[idx].qf_start->qf_pattern);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2020 vim_free(qi->qf_lists[idx].qf_start);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2021 qi->qf_lists[idx].qf_start = qfp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2022 --qi->qf_lists[idx].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 * qf_mark_adjust: adjust marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2030 qf_mark_adjust(wp, line1, line2, amount, amount_after)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2031 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 linenr_T line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 linenr_T line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 long amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 long amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2037 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2038 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2039 int idx;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2040 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2041
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2042 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2043 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2044 if (wp->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2045 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2046 qi = wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2047 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2048
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2049 for (idx = 0; idx < qi->qf_listcount; ++idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2050 if (qi->qf_lists[idx].qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2051 for (i = 0, qfp = qi->qf_lists[idx].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2052 i < qi->qf_lists[idx].qf_count; ++i, qfp = qfp->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 if (qfp->qf_fnum == curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 if (amount == MAXLNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 qfp->qf_cleared = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 qfp->qf_lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 else if (amount_after && qfp->qf_lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 qfp->qf_lnum += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 * Make a nice message out of the error character and the error number:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 * char number message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 * e or E 0 " error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 * w or W 0 " warning"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 * i or I 0 " info"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 * 0 0 ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 * other 0 " c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 * e or E n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 * w or W n " warning n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 * i or I n " info n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 * 0 n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 * other n " c n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 * 1 x "" :helpgrep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 qf_types(c, nr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 int c, nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 static char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 static char_u cc[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 if (c == 'W' || c == 'w')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 p = (char_u *)" warning";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 else if (c == 'I' || c == 'i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 p = (char_u *)" info";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 p = (char_u *)" error";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 else if (c == 0 || c == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 p = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 cc[0] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 cc[1] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 cc[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 p = cc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 if (nr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 sprintf((char *)buf, "%s %3d", (char *)p, nr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 #if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 * ":cwindow": open the quickfix window if we have errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 * close it if not.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2117 * ":lwindow": open the location list window if we have locations to display,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2118 * close it if not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 ex_cwindow(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2124 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2127 if (eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2128 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2129 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2130 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2131 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2132 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2133
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2134 /* Look for an existing quickfix window. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2135 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 * If a quickfix window is open but we have no errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 * close the window. If a quickfix window is not open, then open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 * it if we have errors; otherwise, leave it closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2142 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2143 || qi->qf_curlist >= qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 ex_cclose(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 else if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 ex_copen(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 * ":cclose": close the window showing the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2154 * ":lclose": close the window showing the location list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 ex_cclose(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2161 win_T *win = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2162 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2163
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2164 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2165 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2166 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2167 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2168 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2169 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2170
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2171 /* Find existing quickfix window and close it. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2172 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 win_close(win, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 * ":copen": open a window that shows the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2179 * ":lopen": open a window that shows the location list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 ex_copen(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2185 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 win_T *win;
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2188 tabpage_T *prevtab = curtab;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2190 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2191 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2192 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2193 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2194 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2195 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2196 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2197 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2198 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2199
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 height = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 height = QF_WINHEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2206 reset_VIsual_and_resel(); /* stop Visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 * Find existing quickfix window, or open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2215 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2216
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2217 if (win != NULL && cmdmod.tab == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 win_goto(win);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 /* The current window becomes the previous window afterwards. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2224 if (eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2225 /* Create the new window at the very bottom. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2226 win_goto(lastwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 if (win_split(height, WSP_BELOW) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 return; /* not enough room for window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 #ifdef FEAT_SCROLLBIND
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 curwin->w_p_scb = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2233 /* Remove the location list for the quickfix window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2234 qf_free_all(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2235
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2236 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2238 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2239 * For the location list window, create a reference to the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2240 * location list from the window 'win'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2241 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2242 curwin->w_llist_ref = win->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2243 win->w_llist->qf_refcount++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2245
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2246 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2247 /* switch off 'swapfile' */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2248 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2249 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
729
3d0ca316efab updated for version 7.0221
vimboss
parents: 717
diff changeset
2250 OPT_LOCAL);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2251 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2252 set_option_value((char_u *)"diff", 0L, (char_u *)"", OPT_LOCAL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2254 /* Only set the height when still in the same tab page and there is no
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2255 * window to the side. */
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2256 if (curtab == prevtab
119
e8f07016e34d updated for version 7.0042
vimboss
parents: 95
diff changeset
2257 #ifdef FEAT_VERTSPLIT
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2258 && curwin->w_width == Columns
119
e8f07016e34d updated for version 7.0042
vimboss
parents: 95
diff changeset
2259 #endif
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2260 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 win_setheight(height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 if (win_valid(win))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 prevwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 * Fill the buffer with the quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2270 qf_fill_buffer(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2271
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2272 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 * Return the number of the current entry (line number in the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 * window).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 linenr_T
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2283 qf_current_entry(wp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2284 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2286 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2287
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2288 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2289 /* In the location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2290 qi = wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2291
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2292 return qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 * Update the cursor position in the quickfix window to the current error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 * Return TRUE if there is a quickfix window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 static int
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2300 qf_win_pos_update(qi, old_qf_index)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2301 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 int old_qf_index; /* previous qf_index or zero */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 win_T *win;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2305 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 * Put the cursor on the current error in the quickfix window, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 * it's viewable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2311 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 if (win != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 && qf_index <= win->w_buffer->b_ml.ml_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 && old_qf_index != qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 win_T *old_curwin = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 curwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 curbuf = win->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 if (qf_index > old_qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 curwin->w_redraw_top = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 curwin->w_redraw_bot = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 curwin->w_redraw_top = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 curwin->w_redraw_bot = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 curwin->w_cursor.lnum = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 curwin->w_redr_status = TRUE; /* update ruler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 curwin = old_curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 curbuf = curwin->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 return win != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 /*
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2342 * Find a window displaying the quickfix/location list 'qi'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2343 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2344 static win_T *
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2345 qf_find_win(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2346 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2347 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2348 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2349
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2350 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2351 * When searching for the quickfix buffer, find a window
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2352 * with w_llist_ref set to NULL.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2353 * When searching for the location list buffer, find a window
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2354 * with w_llist_ref pointing to the supplied location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2355 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2356 FOR_ALL_WINDOWS(win)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2357 if (bt_quickfix(win->w_buffer))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2358 if ((qi == &ql_info && win->w_llist_ref == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2359 || (qi != &ql_info && win->w_llist_ref == qi))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2360 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2361
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2362 return win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2363 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2364
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2365 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 * Find quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 static buf_T *
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2369 qf_find_buf(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2370 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2372 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2373
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2374 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2375
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2376 return (win != NULL) ? win->w_buffer: NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 * Find the quickfix buffer. If it exists, update the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2383 qf_update_buffer(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2384 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 #ifdef FEAT_AUTOCMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 aco_save_T aco;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 buf_T *save_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 /* Check if a buffer for the quickfix list exists. Update it. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2394 buf = qf_find_buf(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 #ifdef FEAT_AUTOCMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 /* set curwin/curbuf to buf and save a few things */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 aucmd_prepbuf(&aco, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 save_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 curbuf = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2405 qf_fill_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 #ifdef FEAT_AUTOCMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408 /* restore curwin/curbuf and a few other things */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 aucmd_restbuf(&aco);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 curbuf = save_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2414 (void)qf_win_pos_update(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 * Fill current buffer with quickfix errors, replacing any previous contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 * curbuf must be the quickfix buffer!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2423 qf_fill_buffer(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2424 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2426 linenr_T lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2427 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2428 buf_T *errbuf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2429 int len;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2430 int old_KeyTyped = KeyTyped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 /* delete all existing lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 (void)ml_delete((linenr_T)1, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 /* Check if there is anything to display */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2437 if (qi->qf_curlist < qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 /* Add one line for each error */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2440 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2441 for (lnum = 0; lnum < qi->qf_lists[qi->qf_curlist].qf_count; ++lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 if (qfp->qf_fnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 && errbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 if (qfp->qf_type == 1) /* :helpgrep */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 STRCPY(IObuff, gettail(errbuf->b_fname));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 STRCPY(IObuff, errbuf->b_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 if (qfp->qf_lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 if (qfp->qf_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 sprintf((char *)IObuff + len, " col %d", qfp->qf_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 sprintf((char *)IObuff + len, "%s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2472 else if (qfp->qf_pattern != NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2473 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2474 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2475 len += (int)STRLEN(IObuff + len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2476 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 IObuff[len++] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 /* Remove newlines and leading whitespace from the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 * For an unrecognized line keep the indent, the compiler may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 * mark a word with ^^^^. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 if (ml_append(lnum, IObuff, (colnr_T)STRLEN(IObuff) + 1, FALSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 qfp = qfp->qf_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 /* Delete the empty line which is now at the end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 (void)ml_delete(lnum + 1, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 /* correct cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 check_lnums(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 /* Set the 'filetype' to "qf" each time after filling the buffer. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 * resembles reading a file into a buffer, it's more logical when using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 * autocommands. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 curbuf->b_p_ma = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 #ifdef FEAT_AUTOCMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 FALSE, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 FALSE, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 /* make sure it will be redrawn */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 redraw_curbuf_later(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 /* Restore KeyTyped, setting 'filetype' may reset it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 KeyTyped = old_KeyTyped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 #endif /* FEAT_WINDOWS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 * Return TRUE if "buf" is the quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 bt_quickfix(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 return (buf->b_p_bt[0] == 'q');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 /*
17
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
2531 * Return TRUE if "buf" is a "nofile" or "acwrite" buffer.
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
2532 * This means the buffer name is not a file name.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 bt_nofile(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 {
17
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
2538 return (buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
2539 || buf->b_p_bt[0] == 'a';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 * Return TRUE if "buf" is a "nowrite" or "nofile" buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 bt_dontwrite(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 return (buf->b_p_bt[0] == 'n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 bt_dontwrite_msg(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 if (bt_dontwrite(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 EMSG(_("E382: Cannot write, 'buftype' option is set"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 * and 'bufhidden'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 buf_hide(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572 /* 'bufhidden' overrules 'hidden' and ":hide", check it first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 switch (buf->b_p_bh[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 case 'u': /* "unload" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 case 'w': /* "wipe" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 case 'd': return FALSE; /* "delete" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 case 'h': return TRUE; /* "hide" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 return (p_hid || cmdmod.hide);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2584 * Return TRUE when using ":vimgrep" for ":grep".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2585 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2586 int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2587 grep_internal(cmdidx)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2588 cmdidx_T cmdidx;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2589 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2590 return ((cmdidx == CMD_grep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2591 || cmdidx == CMD_lgrep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2592 || cmdidx == CMD_grepadd
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2593 || cmdidx == CMD_lgrepadd)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2594 && STRCMP("internal",
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2595 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2596 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2597
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2598 /*
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2599 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 ex_make(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 {
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2605 char_u *fname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 char_u *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 unsigned len;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2608 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2609 qf_info_T *qi = &ql_info;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2610 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2611 char_u *au_name = NULL;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2612
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2613 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2614 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2615 case CMD_make: au_name = (char_u *)"make"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2616 case CMD_lmake: au_name = (char_u *)"lmake"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2617 case CMD_grep: au_name = (char_u *)"grep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2618 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2619 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2620 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2621 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2622 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2623 if (au_name != NULL)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2624 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2625 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2626 curbuf->b_fname, TRUE, curbuf);
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
2627 # ifdef FEAT_EVAL
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2628 if (did_throw || force_abort)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2629 return;
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
2630 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2631 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2632 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2634 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2635 if (grep_internal(eap->cmdidx))
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2636 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2637 ex_vimgrep(eap);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2638 return;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2639 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2640
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2641 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2642 || eap->cmdidx == CMD_lgrepadd)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2643 wp = curwin;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2644
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 autowrite_all();
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2646 fname = get_mef_name();
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2647 if (fname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 return;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2649 mch_remove(fname); /* in case it's not unique */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 * If 'shellpipe' empty: don't redirect to 'errorfile'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2656 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 cmd = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 (char *)p_shq);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2663 append_redir(cmd, p_sp, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 * Output a newline if there's something else than the :make command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 * was typed (in which case the cursor is in column 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 MSG_PUTS(":!");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 msg_outtrans(cmd); /* show what we are doing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 /* let the shell know if we are redirecting output or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 #ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 /* read window status report and redraw before message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 (void)char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2683 if (qf_init(wp, fname, (eap->cmdidx != CMD_make
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2684 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2685 (eap->cmdidx != CMD_grepadd
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2686 && eap->cmdidx != CMD_lgrepadd)) > 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 && !eap->forceit)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2688 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2689 if (wp != NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2690 qi = GET_LOC_LIST(wp);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2691 qf_jump(qi, 0, 0, FALSE); /* display first error */
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2692 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2694 mch_remove(fname);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2695 vim_free(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 vim_free(cmd);
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2697
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2698 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2699 if (au_name != NULL)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2700 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2701 curbuf->b_fname, TRUE, curbuf);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2702 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 * Return the name for the errorfile, in allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 * Find a new unique name when 'makeef' contains "##".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 * Returns NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 get_mef_name()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 static int start = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 static int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 #ifdef HAVE_LSTAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 struct stat sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 if (*p_mef == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 name = vim_tempname('e');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 EMSG(_(e_notmp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 for (p = p_mef; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 if (p[0] == '#' && p[1] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 return vim_strsave(p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 /* Keep trying until the name doesn't exist yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 if (start == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 start = mch_get_pid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742 off += 19;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 name = alloc((unsigned)STRLEN(p_mef) + 30);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 STRCPY(name, p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 STRCAT(name, p + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 if (mch_getperm(name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 #ifdef HAVE_LSTAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752 /* Don't accept a symbolic link, its a security risk. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 && mch_lstat((char *)name, &sb) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 * ":cc", ":crewind", ":cfirst" and ":clast".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2764 * ":ll", ":lrewind", ":lfirst" and ":llast".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 ex_cc(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2770 qf_info_T *qi = &ql_info;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2771
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2772 if (eap->cmdidx == CMD_ll
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2773 || eap->cmdidx == CMD_lrewind
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2774 || eap->cmdidx == CMD_lfirst
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2775 || eap->cmdidx == CMD_llast)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2776 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2777 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2778 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2779 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2780 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2781 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2782 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2783 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2784
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2785 qf_jump(qi, 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 eap->addr_count > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 ? (int)eap->line2
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2788 : (eap->cmdidx == CMD_cc || eap->cmdidx == CMD_ll)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 ? 0
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2790 : (eap->cmdidx == CMD_crewind || eap->cmdidx == CMD_lrewind
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2791 || eap->cmdidx == CMD_cfirst || eap->cmdidx == CMD_lfirst)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 ? 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 : 32767,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 * ":cnext", ":cnfile", ":cNext" and ":cprevious".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2799 * ":lnext", ":lNext", ":lprevious", ":lnfile", ":lNfile" and ":lpfile".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 ex_cnext(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2805 qf_info_T *qi = &ql_info;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2806
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2807 if (eap->cmdidx == CMD_lnext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2808 || eap->cmdidx == CMD_lNext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2809 || eap->cmdidx == CMD_lprevious
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2810 || eap->cmdidx == CMD_lnfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2811 || eap->cmdidx == CMD_lNfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2812 || eap->cmdidx == CMD_lpfile)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2813 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2814 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2815 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2816 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2817 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2818 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2819 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2820 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2821
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2822 qf_jump(qi, (eap->cmdidx == CMD_cnext || eap->cmdidx == CMD_lnext)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823 ? FORWARD
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2824 : (eap->cmdidx == CMD_cnfile || eap->cmdidx == CMD_lnfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 ? FORWARD_FILE
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2826 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2827 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 ? BACKWARD_FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 : BACKWARD,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 eap->addr_count > 0 ? (int)eap->line2 : 1, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 /*
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2834 * ":cfile"/":cgetfile"/":caddfile" commands.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2835 * ":lfile"/":lgetfile"/":laddfile" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 ex_cfile(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2841 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2842 qf_info_T *qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2843
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2844 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2845 || eap->cmdidx == CMD_laddfile)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2846 wp = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2847
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 if (*eap->arg != NUL)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 682
diff changeset
2849 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2850
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2851 /*
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2852 * This function is used by the :cfile, :cgetfile and :caddfile
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2853 * commands.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2854 * :cfile always creates a new quickfix list and jumps to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2855 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2856 * :cgetfile creates a new quickfix list but doesn't jump to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2857 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2858 * :caddfile adds to an existing quickfix list. If there is no
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2859 * quickfix list then a new list is created.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2860 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2861 if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2862 && eap->cmdidx != CMD_laddfile)) > 0
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2863 && (eap->cmdidx == CMD_cfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2864 || eap->cmdidx == CMD_lfile))
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2865 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2866 if (wp != NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2867 qi = GET_LOC_LIST(wp);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2868 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
2869 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2873 * ":vimgrep {pattern} file(s)"
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2874 * ":vimgrepadd {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2875 * ":lvimgrep {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2876 * ":lvimgrepadd {pattern} file(s)"
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2877 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2878 void
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2879 ex_vimgrep(eap)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2880 exarg_T *eap;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2881 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2882 regmmatch_T regmatch;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
2883 int fcount;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2884 char_u **fnames;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
2885 char_u *s;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
2886 char_u *p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
2887 int fi;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2888 qf_info_T *qi = &ql_info;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2889 qfline_T *prevp = NULL;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2890 long lnum;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2891 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2892 int duplicate_name = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2893 int using_dummy;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2894 int found_match;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2895 buf_T *first_match_buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2896 time_t seconds = 0;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
2897 int save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2898 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2899 char_u *save_ei = NULL;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
2900 #endif
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
2901 #ifndef FEAT_AUTOCMD
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
2902 buf_T *save_curbuf;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
2903 #else
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2904 aco_save_T aco;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2905 char_u *au_name = NULL;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
2906 int flags = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
2907 colnr_T col;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2908 long tomatch;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2909
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2910 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2911 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2912 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2913 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2914 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2915 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2916 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2917 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2918 if (au_name != NULL)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2919 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2920 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2921 curbuf->b_fname, TRUE, curbuf);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2922 if (did_throw || force_abort)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2923 return;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2924 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2925 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2926
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2927 if (eap->cmdidx == CMD_lgrep
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2928 || eap->cmdidx == CMD_lvimgrep
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2929 || eap->cmdidx == CMD_lgrepadd
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2930 || eap->cmdidx == CMD_lvimgrepadd)
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2931 {
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2932 qi = ll_get_or_alloc_list(curwin);
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2933 if (qi == NULL)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2934 return;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2935 }
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2936
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2937 if (eap->addr_count > 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2938 tomatch = eap->line2;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2939 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2940 tomatch = MAXLNUM;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2941
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2942 /* Get the search pattern: either white-separated or enclosed in // */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2943 regmatch.regprog = NULL;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
2944 p = skip_vimgrep_pat(eap->arg, &s, &flags);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
2945 if (p == NULL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2946 {
282
33d9c918b8ab updated for version 7.0075
vimboss
parents: 277
diff changeset
2947 EMSG(_(e_invalpat));
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
2948 goto theend;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2949 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2950 regmatch.regprog = vim_regcomp(s, RE_MAGIC);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2951 if (regmatch.regprog == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2952 goto theend;
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 42
diff changeset
2953 regmatch.rmm_ic = p_ic;
410
c60ba877860b updated for version 7.0107
vimboss
parents: 359
diff changeset
2954 regmatch.rmm_maxcol = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2955
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2956 p = skipwhite(p);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2957 if (*p == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2958 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2959 EMSG(_("E683: File name missing or invalid pattern"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2960 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2961 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2962
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2963 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd &&
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2964 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2965 || qi->qf_curlist == qi->qf_listcount)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2966 /* make place for a new list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2967 qf_new_list(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2968 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2969 /* Adding to existing list, find last entry. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2970 for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2971 prevp->qf_next != prevp; prevp = prevp->qf_next)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2972 ;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2973
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2974 /* parse the list of arguments */
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 230
diff changeset
2975 if (get_arglist_exp(p, &fcount, &fnames) == FAIL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2976 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2977 if (fcount == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2978 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2979 EMSG(_(e_nomatch));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2980 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2981 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2982
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2983 seconds = (time_t)0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
2984 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2985 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2986 if (time(NULL) > seconds)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2987 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2988 /* Display the file name every second or so. */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2989 seconds = time(NULL);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2990 msg_start();
514
5ffc9de8bb26 updated for version 7.0144
vimboss
parents: 502
diff changeset
2991 p = msg_strtrunc(fnames[fi], TRUE);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2992 if (p == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2993 msg_outtrans(fnames[fi]);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2994 else
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2995 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2996 msg_outtrans(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2997 vim_free(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2998 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
2999 msg_clr_eos();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3000 msg_didout = FALSE; /* overwrite this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3001 msg_nowait = TRUE; /* don't wait for this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3002 msg_col = 0;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3003 out_flush();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3004 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3005
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3006 buf = buflist_findname_exp(fnames[fi]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3007 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3008 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3009 /* Remember that a buffer with this name already exists. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3010 duplicate_name = (buf != NULL);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3011 using_dummy = TRUE;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3012
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3013 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3014 /* Don't do Filetype autocommands to avoid loading syntax and
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3015 * indent scripts, a great speed improvement. */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3016 save_ei = au_event_disable(",Filetype");
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3017 #endif
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3018 /* Don't use modelines here, it's useless. */
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3019 save_mls = p_mls;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3020 p_mls = 0;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3021
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3022 /* Load file into a buffer, so that 'fileencoding' is detected,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3023 * autocommands applied, etc. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3024 buf = load_dummy_buffer(fnames[fi]);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3025
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3026 p_mls = save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3027 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3028 au_event_restore(save_ei);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3029 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3030 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3031 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3032 /* Use existing, loaded buffer. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3033 using_dummy = FALSE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3034
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3035 if (buf == NULL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3036 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3037 if (!got_int)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3038 smsg((char_u *)_("Cannot open file \"%s\""), fnames[fi]);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3039 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3040 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3041 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3042 /* Try for a match in all lines of the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3043 * For ":1vimgrep" look for first match only. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3044 found_match = FALSE;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3045 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3046 ++lnum)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3047 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3048 col = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3049 while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3050 col) > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3051 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3052 if (qf_add_entry(qi, &prevp,
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3053 NULL, /* dir */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3054 fnames[fi],
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3055 ml_get_buf(buf,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3056 regmatch.startpos[0].lnum + lnum, FALSE),
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3057 regmatch.startpos[0].lnum + lnum,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3058 regmatch.startpos[0].col + 1,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3059 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3060 NULL, /* search pattern */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3061 0, /* nr */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3062 0, /* type */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3063 TRUE /* valid */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3064 ) == FAIL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3065 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3066 got_int = TRUE;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3067 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3068 }
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3069 found_match = TRUE;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3070 if (--tomatch == 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3071 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3072 if ((flags & VGR_GLOBAL) == 0
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3073 || regmatch.endpos[0].lnum > 0)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3074 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3075 col = regmatch.endpos[0].col
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3076 + (col == regmatch.endpos[0].col);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3077 if (col > STRLEN(ml_get_buf(buf, lnum, FALSE)))
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3078 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3079 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3080 line_breakcheck();
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3081 if (got_int)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3082 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3083 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3084
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3085 if (using_dummy)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3086 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3087 if (found_match && first_match_buf == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3088 first_match_buf = buf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3089 if (duplicate_name)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3090 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3091 /* Never keep a dummy buffer if there is another buffer
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3092 * with the same name. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3093 wipe_dummy_buffer(buf);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3094 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3095 }
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3096 else if (!cmdmod.hide
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3097 || buf->b_p_bh[0] == 'u' /* "unload" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3098 || buf->b_p_bh[0] == 'w' /* "wipe" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3099 || buf->b_p_bh[0] == 'd') /* "delete" */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3100 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3101 /* When no match was found we don't need to remember the
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3102 * buffer, wipe it out. If there was a match and it
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3103 * wasn't the first one or we won't jump there: only
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3104 * unload the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3105 * Ignore 'hidden' here, because it may lead to having too
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3106 * many swap files. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3107 if (!found_match)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3108 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3109 wipe_dummy_buffer(buf);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3110 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3111 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3112 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3113 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3114 unload_dummy_buffer(buf);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3115 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3116 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3117 }
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3118
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3119 if (buf != NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3120 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3121 /* The buffer is still loaded, the Filetype autocommands
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3122 * need to be done now, in that buffer. And the modelines
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3123 * need to be done (again). But not the window-local
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3124 * options! */
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3125 #if defined(FEAT_AUTOCMD)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3126 aucmd_prepbuf(&aco, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3127 #else
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3128 save_curbuf = curbuf;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3129 curbuf = buf;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3130 curwin->w_buffer = curbuf;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3131 #endif
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3132 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3133 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3134 buf->b_fname, TRUE, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3135 #endif
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3136 do_modelines(OPT_NOWIN);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3137 #if defined(FEAT_AUTOCMD)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3138 aucmd_restbuf(&aco);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3139 #else
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3140 curbuf = save_curbuf;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3141 curwin->w_buffer = curbuf;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3142 #endif
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3143 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3144 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3145 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3146 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3147
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3148 FreeWild(fcount, fnames);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3149
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3150 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3151 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3152 qi->qf_lists[qi->qf_curlist].qf_index = 1;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3153
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3154 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3155 qf_update_buffer(qi);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3156 #endif
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3157
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3158 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3159 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3160 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3161 if ((flags & VGR_NOJUMP) == 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3162 qf_jump(qi, 0, 0, eap->forceit);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3163 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3164 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3165 EMSG2(_(e_nomatch2), s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3166
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3167 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3168 if (au_name != NULL)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3169 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3170 curbuf->b_fname, TRUE, curbuf);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3171 #endif
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3172
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3173 theend:
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3174 vim_free(regmatch.regprog);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3175 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3176
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3177 /*
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3178 * Skip over the pattern argument of ":vimgrep /pat/[g][j]".
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3179 * Put the start of the pattern in "*s", unless "s" is NULL.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3180 * If "flags" is not NULL put the flags in it: VGR_GLOBAL, VGR_NOJUMP.
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3181 * If "s" is not NULL terminate the pattern with a NUL.
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3182 * Return a pointer to the char just past the pattern plus flags.
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3183 */
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3184 char_u *
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3185 skip_vimgrep_pat(p, s, flags)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3186 char_u *p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3187 char_u **s;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3188 int *flags;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3189 {
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3190 int c;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3191
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3192 if (vim_isIDc(*p))
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3193 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3194 /* ":vimgrep pattern fname" */
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3195 if (s != NULL)
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3196 *s = p;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3197 p = skiptowhite(p);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3198 if (s != NULL && *p != NUL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3199 *p++ = NUL;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3200 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3201 else
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3202 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3203 /* ":vimgrep /pattern/[g][j] fname" */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3204 if (s != NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3205 *s = p + 1;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3206 c = *p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3207 p = skip_regexp(p + 1, c, TRUE, NULL);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3208 if (*p != c)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3209 return NULL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3210
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3211 /* Truncate the pattern. */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3212 if (s != NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3213 *p = NUL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3214 ++p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3215
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3216 /* Find the flags */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3217 while (*p == 'g' || *p == 'j')
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3218 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3219 if (flags != NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3220 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3221 if (*p == 'g')
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3222 *flags |= VGR_GLOBAL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3223 else
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3224 *flags |= VGR_NOJUMP;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3225 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3226 ++p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3227 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3228 }
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3229 return p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3230 }
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3231
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3232 /*
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3233 * Load file "fname" into a dummy buffer and return the buffer pointer.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3234 * Returns NULL if it fails.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3235 * Must call unload_dummy_buffer() or wipe_dummy_buffer() later!
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3236 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3237 static buf_T *
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3238 load_dummy_buffer(fname)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3239 char_u *fname;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3240 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3241 buf_T *newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3242 int failed = TRUE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3243 #ifdef FEAT_AUTOCMD
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3244 aco_save_T aco;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3245 #else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3246 buf_T *old_curbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3247 #endif
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3248
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3249 /* Allocate a buffer without putting it in the buffer list. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3250 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3251 if (newbuf == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3252 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3253
177
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
3254 /* Init the options. */
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
3255 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
3256
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3257 #ifdef FEAT_AUTOCMD
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3258 /* set curwin/curbuf to buf and save a few things */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3259 aucmd_prepbuf(&aco, newbuf);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3260 #else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3261 curbuf = newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3262 curwin->w_buffer = newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3263 #endif
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3264
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3265 /* Need to set the filename for autocommands. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3266 (void)setfname(curbuf, fname, NULL, FALSE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3267
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3268 if (ml_open(curbuf) == OK)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3269 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3270 /* Create swap file now to avoid the ATTENTION message. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3271 check_need_swap(TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3272
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3273 /* Remove the "dummy" flag, otherwise autocommands may not
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3274 * work. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3275 curbuf->b_flags &= ~BF_DUMMY;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3276
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3277 if (readfile(fname, NULL,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3278 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3279 NULL, READ_NEW | READ_DUMMY) == OK
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3280 && !(curbuf->b_flags & BF_NEW))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3281 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3282 failed = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3283 if (curbuf != newbuf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3284 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3285 /* Bloody autocommands changed the buffer! */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3286 if (buf_valid(newbuf))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3287 wipe_buffer(newbuf, FALSE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3288 newbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3289 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3290 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3291 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3292
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3293 #ifdef FEAT_AUTOCMD
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3294 /* restore curwin/curbuf and a few other things */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3295 aucmd_restbuf(&aco);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3296 #else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3297 curbuf = old_curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3298 curwin->w_buffer = old_curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3299 #endif
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3300
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3301 if (!buf_valid(newbuf))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3302 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3303 if (failed)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3304 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3305 wipe_dummy_buffer(newbuf);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3306 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3307 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3308 return newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3309 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3310
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3311 /*
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3312 * Wipe out the dummy buffer that load_dummy_buffer() created.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3313 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3314 static void
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3315 wipe_dummy_buffer(buf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3316 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3317 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3318 if (curbuf != buf) /* safety check */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3319 wipe_buffer(buf, FALSE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3320 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3321
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3322 /*
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3323 * Unload the dummy buffer that load_dummy_buffer() created.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3324 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3325 static void
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3326 unload_dummy_buffer(buf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3327 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3328 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3329 if (curbuf != buf) /* safety check */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3330 close_buffer(NULL, buf, DOBUF_UNLOAD);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3331 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3332
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3333 #if defined(FEAT_EVAL) || defined(PROTO)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3334 /*
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3335 * Add each quickfix error to list "list" as a dictionary.
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3336 */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3337 int
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3338 get_errorlist(wp, list)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3339 win_T *wp;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3340 list_T *list;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3341 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3342 qf_info_T *qi = &ql_info;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3343 dict_T *dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3344 char_u buf[2];
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3345 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3346 int i;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3347
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3348 if (wp != NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3349 {
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3350 qi = GET_LOC_LIST(wp);
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3351 if (qi == NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3352 return FAIL;
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3353 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3354
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3355 if (qi->qf_curlist >= qi->qf_listcount
712
2e887dfa8917 updated for version 7.0214
vimboss
parents: 694
diff changeset
3356 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3357 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3358
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3359 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3360 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3361 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3362 if ((dict = dict_alloc()) == NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3363 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3364 if (list_append_dict(list, dict) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3365 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3366
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3367 buf[0] = qfp->qf_type;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3368 buf[1] = NUL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3369 if ( dict_add_nr_str(dict, "bufnr", (long)qfp->qf_fnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3370 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3371 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3372 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3373 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3374 || dict_add_nr_str(dict, "pattern", 0L, qfp->qf_pattern) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3375 || dict_add_nr_str(dict, "text", 0L, qfp->qf_text) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3376 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3377 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3378 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3379
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3380 qfp = qfp->qf_next;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3381 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3382 return OK;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3383 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3384
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3385 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3386 * Populate the quickfix list with the items supplied in the list
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3387 * of dictionaries.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3388 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3389 int
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3390 set_errorlist(wp, list, action)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3391 win_T *wp;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3392 list_T *list;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
3393 int action;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3394 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3395 listitem_T *li;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3396 dict_T *d;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3397 char_u *filename, *pattern, *text, *type;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3398 long lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3399 int col, nr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3400 int vcol;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3401 qfline_T *prevp = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3402 int valid, status;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3403 int retval = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3404 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3405
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3406 if (wp != NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3407 {
648
9032e4668296 updated for version 7.0189
vimboss
parents: 647
diff changeset
3408 qi = ll_get_or_alloc_list(wp);
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3409 if (qi == NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3410 return FAIL;
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3411 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3412
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3413 if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
3414 /* make place for a new list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3415 qf_new_list(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3416 else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
3417 /* Adding to existing list, find last entry. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3418 for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
3419 prevp->qf_next != prevp; prevp = prevp->qf_next)
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
3420 ;
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
3421 else if (action == 'r')
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3422 qf_free(qi, qi->qf_curlist);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3423
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3424 for (li = list->lv_first; li != NULL; li = li->li_next)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3425 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3426 if (li->li_tv.v_type != VAR_DICT)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3427 continue; /* Skip non-dict items */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3428
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3429 d = li->li_tv.vval.v_dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3430 if (d == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3431 continue;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3432
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3433 filename = get_dict_string(d, (char_u *)"filename", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3434 lnum = get_dict_number(d, (char_u *)"lnum");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3435 col = get_dict_number(d, (char_u *)"col");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3436 vcol = get_dict_number(d, (char_u *)"vcol");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3437 nr = get_dict_number(d, (char_u *)"nr");
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3438 type = get_dict_string(d, (char_u *)"type", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3439 pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3440 text = get_dict_string(d, (char_u *)"text", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3441 if (text == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3442 text = vim_strsave((char_u *)"");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3443
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3444 valid = TRUE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3445 if (filename == NULL || (lnum == 0 && pattern == NULL))
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3446 valid = FALSE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3447
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3448 status = qf_add_entry(qi, &prevp,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3449 NULL, /* dir */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3450 filename,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3451 text,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3452 lnum,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3453 col,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3454 vcol, /* vis_col */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3455 pattern, /* search pattern */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3456 nr,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3457 type == NULL ? NUL : *type,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3458 valid);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3459
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3460 vim_free(filename);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3461 vim_free(pattern);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3462 vim_free(text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3463 vim_free(type);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3464
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3465 if (status == FAIL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3466 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3467 retval = FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3468 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3469 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3470 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3471
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3472 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3473 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3474 qi->qf_lists[qi->qf_curlist].qf_index = 1;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3475
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3476 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3477 qf_update_buffer(qi);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3478 #endif
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3479
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3480 return retval;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3481 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3482 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3483
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3484 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3485 * ":[range]cbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3486 * ":[range]caddbuffer [bufnr]" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3487 * ":[range]lbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3488 * ":[range]laddbuffer [bufnr]" command.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3489 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3490 void
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3491 ex_cbuffer(eap)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3492 exarg_T *eap;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3493 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3494 buf_T *buf = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3495 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3496
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3497 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_laddbuffer)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3498 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3499 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3500 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3501 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3502 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3503
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3504 if (*eap->arg == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3505 buf = curbuf;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3506 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3507 buf = buflist_findnr(atoi((char *)eap->arg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3508 if (buf == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3509 EMSG(_(e_invarg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3510 else if (buf->b_ml.ml_mfp == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3511 EMSG(_("E681: Buffer is not loaded"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3512 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3513 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3514 if (eap->addr_count == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3515 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3516 eap->line1 = 1;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3517 eap->line2 = buf->b_ml.ml_line_count;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3518 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3519 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3520 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3521 EMSG(_(e_invrange));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3522 else
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3523 {
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3524 int buffer_cmd = (eap->cmdidx == CMD_cbuffer
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3525 || eap->cmdidx == CMD_lbuffer);
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3526
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3527 if (qf_init_ext(qi, NULL, buf, NULL, p_efm, buffer_cmd,
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3528 eap->line1, eap->line2) > 0
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3529 && buffer_cmd)
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3530 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3531 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3532 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3533 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3534
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3535 #if defined(FEAT_EVAL) || defined(PROTO)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3536 /*
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3537 * ":cexpr {expr}" and ":caddexpr {expr}" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3538 * ":lexpr {expr}" and ":laddexpr {expr}" command.
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3539 */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3540 void
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3541 ex_cexpr(eap)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3542 exarg_T *eap;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3543 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3544 typval_T *tv;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3545 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3546
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3547 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_laddexpr)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3548 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3549 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3550 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3551 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3552 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3553
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3554 /* Evaluate the expression. When the result is a string or a list we can
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3555 * use it to fill the errorlist. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3556 tv = eval_expr(eap->arg, NULL);
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3557 if (tv != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3558 {
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3559 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3560 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3561 {
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3562 int expr_cmd = (eap->cmdidx == CMD_cexpr
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3563 || eap->cmdidx == CMD_lexpr);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3564 if (qf_init_ext(qi, NULL, NULL, tv, p_efm, expr_cmd,
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3565 (linenr_T)0, (linenr_T)0) > 0
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3566 && expr_cmd)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3567 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3568 }
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3569 else
626
732c7ae5743e updated for version 7.0180
vimboss
parents: 625
diff changeset
3570 EMSG(_("E777: String or List expected"));
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3571 free_tv(tv);
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
3572 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3573 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3574 #endif
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3575
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3576 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3577 * ":helpgrep {pattern}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3578 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3579 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3580 ex_helpgrep(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3583 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3584 char_u *save_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3585 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3586 int fcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3587 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3588 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3589 int fi;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3590 qfline_T *prevp = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3591 long lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3592 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3593 char_u *lang;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3594 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3595 qf_info_T *qi = &ql_info;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3596 int new_qi = FALSE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3597 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3599 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3600 save_cpo = p_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3601 p_cpo = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3602
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3603 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3604 /* Check for a specified language */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3605 lang = check_help_lang(eap->arg);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3606 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3607
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3608 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3609 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3610 /* Find an existing help window */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3611 FOR_ALL_WINDOWS(wp)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3612 if (wp->w_buffer != NULL && wp->w_buffer->b_help)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3613 break;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3614
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3615 if (wp == NULL) /* Help window not found */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3616 qi = NULL;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3617 else
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3618 qi = wp->w_llist;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3619
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3620 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3621 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3622 /* Allocate a new location list for help text matches */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3623 if ((qi = ll_new_list()) == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3624 return;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3625 new_qi = TRUE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3626 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3627 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3628
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3629 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3630 regmatch.rm_ic = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3631 if (regmatch.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 /* create a new quickfix list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3634 qf_new_list(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3636 /* Go through all directories in 'runtimepath' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3637 p = p_rtp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638 while (*p != NUL && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3640 copy_option_part(&p, NameBuff, MAXPATHL, ",");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3641
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3643 add_pathsep(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3644 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3645 if (gen_expand_wildcards(1, &NameBuff, &fcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3646 &fnames, EW_FILE|EW_SILENT) == OK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 && fcount > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3648 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3649 for (fi = 0; fi < fcount && !got_int; ++fi)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3650 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3651 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3652 /* Skip files for a different language. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3653 if (lang != NULL
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3654 && STRNICMP(lang, fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3655 + STRLEN(fnames[fi]) - 3, 2) != 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3656 && !(STRNICMP(lang, "en", 2) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3657 && STRNICMP("txt", fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3658 + STRLEN(fnames[fi]) - 3, 3) == 0))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3659 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3660 #endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 514
diff changeset
3661 fd = mch_fopen((char *)fnames[fi], "r");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3662 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3663 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3664 lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3665 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3666 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3667 if (vim_regexec(&regmatch, IObuff, (colnr_T)0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3668 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3669 int l = STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3670
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3671 /* remove trailing CR, LF, spaces, etc. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3672 while (l > 0 && IObuff[l - 1] <= ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3673 IObuff[--l] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3674
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3675 if (qf_add_entry(qi, &prevp,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3676 NULL, /* dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3677 fnames[fi],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3678 IObuff,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3679 lnum,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3680 (int)(regmatch.startp[0] - IObuff)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3681 + 1, /* col */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3682 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3683 NULL, /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3684 0, /* nr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3685 1, /* type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3686 TRUE /* valid */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3687 ) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3689 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3690 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3693 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3699 FreeWild(fcount, fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3702 vim_free(regmatch.regprog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3703
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3704 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3705 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3706 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3707 qi->qf_lists[qi->qf_curlist].qf_index = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3710 p_cpo = save_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3712 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3713 qf_update_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3714 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3715
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3716 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3717 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3718 qf_jump(qi, 0, 0, FALSE);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3719 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3720 EMSG2(_(e_nomatch2), eap->arg);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3721
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3722 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3723 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3724 /* If the help window is not opened or if it already points to the
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3725 * correct location list, then free the new location list. */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3726 if (!curwin->w_buffer->b_help || curwin->w_llist == qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3727 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3728 if (new_qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3729 ll_free_all(&qi);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3730 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3731 else if (curwin->w_llist == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3732 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3733 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3736 #endif /* FEAT_QUICKFIX */