Mercurial > vim
annotate src/quickfix.c @ 9421:ce8891614a89
Added tag v7.4.1991 for changeset 9f78f3f0c81f8d4d33020ce615f4918dde8e3132
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 07 Jul 2016 14:30:06 +0200 |
parents | e08e8b00fe48 |
children | abb72f0b9e06 |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * quickfix.c: functions for quickfix mode, using a file with error messages | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 #if defined(FEAT_QUICKFIX) || defined(PROTO) | |
17 | |
18 struct dir_stack_T | |
19 { | |
20 struct dir_stack_T *next; | |
21 char_u *dirname; | |
22 }; | |
23 | |
24 /* | |
230 | 25 * For each error the next struct is allocated and linked in a list. |
7 | 26 */ |
230 | 27 typedef struct qfline_S qfline_T; |
28 struct qfline_S | |
7 | 29 { |
230 | 30 qfline_T *qf_next; /* pointer to next error in the list */ |
31 qfline_T *qf_prev; /* pointer to previous error in the list */ | |
32 linenr_T qf_lnum; /* line number where the error occurred */ | |
33 int qf_fnum; /* file number for the line */ | |
34 int qf_col; /* column where the error occurred */ | |
35 int qf_nr; /* error number */ | |
36 char_u *qf_pattern; /* search pattern for the error */ | |
37 char_u *qf_text; /* description of the error */ | |
38 char_u qf_viscol; /* set to TRUE if qf_col is screen column */ | |
39 char_u qf_cleared; /* set to TRUE if line has been deleted */ | |
40 char_u qf_type; /* type of the error (mostly 'E'); 1 for | |
7 | 41 :helpgrep */ |
230 | 42 char_u qf_valid; /* valid error message detected */ |
7 | 43 }; |
44 | |
45 /* | |
46 * There is a stack of error lists. | |
47 */ | |
48 #define LISTCOUNT 10 | |
49 | |
644 | 50 typedef struct qf_list_S |
7 | 51 { |
230 | 52 qfline_T *qf_start; /* pointer to the first error */ |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
53 qfline_T *qf_last; /* pointer to the last error */ |
230 | 54 qfline_T *qf_ptr; /* pointer to the current error */ |
55 int qf_count; /* number of errors (0 means no error list) */ | |
56 int qf_index; /* current index in the error list */ | |
57 int qf_nonevalid; /* TRUE if not a single valid entry found */ | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
58 char_u *qf_title; /* title derived from the command that created |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
59 * the error list */ |
644 | 60 } qf_list_T; |
61 | |
62 struct qf_info_S | |
63 { | |
64 /* | |
65 * Count of references to this list. Used only for location lists. | |
66 * When a location list window reference this list, qf_refcount | |
67 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount | |
68 * reaches 0, the list is freed. | |
69 */ | |
70 int qf_refcount; | |
71 int qf_listcount; /* current number of lists */ | |
72 int qf_curlist; /* current error list */ | |
73 qf_list_T qf_lists[LISTCOUNT]; | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
74 |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
75 int qf_dir_curlist; /* error list for qf_dir_stack */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
76 struct dir_stack_T *qf_dir_stack; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
77 char_u *qf_directory; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
78 struct dir_stack_T *qf_file_stack; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
79 char_u *qf_currfile; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
80 int qf_multiline; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
81 int qf_multiignore; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
82 int qf_multiscan; |
644 | 83 }; |
84 | |
85 static qf_info_T ql_info; /* global quickfix list */ | |
7 | 86 |
230 | 87 #define FMT_PATTERNS 10 /* maximum number of % recognized */ |
7 | 88 |
89 /* | |
90 * Structure used to hold the info of one part of 'errorformat' | |
91 */ | |
789 | 92 typedef struct efm_S efm_T; |
93 struct efm_S | |
7 | 94 { |
95 regprog_T *prog; /* pre-formatted part of 'errorformat' */ | |
789 | 96 efm_T *next; /* pointer to next (NULL if last) */ |
7 | 97 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */ |
98 char_u prefix; /* prefix of this format line: */ | |
99 /* 'D' enter directory */ | |
100 /* 'X' leave directory */ | |
101 /* 'A' start of multi-line message */ | |
102 /* 'E' error message */ | |
103 /* 'W' warning message */ | |
104 /* 'I' informational message */ | |
105 /* 'C' continuation line */ | |
106 /* 'Z' end of multi-line message */ | |
107 /* 'G' general, unspecific message */ | |
108 /* 'P' push file (partial) message */ | |
109 /* 'Q' pop/quit file (partial) message */ | |
110 /* 'O' overread (partial) message */ | |
111 char_u flags; /* additional flags given in prefix */ | |
112 /* '-' do not include this line */ | |
625 | 113 /* '+' include whole line in message */ |
789 | 114 int conthere; /* %> used */ |
7 | 115 }; |
116 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
117 static int qf_init_ext(qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
118 static void qf_store_title(qf_info_T *qi, char_u *title); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
119 static void qf_new_list(qf_info_T *qi, char_u *qf_title); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
120 static void ll_free_all(qf_info_T **pqi); |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
121 static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
122 static qf_info_T *ll_new_list(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
123 static void qf_msg(qf_info_T *qi); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
124 static void qf_free(qf_info_T *qi, int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
125 static char_u *qf_types(int, int); |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
126 static int qf_get_fnum(qf_info_T *qi, char_u *, char_u *); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
127 static char_u *qf_push_dir(char_u *, struct dir_stack_T **, int is_file_stack); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
128 static char_u *qf_pop_dir(struct dir_stack_T **); |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
129 static char_u *qf_guess_filepath(qf_info_T *qi, char_u *); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
130 static void qf_fmt_text(char_u *text, char_u *buf, int bufsize); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
131 static void qf_clean_dir_stack(struct dir_stack_T **); |
7 | 132 #ifdef FEAT_WINDOWS |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
133 static int qf_win_pos_update(qf_info_T *qi, int old_qf_index); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
134 static int is_qf_win(win_T *win, qf_info_T *qi); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
135 static win_T *qf_find_win(qf_info_T *qi); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
136 static buf_T *qf_find_buf(qf_info_T *qi); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
137 static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
138 static void qf_set_title_var(qf_info_T *qi); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
139 static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last); |
7 | 140 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
141 static char_u *get_mef_name(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
142 static void restore_start_dir(char_u *dirname_start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
143 static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *resulting_dir); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
144 static void wipe_dummy_buffer(buf_T *buf, char_u *dirname_start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
145 static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7710
diff
changeset
|
146 static qf_info_T *ll_get_or_alloc_list(win_T *); |
7 | 147 |
644 | 148 /* Quickfix window check helper macro */ |
149 #define IS_QF_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL) | |
150 /* Location list window check helper macro */ | |
151 #define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL) | |
152 /* | |
153 * Return location list for window 'wp' | |
154 * For location list window, return the referenced location list | |
155 */ | |
156 #define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist) | |
157 | |
7 | 158 /* |
41 | 159 * Read the errorfile "efile" into memory, line by line, building the error |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
160 * list. Set the error list's title to qf_title. |
7 | 161 * Return -1 for error, number of errors for success. |
162 */ | |
163 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
164 qf_init( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
165 win_T *wp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
166 char_u *efile, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
167 char_u *errorformat, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
168 int newlist, /* TRUE: start a new error list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
169 char_u *qf_title) |
7 | 170 { |
644 | 171 qf_info_T *qi = &ql_info; |
172 | |
173 if (wp != NULL) | |
665 | 174 { |
175 qi = ll_get_or_alloc_list(wp); | |
176 if (qi == NULL) | |
177 return FAIL; | |
178 } | |
644 | 179 |
180 return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist, | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
181 (linenr_T)0, (linenr_T)0, |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
182 qf_title); |
41 | 183 } |
184 | |
185 /* | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
186 * Maximum number of bytes allowed per line while reading a errorfile. |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
187 */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
188 #define LINE_MAXLEN 4096 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
189 |
9114
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
190 static char_u * |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
191 qf_grow_linebuf(char_u **growbuf, int *growbufsiz, int newsz, int *allocsz) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
192 { |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
193 /* |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
194 * If the line exceeds LINE_MAXLEN exclude the last |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
195 * byte since it's not a NL character. |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
196 */ |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
197 *allocsz = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz; |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
198 if (*growbuf == NULL) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
199 { |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
200 *growbuf = alloc(*allocsz + 1); |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
201 if (*growbuf == NULL) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
202 return NULL; |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
203 *growbufsiz = *allocsz; |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
204 } |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
205 else if (*allocsz > *growbufsiz) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
206 { |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
207 *growbuf = vim_realloc(*growbuf, *allocsz + 1); |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
208 if (*growbuf == NULL) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
209 return NULL; |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
210 *growbufsiz = *allocsz; |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
211 } |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
212 return *growbuf; |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
213 } |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
214 |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
215 static struct fmtpattern |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
216 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
217 char_u convchar; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
218 char *pattern; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
219 } fmt_pat[FMT_PATTERNS] = |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
220 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
221 {'f', ".\\+"}, /* only used when at end */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
222 {'n', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
223 {'l', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
224 {'c', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
225 {'t', "."}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
226 {'m', ".\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
227 {'r', ".*"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
228 {'p', "[- .]*"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
229 {'v', "\\d\\+"}, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
230 {'s', ".\\+"} |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
231 }; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
232 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
233 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
234 * Converts a 'errorformat' string to regular expression pattern |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
235 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
236 static int |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
237 efm_to_regpat( |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
238 char_u *efm, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
239 int len, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
240 efm_T *fmt_ptr, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
241 char_u *regpat, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
242 char_u *errmsg) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
243 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
244 char_u *ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
245 char_u *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
246 char_u *srcptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
247 int round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
248 int idx = 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
249 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
250 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
251 * Build regexp pattern from current 'errorformat' option |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
252 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
253 ptr = regpat; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
254 *ptr++ = '^'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
255 round = 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
256 for (efmp = efm; efmp < efm + len; ++efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
257 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
258 if (*efmp == '%') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
259 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
260 ++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
261 for (idx = 0; idx < FMT_PATTERNS; ++idx) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
262 if (fmt_pat[idx].convchar == *efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
263 break; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
264 if (idx < FMT_PATTERNS) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
265 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
266 if (fmt_ptr->addr[idx]) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
267 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
268 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
269 _("E372: Too many %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
270 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
271 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
272 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
273 if ((idx |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
274 && idx < 6 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
275 && vim_strchr((char_u *)"DXOPQ", |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
276 fmt_ptr->prefix) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
277 || (idx == 6 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
278 && vim_strchr((char_u *)"OPQ", |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
279 fmt_ptr->prefix) == NULL)) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
280 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
281 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
282 _("E373: Unexpected %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
283 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
284 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
285 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
286 fmt_ptr->addr[idx] = (char_u)++round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
287 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
288 *ptr++ = '('; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
289 #ifdef BACKSLASH_IN_FILENAME |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
290 if (*efmp == 'f') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
291 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
292 /* Also match "c:" in the file name, even when |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
293 * checking for a colon next: "%f:". |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
294 * "\%(\a:\)\=" */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
295 STRCPY(ptr, "\\%(\\a:\\)\\="); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
296 ptr += 10; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
297 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
298 #endif |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
299 if (*efmp == 'f' && efmp[1] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
300 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
301 if (efmp[1] != '\\' && efmp[1] != '%') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
302 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
303 /* A file name may contain spaces, but this isn't |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
304 * in "\f". For "%f:%l:%m" there may be a ":" in |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
305 * the file name. Use ".\{-1,}x" instead (x is |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
306 * the next character), the requirement that :999: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
307 * follows should work. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
308 STRCPY(ptr, ".\\{-1,}"); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
309 ptr += 7; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
310 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
311 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
312 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
313 /* File name followed by '\\' or '%': include as |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
314 * many file name chars as possible. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
315 STRCPY(ptr, "\\f\\+"); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
316 ptr += 4; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
317 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
318 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
319 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
320 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
321 srcptr = (char_u *)fmt_pat[idx].pattern; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
322 while ((*ptr = *srcptr++) != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
323 ++ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
324 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
325 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
326 *ptr++ = ')'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
327 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
328 else if (*efmp == '*') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
329 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
330 if (*++efmp == '[' || *efmp == '\\') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
331 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
332 if ((*ptr++ = *efmp) == '[') /* %*[^a-z0-9] etc. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
333 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
334 if (efmp[1] == '^') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
335 *ptr++ = *++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
336 if (efmp < efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
337 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
338 *ptr++ = *++efmp; /* could be ']' */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
339 while (efmp < efm + len |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
340 && (*ptr++ = *++efmp) != ']') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
341 /* skip */; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
342 if (efmp == efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
343 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
344 EMSG(_("E374: Missing ] in format string")); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
345 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
346 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
347 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
348 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
349 else if (efmp < efm + len) /* %*\D, %*\s etc. */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
350 *ptr++ = *++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
351 *ptr++ = '\\'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
352 *ptr++ = '+'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
353 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
354 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
355 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
356 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
357 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
358 _("E375: Unsupported %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
359 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
360 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
361 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
362 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
363 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
364 *ptr++ = *efmp; /* regexp magic characters */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
365 else if (*efmp == '#') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
366 *ptr++ = '*'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
367 else if (*efmp == '>') |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
368 fmt_ptr->conthere = TRUE; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
369 else if (efmp == efm + 1) /* analyse prefix */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
370 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
371 if (vim_strchr((char_u *)"+-", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
372 fmt_ptr->flags = *efmp++; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
373 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
374 fmt_ptr->prefix = *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
375 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
376 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
377 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
378 _("E376: Invalid %%%c in format string prefix"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
379 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
380 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
381 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
382 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
383 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
384 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
385 sprintf((char *)errmsg, |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
386 _("E377: Invalid %%%c in format string"), *efmp); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
387 EMSG(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
388 return -1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
389 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
390 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
391 else /* copy normal character */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
392 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
393 if (*efmp == '\\' && efmp + 1 < efm + len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
394 ++efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
395 else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
396 *ptr++ = '\\'; /* escape regexp atoms */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
397 if (*efmp) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
398 *ptr++ = *efmp; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
399 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
400 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
401 *ptr++ = '$'; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
402 *ptr = NUL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
403 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
404 return 0; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
405 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
406 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
407 static void |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
408 free_efm_list(efm_T **efm_first) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
409 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
410 efm_T *efm_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
411 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
412 for (efm_ptr = *efm_first; efm_ptr != NULL; efm_ptr = *efm_first) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
413 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
414 *efm_first = efm_ptr->next; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
415 vim_regfree(efm_ptr->prog); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
416 vim_free(efm_ptr); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
417 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
418 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
419 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
420 /* Parse 'errorformat' option */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
421 static efm_T * |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
422 parse_efm_option(char_u *efm) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
423 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
424 char_u *errmsg = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
425 int errmsglen; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
426 efm_T *fmt_ptr = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
427 efm_T *fmt_first = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
428 efm_T *fmt_last = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
429 char_u *fmtstr = NULL; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
430 int len; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
431 int i; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
432 int round; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
433 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
434 errmsglen = CMDBUFFSIZE + 1; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
435 errmsg = alloc_id(errmsglen, aid_qf_errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
436 if (errmsg == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
437 goto parse_efm_end; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
438 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
439 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
440 * Get some space to modify the format string into. |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
441 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
442 i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
443 for (round = FMT_PATTERNS; round > 0; ) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
444 i += (int)STRLEN(fmt_pat[--round].pattern); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
445 #ifdef COLON_IN_FILENAME |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
446 i += 12; /* "%f" can become twelve chars longer */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
447 #else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
448 i += 2; /* "%f" can become two chars longer */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
449 #endif |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
450 if ((fmtstr = alloc(i)) == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
451 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
452 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
453 while (efm[0] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
454 { |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
455 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
456 * Allocate a new eformat structure and put it at the end of the list |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
457 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
458 fmt_ptr = (efm_T *)alloc_clear((unsigned)sizeof(efm_T)); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
459 if (fmt_ptr == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
460 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
461 if (fmt_first == NULL) /* first one */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
462 fmt_first = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
463 else |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
464 fmt_last->next = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
465 fmt_last = fmt_ptr; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
466 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
467 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
468 * Isolate one part in the 'errorformat' option |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
469 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
470 for (len = 0; efm[len] != NUL && efm[len] != ','; ++len) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
471 if (efm[len] == '\\' && efm[len + 1] != NUL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
472 ++len; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
473 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
474 if (efm_to_regpat(efm, len, fmt_ptr, fmtstr, errmsg) == -1) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
475 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
476 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
477 goto parse_efm_error; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
478 /* |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
479 * Advance to next part |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
480 */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
481 efm = skip_to_option_part(efm + len); /* skip comma and spaces */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
482 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
483 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
484 if (fmt_first == NULL) /* nothing found */ |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
485 EMSG(_("E378: 'errorformat' contains no pattern")); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
486 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
487 goto parse_efm_end; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
488 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
489 parse_efm_error: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
490 free_efm_list(&fmt_first); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
491 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
492 parse_efm_end: |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
493 vim_free(fmtstr); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
494 vim_free(errmsg); |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
495 |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
496 return fmt_first; |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
497 } |
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
498 |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
499 /* |
41 | 500 * Read the errorfile "efile" into memory, line by line, building the error |
501 * list. | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
502 * Alternative: when "efile" is NULL read errors from buffer "buf". |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
503 * Alternative: when "tv" is not NULL get errors from the string or list. |
41 | 504 * Always use 'errorformat' from "buf" if there is a local value. |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
505 * Then "lnumfirst" and "lnumlast" specify the range of lines to use. |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
506 * Set the title of the list to "qf_title". |
41 | 507 * Return -1 for error, number of errors for success. |
508 */ | |
509 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
510 qf_init_ext( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
511 qf_info_T *qi, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
512 char_u *efile, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
513 buf_T *buf, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
514 typval_T *tv, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
515 char_u *errorformat, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
516 int newlist, /* TRUE: start a new error list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
517 linenr_T lnumfirst, /* first line number to use */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
518 linenr_T lnumlast, /* last line number to use */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
519 char_u *qf_title) |
41 | 520 { |
7 | 521 char_u *namebuf; |
522 char_u *errmsg; | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
523 int errmsglen; |
230 | 524 char_u *pattern; |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
525 char_u *growbuf = NULL; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
526 int growbuflen; |
9060
616793d0412b
commit https://github.com/vim/vim/commit/9a3b3311d26c990208150255ad65472bb4eefaa4
Christian Brabandt <cb@256bit.org>
parents:
9056
diff
changeset
|
527 int growbufsiz = 0; |
616793d0412b
commit https://github.com/vim/vim/commit/9a3b3311d26c990208150255ad65472bb4eefaa4
Christian Brabandt <cb@256bit.org>
parents:
9056
diff
changeset
|
528 char_u *linebuf = NULL; |
616793d0412b
commit https://github.com/vim/vim/commit/9a3b3311d26c990208150255ad65472bb4eefaa4
Christian Brabandt <cb@256bit.org>
parents:
9056
diff
changeset
|
529 int linelen = 0; |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
530 int discard; |
7 | 531 int col = 0; |
170 | 532 char_u use_viscol = FALSE; |
7 | 533 int type = 0; |
534 int valid; | |
41 | 535 linenr_T buflnum = lnumfirst; |
7 | 536 long lnum = 0L; |
537 int enr = 0; | |
41 | 538 FILE *fd = NULL; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
539 #ifdef FEAT_WINDOWS |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
540 qfline_T *old_last = NULL; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
541 #endif |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
542 static efm_T *fmt_first = NULL; |
789 | 543 efm_T *fmt_ptr; |
544 efm_T *fmt_start = NULL; | |
7 | 545 char_u *efm; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
546 static char_u *last_efm = NULL; |
7 | 547 char_u *ptr; |
548 int len; | |
549 int i; | |
550 int idx = 0; | |
551 int retval = -1; /* default: return error flag */ | |
552 char_u *tail = NULL; | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
553 char_u *p_buf = NULL; |
446 | 554 char_u *p_str = NULL; |
555 listitem_T *p_li = NULL; | |
7 | 556 regmatch_T regmatch; |
557 | |
7558
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
558 namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf); |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
559 errmsglen = CMDBUFFSIZE + 1; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
560 errmsg = alloc_id(errmsglen, aid_qf_errmsg); |
7558
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
561 pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern); |
230 | 562 if (namebuf == NULL || errmsg == NULL || pattern == NULL) |
7 | 563 goto qf_init_end; |
564 | |
41 | 565 if (efile != NULL && (fd = mch_fopen((char *)efile, "r")) == NULL) |
7 | 566 { |
567 EMSG2(_(e_openerrf), efile); | |
568 goto qf_init_end; | |
569 } | |
570 | |
644 | 571 if (newlist || qi->qf_curlist == qi->qf_listcount) |
7 | 572 /* make place for a new list */ |
3965 | 573 qf_new_list(qi, qf_title); |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
574 #ifdef FEAT_WINDOWS |
644 | 575 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
576 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
577 /* Adding to existing list, use last entry. */ |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
578 old_last = qi->qf_lists[qi->qf_curlist].qf_last; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
579 } |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
580 #endif |
7 | 581 |
582 /* | |
583 * Each part of the format string is copied and modified from errorformat to | |
584 * regex prog. Only a few % characters are allowed. | |
585 */ | |
586 /* Use the local value of 'errorformat' if it's set. */ | |
446 | 587 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) |
41 | 588 efm = buf->b_p_efm; |
7 | 589 else |
590 efm = errorformat; | |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
591 |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
592 /* |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
593 * If we are not adding or adding to another list: clear the state. |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
594 */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
595 if (newlist || qi->qf_curlist != qi->qf_dir_curlist) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
596 { |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
597 qi->qf_dir_curlist = qi->qf_curlist; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
598 qf_clean_dir_stack(&qi->qf_dir_stack); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
599 qi->qf_directory = NULL; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
600 qf_clean_dir_stack(&qi->qf_file_stack); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
601 qi->qf_currfile = NULL; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
602 qi->qf_multiline = FALSE; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
603 qi->qf_multiignore = FALSE; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
604 qi->qf_multiscan = FALSE; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
605 } |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
606 |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
607 /* |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
608 * If the errorformat didn't change between calls, then reuse the |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
609 * previously parsed values. |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
610 */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
611 if (last_efm == NULL || (STRCMP(last_efm, efm) != 0)) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
612 { |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
613 /* free the previously parsed data */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
614 vim_free(last_efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
615 last_efm = NULL; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
616 free_efm_list(&fmt_first); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
617 |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
618 /* parse the current 'efm' */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
619 fmt_first = parse_efm_option(efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
620 if (fmt_first != NULL) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
621 last_efm = vim_strsave(efm); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
622 } |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
623 |
9365
3830a92c12bf
commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents:
9334
diff
changeset
|
624 if (fmt_first == NULL) /* nothing found */ |
7 | 625 goto error2; |
626 | |
627 /* | |
628 * got_int is reset here, because it was probably set when killing the | |
629 * ":make" command, but we still want to read the errorfile then. | |
630 */ | |
631 got_int = FALSE; | |
632 | |
633 /* Always ignore case when looking for a matching error. */ | |
634 regmatch.rm_ic = TRUE; | |
635 | |
446 | 636 if (tv != NULL) |
637 { | |
638 if (tv->v_type == VAR_STRING) | |
639 p_str = tv->vval.v_string; | |
640 else if (tv->v_type == VAR_LIST) | |
641 p_li = tv->vval.v_list->lv_first; | |
642 } | |
643 | |
7 | 644 /* |
645 * Read the lines in the error file one by one. | |
646 * Try to recognize one of the error formats in each line. | |
647 */ | |
41 | 648 while (!got_int) |
7 | 649 { |
41 | 650 /* Get the next line. */ |
651 if (fd == NULL) | |
652 { | |
446 | 653 if (tv != NULL) |
654 { | |
655 if (tv->v_type == VAR_STRING) | |
656 { | |
657 /* Get the next line from the supplied string */ | |
658 char_u *p; | |
659 | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
660 if (*p_str == NUL) /* Reached the end of the string */ |
446 | 661 break; |
662 | |
663 p = vim_strchr(p_str, '\n'); | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
664 if (p != NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
665 len = (int)(p - p_str) + 1; |
446 | 666 else |
835 | 667 len = (int)STRLEN(p_str); |
446 | 668 |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
669 if (len > IOSIZE - 2) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
670 { |
9114
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
671 linebuf = qf_grow_linebuf(&growbuf, &growbufsiz, len, |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
672 &linelen); |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
673 if (linebuf == NULL) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
674 goto qf_init_end; |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
675 } |
446 | 676 else |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
677 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
678 linebuf = IObuff; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
679 linelen = len; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
680 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
681 vim_strncpy(linebuf, p_str, linelen); |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
682 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
683 /* |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
684 * Increment using len in order to discard the rest of the |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
685 * line if it exceeds LINE_MAXLEN. |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
686 */ |
446 | 687 p_str += len; |
688 } | |
689 else if (tv->v_type == VAR_LIST) | |
690 { | |
691 /* Get the next line from the supplied list */ | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
692 while (p_li != NULL |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
693 && (p_li->li_tv.v_type != VAR_STRING |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
694 || p_li->li_tv.vval.v_string == NULL)) |
446 | 695 p_li = p_li->li_next; /* Skip non-string items */ |
696 | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
697 if (p_li == NULL) /* End of the list */ |
446 | 698 break; |
699 | |
835 | 700 len = (int)STRLEN(p_li->li_tv.vval.v_string); |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
701 if (len > IOSIZE - 2) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
702 { |
9114
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
703 linebuf = qf_grow_linebuf(&growbuf, &growbufsiz, len, |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
704 &linelen); |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
705 if (linebuf == NULL) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
706 goto qf_init_end; |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
707 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
708 else |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
709 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
710 linebuf = IObuff; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
711 linelen = len; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
712 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
713 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
714 vim_strncpy(linebuf, p_li->li_tv.vval.v_string, linelen); |
446 | 715 |
716 p_li = p_li->li_next; /* next item */ | |
717 } | |
718 } | |
719 else | |
720 { | |
721 /* Get the next line from the supplied buffer */ | |
722 if (buflnum > lnumlast) | |
723 break; | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
724 p_buf = ml_get_buf(buf, buflnum++, FALSE); |
9334
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
725 len = (int)STRLEN(p_buf); |
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
726 if (len > IOSIZE - 2) |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
727 { |
9114
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
728 linebuf = qf_grow_linebuf(&growbuf, &growbufsiz, len, |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
729 &linelen); |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
730 if (linebuf == NULL) |
f221aec7fcca
commit https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905
Christian Brabandt <cb@256bit.org>
parents:
9077
diff
changeset
|
731 goto qf_init_end; |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
732 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
733 else |
9334
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
734 { |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
735 linebuf = IObuff; |
9334
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
736 linelen = len; |
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
737 } |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
738 vim_strncpy(linebuf, p_buf, linelen); |
446 | 739 } |
41 | 740 } |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
741 else |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
742 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
743 if (fgets((char *)IObuff, IOSIZE, fd) == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
744 break; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
745 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
746 discard = FALSE; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
747 linelen = (int)STRLEN(IObuff); |
9197
847a709d04c1
commit https://github.com/vim/vim/commit/b37662a0fbb952838fca87aff4d26b596030b67b
Christian Brabandt <cb@256bit.org>
parents:
9195
diff
changeset
|
748 if (linelen == IOSIZE - 1 && !(IObuff[linelen - 1] == '\n' |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
749 #ifdef USE_CRNL |
9197
847a709d04c1
commit https://github.com/vim/vim/commit/b37662a0fbb952838fca87aff4d26b596030b67b
Christian Brabandt <cb@256bit.org>
parents:
9195
diff
changeset
|
750 || IObuff[linelen - 1] == '\r' |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
751 #endif |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
752 )) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
753 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
754 /* |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
755 * The current line exceeds IObuff, continue reading using |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
756 * growbuf until EOL or LINE_MAXLEN bytes is read. |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
757 */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
758 if (growbuf == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
759 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
760 growbufsiz = 2 * (IOSIZE - 1); |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
761 growbuf = alloc(growbufsiz); |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
762 if (growbuf == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
763 goto qf_init_end; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
764 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
765 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
766 /* Copy the read part of the line, excluding null-terminator */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
767 memcpy(growbuf, IObuff, IOSIZE - 1); |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
768 growbuflen = linelen; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
769 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
770 for (;;) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
771 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
772 if (fgets((char *)growbuf + growbuflen, |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
773 growbufsiz - growbuflen, fd) == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
774 break; |
9077
a2441f2ff85d
commit https://github.com/vim/vim/commit/d9db8b448c214eb583e84c598bca0688b9202ba7
Christian Brabandt <cb@256bit.org>
parents:
9060
diff
changeset
|
775 linelen = (int)STRLEN(growbuf + growbuflen); |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
776 growbuflen += linelen; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
777 if (growbuf[growbuflen - 1] == '\n' |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
778 #ifdef USE_CRNL |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
779 || growbuf[growbuflen - 1] == '\r' |
3002 | 780 #endif |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
781 ) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
782 break; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
783 if (growbufsiz == LINE_MAXLEN) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
784 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
785 discard = TRUE; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
786 break; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
787 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
788 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
789 growbufsiz = 2 * growbufsiz < LINE_MAXLEN |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
790 ? 2 * growbufsiz : LINE_MAXLEN; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
791 growbuf = vim_realloc(growbuf, 2 * growbufsiz); |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
792 if (growbuf == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
793 goto qf_init_end; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
794 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
795 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
796 while (discard) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
797 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
798 /* |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
799 * The current line is longer than LINE_MAXLEN, continue |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
800 * reading but discard everything until EOL or EOF is |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
801 * reached. |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
802 */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
803 if (fgets((char *)IObuff, IOSIZE, fd) == NULL |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
804 || (int)STRLEN(IObuff) < IOSIZE - 1 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
805 || IObuff[IOSIZE - 1] == '\n' |
7 | 806 #ifdef USE_CRNL |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
807 || IObuff[IOSIZE - 1] == '\r' |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
808 #endif |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
809 ) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
810 break; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
811 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
812 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
813 linebuf = growbuf; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
814 linelen = growbuflen; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
815 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
816 else |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
817 linebuf = IObuff; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
818 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
819 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
820 if (linelen > 0 && linebuf[linelen - 1] == '\n') |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
821 linebuf[linelen - 1] = NUL; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
822 #ifdef USE_CRNL |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
823 if (linelen > 0 && linebuf[linelen - 1] == '\r') |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
824 linebuf[linelen - 1] = NUL; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
825 #endif |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
826 |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
827 #ifdef FEAT_MBYTE |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
828 remove_bom(linebuf); |
7 | 829 #endif |
830 | |
789 | 831 /* If there was no %> item start at the first pattern */ |
832 if (fmt_start == NULL) | |
833 fmt_ptr = fmt_first; | |
834 else | |
835 { | |
836 fmt_ptr = fmt_start; | |
837 fmt_start = NULL; | |
838 } | |
839 | |
7 | 840 /* |
841 * Try to match each part of 'errorformat' until we find a complete | |
842 * match or no match. | |
843 */ | |
844 valid = TRUE; | |
845 restofline: | |
789 | 846 for ( ; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next) |
7 | 847 { |
6450 | 848 int r; |
849 | |
7 | 850 idx = fmt_ptr->prefix; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
851 if (qi->qf_multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL) |
7 | 852 continue; |
853 namebuf[0] = NUL; | |
230 | 854 pattern[0] = NUL; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
855 if (!qi->qf_multiscan) |
7 | 856 errmsg[0] = NUL; |
857 lnum = 0; | |
858 col = 0; | |
170 | 859 use_viscol = FALSE; |
7 | 860 enr = -1; |
861 type = 0; | |
862 tail = NULL; | |
863 | |
864 regmatch.regprog = fmt_ptr->prog; | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
865 r = vim_regexec(®match, linebuf, (colnr_T)0); |
6450 | 866 fmt_ptr->prog = regmatch.regprog; |
867 if (r) | |
7 | 868 { |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
869 if ((idx == 'C' || idx == 'Z') && !qi->qf_multiline) |
7 | 870 continue; |
871 if (vim_strchr((char_u *)"EWI", idx) != NULL) | |
872 type = idx; | |
873 else | |
874 type = 0; | |
875 /* | |
895 | 876 * Extract error message data from matched line. |
877 * We check for an actual submatch, because "\[" and "\]" in | |
878 * the 'errorformat' may cause the wrong submatch to be used. | |
7 | 879 */ |
880 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */ | |
881 { | |
895 | 882 int c; |
883 | |
884 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) | |
885 continue; | |
277 | 886 |
887 /* Expand ~/file and $HOME/file to full path. */ | |
895 | 888 c = *regmatch.endp[i]; |
277 | 889 *regmatch.endp[i] = NUL; |
890 expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE); | |
891 *regmatch.endp[i] = c; | |
892 | |
7 | 893 if (vim_strchr((char_u *)"OPQ", idx) != NULL |
277 | 894 && mch_getperm(namebuf) == -1) |
7 | 895 continue; |
896 } | |
897 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */ | |
895 | 898 { |
899 if (regmatch.startp[i] == NULL) | |
900 continue; | |
7 | 901 enr = (int)atol((char *)regmatch.startp[i]); |
895 | 902 } |
7 | 903 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */ |
895 | 904 { |
905 if (regmatch.startp[i] == NULL) | |
906 continue; | |
7 | 907 lnum = atol((char *)regmatch.startp[i]); |
895 | 908 } |
7 | 909 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */ |
895 | 910 { |
911 if (regmatch.startp[i] == NULL) | |
912 continue; | |
7 | 913 col = (int)atol((char *)regmatch.startp[i]); |
895 | 914 } |
7 | 915 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */ |
895 | 916 { |
917 if (regmatch.startp[i] == NULL) | |
918 continue; | |
7 | 919 type = *regmatch.startp[i]; |
895 | 920 } |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
921 if (fmt_ptr->flags == '+' && !qi->qf_multiscan) /* %+ */ |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
922 { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
923 if (linelen > errmsglen) { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
924 /* linelen + null terminator */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
925 if ((errmsg = vim_realloc(errmsg, linelen + 1)) == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
926 goto qf_init_end; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
927 errmsglen = linelen + 1; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
928 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
929 vim_strncpy(errmsg, linebuf, linelen); |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
930 } |
7 | 931 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */ |
932 { | |
895 | 933 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
934 continue; | |
7 | 935 len = (int)(regmatch.endp[i] - regmatch.startp[i]); |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
936 if (len > errmsglen) { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
937 /* len + null terminator */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
938 if ((errmsg = vim_realloc(errmsg, len + 1)) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
939 == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
940 goto qf_init_end; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
941 errmsglen = len + 1; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
942 } |
418 | 943 vim_strncpy(errmsg, regmatch.startp[i], len); |
7 | 944 } |
945 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */ | |
895 | 946 { |
947 if (regmatch.startp[i] == NULL) | |
948 continue; | |
7 | 949 tail = regmatch.startp[i]; |
895 | 950 } |
7 | 951 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */ |
952 { | |
3555 | 953 char_u *match_ptr; |
954 | |
895 | 955 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
956 continue; | |
3555 | 957 col = 0; |
958 for (match_ptr = regmatch.startp[i]; | |
959 match_ptr != regmatch.endp[i]; ++match_ptr) | |
960 { | |
961 ++col; | |
962 if (*match_ptr == TAB) | |
963 { | |
964 col += 7; | |
965 col -= col % 8; | |
966 } | |
967 } | |
968 ++col; | |
969 use_viscol = TRUE; | |
7 | 970 } |
971 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */ | |
972 { | |
895 | 973 if (regmatch.startp[i] == NULL) |
974 continue; | |
7 | 975 col = (int)atol((char *)regmatch.startp[i]); |
170 | 976 use_viscol = TRUE; |
7 | 977 } |
230 | 978 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */ |
979 { | |
895 | 980 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) |
981 continue; | |
230 | 982 len = (int)(regmatch.endp[i] - regmatch.startp[i]); |
983 if (len > CMDBUFFSIZE - 5) | |
984 len = CMDBUFFSIZE - 5; | |
985 STRCPY(pattern, "^\\V"); | |
986 STRNCAT(pattern, regmatch.startp[i], len); | |
987 pattern[len + 3] = '\\'; | |
988 pattern[len + 4] = '$'; | |
989 pattern[len + 5] = NUL; | |
990 } | |
7 | 991 break; |
992 } | |
993 } | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
994 qi->qf_multiscan = FALSE; |
789 | 995 |
625 | 996 if (fmt_ptr == NULL || idx == 'D' || idx == 'X') |
7 | 997 { |
625 | 998 if (fmt_ptr != NULL) |
7 | 999 { |
1000 if (idx == 'D') /* enter directory */ | |
1001 { | |
1002 if (*namebuf == NUL) | |
1003 { | |
1004 EMSG(_("E379: Missing or empty directory name")); | |
1005 goto error2; | |
1006 } | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1007 qi->qf_directory = |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1008 qf_push_dir(namebuf, &qi->qf_dir_stack, FALSE); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1009 if (qi->qf_directory == NULL) |
7 | 1010 goto error2; |
1011 } | |
1012 else if (idx == 'X') /* leave directory */ | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1013 qi->qf_directory = qf_pop_dir(&qi->qf_dir_stack); |
7 | 1014 } |
1015 namebuf[0] = NUL; /* no match found, remove file name */ | |
1016 lnum = 0; /* don't jump to this line */ | |
1017 valid = FALSE; | |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1018 if (linelen > errmsglen) { |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1019 /* linelen + null terminator */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1020 if ((errmsg = vim_realloc(errmsg, linelen + 1)) == NULL) |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1021 goto qf_init_end; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1022 errmsglen = linelen + 1; |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1023 } |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1024 /* copy whole line to error message */ |
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1025 vim_strncpy(errmsg, linebuf, linelen); |
625 | 1026 if (fmt_ptr == NULL) |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1027 qi->qf_multiline = qi->qf_multiignore = FALSE; |
7 | 1028 } |
625 | 1029 else if (fmt_ptr != NULL) |
7 | 1030 { |
789 | 1031 /* honor %> item */ |
1032 if (fmt_ptr->conthere) | |
1033 fmt_start = fmt_ptr; | |
1034 | |
7 | 1035 if (vim_strchr((char_u *)"AEWI", idx) != NULL) |
5716 | 1036 { |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1037 qi->qf_multiline = TRUE; /* start of a multi-line message */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1038 qi->qf_multiignore = FALSE; /* reset continuation */ |
5716 | 1039 } |
7 | 1040 else if (vim_strchr((char_u *)"CZ", idx) != NULL) |
1041 { /* continuation of multi-line msg */ | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1042 qfline_T *qfprev = qi->qf_lists[qi->qf_curlist].qf_last; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1043 |
7 | 1044 if (qfprev == NULL) |
1045 goto error2; | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1046 if (*errmsg && !qi->qf_multiignore) |
7 | 1047 { |
1048 len = (int)STRLEN(qfprev->qf_text); | |
1049 if ((ptr = alloc((unsigned)(len + STRLEN(errmsg) + 2))) | |
1050 == NULL) | |
1051 goto error2; | |
1052 STRCPY(ptr, qfprev->qf_text); | |
1053 vim_free(qfprev->qf_text); | |
1054 qfprev->qf_text = ptr; | |
1055 *(ptr += len) = '\n'; | |
1056 STRCPY(++ptr, errmsg); | |
1057 } | |
1058 if (qfprev->qf_nr == -1) | |
1059 qfprev->qf_nr = enr; | |
1060 if (vim_isprintc(type) && !qfprev->qf_type) | |
1061 qfprev->qf_type = type; /* only printable chars allowed */ | |
1062 if (!qfprev->qf_lnum) | |
1063 qfprev->qf_lnum = lnum; | |
1064 if (!qfprev->qf_col) | |
1065 qfprev->qf_col = col; | |
170 | 1066 qfprev->qf_viscol = use_viscol; |
7 | 1067 if (!qfprev->qf_fnum) |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1068 qfprev->qf_fnum = qf_get_fnum(qi, qi->qf_directory, |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1069 *namebuf || qi->qf_directory != NULL |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1070 ? namebuf |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1071 : qi->qf_currfile != NULL && valid |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1072 ? qi->qf_currfile : 0); |
7 | 1073 if (idx == 'Z') |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1074 qi->qf_multiline = qi->qf_multiignore = FALSE; |
7 | 1075 line_breakcheck(); |
1076 continue; | |
1077 } | |
1078 else if (vim_strchr((char_u *)"OPQ", idx) != NULL) | |
1079 { | |
1080 /* global file names */ | |
1081 valid = FALSE; | |
1082 if (*namebuf == NUL || mch_getperm(namebuf) >= 0) | |
1083 { | |
1084 if (*namebuf && idx == 'P') | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1085 qi->qf_currfile = |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1086 qf_push_dir(namebuf, &qi->qf_file_stack, TRUE); |
7 | 1087 else if (idx == 'Q') |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1088 qi->qf_currfile = qf_pop_dir(&qi->qf_file_stack); |
7 | 1089 *namebuf = NUL; |
1090 if (tail && *tail) | |
1091 { | |
1668 | 1092 STRMOVE(IObuff, skipwhite(tail)); |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1093 qi->qf_multiscan = TRUE; |
7 | 1094 goto restofline; |
1095 } | |
1096 } | |
1097 } | |
1098 if (fmt_ptr->flags == '-') /* generally exclude this line */ | |
1099 { | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1100 if (qi->qf_multiline) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1101 /* also exclude continuation lines */ |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1102 qi->qf_multiignore = TRUE; |
7 | 1103 continue; |
1104 } | |
1105 } | |
1106 | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1107 if (qf_add_entry(qi, |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1108 qi->qf_directory, |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1109 (*namebuf || qi->qf_directory != NULL) |
7 | 1110 ? namebuf |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1111 : ((qi->qf_currfile != NULL && valid) |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1112 ? qi->qf_currfile : (char_u *)NULL), |
1065 | 1113 0, |
7 | 1114 errmsg, |
1115 lnum, | |
1116 col, | |
170 | 1117 use_viscol, |
230 | 1118 pattern, |
7 | 1119 enr, |
1120 type, | |
1121 valid) == FAIL) | |
1122 goto error2; | |
1123 line_breakcheck(); | |
1124 } | |
41 | 1125 if (fd == NULL || !ferror(fd)) |
7 | 1126 { |
644 | 1127 if (qi->qf_lists[qi->qf_curlist].qf_index == 0) |
7 | 1128 { |
644 | 1129 /* no valid entry found */ |
1130 qi->qf_lists[qi->qf_curlist].qf_ptr = | |
1131 qi->qf_lists[qi->qf_curlist].qf_start; | |
1132 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
1133 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE; | |
7 | 1134 } |
1135 else | |
1136 { | |
644 | 1137 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
1138 if (qi->qf_lists[qi->qf_curlist].qf_ptr == NULL) | |
1139 qi->qf_lists[qi->qf_curlist].qf_ptr = | |
1140 qi->qf_lists[qi->qf_curlist].qf_start; | |
7 | 1141 } |
644 | 1142 /* return number of matches */ |
1143 retval = qi->qf_lists[qi->qf_curlist].qf_count; | |
9369
ce5b79b005ec
commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents:
9365
diff
changeset
|
1144 goto qf_init_end; |
7 | 1145 } |
1146 EMSG(_(e_readerrf)); | |
1147 error2: | |
644 | 1148 qf_free(qi, qi->qf_curlist); |
1149 qi->qf_listcount--; | |
1150 if (qi->qf_curlist > 0) | |
1151 --qi->qf_curlist; | |
9369
ce5b79b005ec
commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents:
9365
diff
changeset
|
1152 qf_init_end: |
41 | 1153 if (fd != NULL) |
1154 fclose(fd); | |
7 | 1155 vim_free(namebuf); |
1156 vim_free(errmsg); | |
230 | 1157 vim_free(pattern); |
9033
0536d1469b67
commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents:
8932
diff
changeset
|
1158 vim_free(growbuf); |
7 | 1159 |
1160 #ifdef FEAT_WINDOWS | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
1161 qf_update_buffer(qi, old_last); |
7 | 1162 #endif |
1163 | |
1164 return retval; | |
1165 } | |
1166 | |
6079 | 1167 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1168 qf_store_title(qf_info_T *qi, char_u *title) |
6079 | 1169 { |
1170 if (title != NULL) | |
1171 { | |
1172 char_u *p = alloc((int)STRLEN(title) + 2); | |
1173 | |
1174 qi->qf_lists[qi->qf_curlist].qf_title = p; | |
1175 if (p != NULL) | |
1176 sprintf((char *)p, ":%s", (char *)title); | |
1177 } | |
1178 } | |
1179 | |
7 | 1180 /* |
1181 * Prepare for adding a new quickfix list. | |
1182 */ | |
1183 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1184 qf_new_list(qf_info_T *qi, char_u *qf_title) |
7 | 1185 { |
1186 int i; | |
1187 | |
1188 /* | |
6079 | 1189 * If the current entry is not the last entry, delete entries beyond |
7 | 1190 * the current entry. This makes it possible to browse in a tree-like |
1191 * way with ":grep'. | |
1192 */ | |
644 | 1193 while (qi->qf_listcount > qi->qf_curlist + 1) |
1194 qf_free(qi, --qi->qf_listcount); | |
7 | 1195 |
1196 /* | |
1197 * When the stack is full, remove to oldest entry | |
1198 * Otherwise, add a new entry. | |
1199 */ | |
644 | 1200 if (qi->qf_listcount == LISTCOUNT) |
7 | 1201 { |
644 | 1202 qf_free(qi, 0); |
7 | 1203 for (i = 1; i < LISTCOUNT; ++i) |
644 | 1204 qi->qf_lists[i - 1] = qi->qf_lists[i]; |
1205 qi->qf_curlist = LISTCOUNT - 1; | |
7 | 1206 } |
1207 else | |
644 | 1208 qi->qf_curlist = qi->qf_listcount++; |
3259 | 1209 vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T))); |
6079 | 1210 qf_store_title(qi, qf_title); |
7 | 1211 } |
1212 | |
644 | 1213 /* |
1214 * Free a location list | |
1215 */ | |
1216 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1217 ll_free_all(qf_info_T **pqi) |
359 | 1218 { |
1219 int i; | |
644 | 1220 qf_info_T *qi; |
1221 | |
1222 qi = *pqi; | |
1223 if (qi == NULL) | |
1224 return; | |
1225 *pqi = NULL; /* Remove reference to this list */ | |
1226 | |
1227 qi->qf_refcount--; | |
1228 if (qi->qf_refcount < 1) | |
1229 { | |
1230 /* No references to this location list */ | |
1231 for (i = 0; i < qi->qf_listcount; ++i) | |
1232 qf_free(qi, i); | |
1233 vim_free(qi); | |
1234 } | |
359 | 1235 } |
644 | 1236 |
1237 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1238 qf_free_all(win_T *wp) |
644 | 1239 { |
1240 int i; | |
1241 qf_info_T *qi = &ql_info; | |
1242 | |
1243 if (wp != NULL) | |
1244 { | |
1245 /* location list */ | |
1246 ll_free_all(&wp->w_llist); | |
1247 ll_free_all(&wp->w_llist_ref); | |
1248 } | |
1249 else | |
1250 /* quickfix list */ | |
1251 for (i = 0; i < qi->qf_listcount; ++i) | |
1252 qf_free(qi, i); | |
1253 } | |
359 | 1254 |
7 | 1255 /* |
1256 * Add an entry to the end of the list of errors. | |
1257 * Returns OK or FAIL. | |
1258 */ | |
1259 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1260 qf_add_entry( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1261 qf_info_T *qi, /* quickfix list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1262 char_u *dir, /* optional directory name */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1263 char_u *fname, /* file name or NULL */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1264 int bufnum, /* buffer number or zero */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1265 char_u *mesg, /* message */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1266 long lnum, /* line number */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1267 int col, /* column */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1268 int vis_col, /* using visual column */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1269 char_u *pattern, /* search pattern */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1270 int nr, /* error number */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1271 int type, /* type character */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1272 int valid) /* valid entry */ |
7 | 1273 { |
230 | 1274 qfline_T *qfp; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1275 qfline_T **lastp; /* pointer to qf_last or NULL */ |
7 | 1276 |
230 | 1277 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) |
7 | 1278 return FAIL; |
1065 | 1279 if (bufnum != 0) |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1280 { |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1281 buf_T *buf = buflist_findnr(bufnum); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1282 |
1065 | 1283 qfp->qf_fnum = bufnum; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1284 if (buf != NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1285 buf->b_has_qf_entry = TRUE; |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1286 } |
1065 | 1287 else |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1288 qfp->qf_fnum = qf_get_fnum(qi, dir, fname); |
7 | 1289 if ((qfp->qf_text = vim_strsave(mesg)) == NULL) |
1290 { | |
1291 vim_free(qfp); | |
1292 return FAIL; | |
1293 } | |
1294 qfp->qf_lnum = lnum; | |
1295 qfp->qf_col = col; | |
170 | 1296 qfp->qf_viscol = vis_col; |
230 | 1297 if (pattern == NULL || *pattern == NUL) |
1298 qfp->qf_pattern = NULL; | |
1299 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) | |
1300 { | |
1301 vim_free(qfp->qf_text); | |
1302 vim_free(qfp); | |
1303 return FAIL; | |
1304 } | |
7 | 1305 qfp->qf_nr = nr; |
1306 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */ | |
1307 type = 0; | |
1308 qfp->qf_type = type; | |
1309 qfp->qf_valid = valid; | |
1310 | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1311 lastp = &qi->qf_lists[qi->qf_curlist].qf_last; |
644 | 1312 if (qi->qf_lists[qi->qf_curlist].qf_count == 0) |
1313 /* first element in the list */ | |
7 | 1314 { |
644 | 1315 qi->qf_lists[qi->qf_curlist].qf_start = qfp; |
8716
4ce26276caeb
commit https://github.com/vim/vim/commit/8b20179c657b4266dff115486ca68c6a50324071
Christian Brabandt <cb@256bit.org>
parents:
8702
diff
changeset
|
1316 qi->qf_lists[qi->qf_curlist].qf_ptr = qfp; |
4ce26276caeb
commit https://github.com/vim/vim/commit/8b20179c657b4266dff115486ca68c6a50324071
Christian Brabandt <cb@256bit.org>
parents:
8702
diff
changeset
|
1317 qi->qf_lists[qi->qf_curlist].qf_index = 0; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1318 qfp->qf_prev = NULL; |
7 | 1319 } |
1320 else | |
1321 { | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1322 qfp->qf_prev = *lastp; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1323 (*lastp)->qf_next = qfp; |
7 | 1324 } |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1325 qfp->qf_next = NULL; |
7 | 1326 qfp->qf_cleared = FALSE; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1327 *lastp = qfp; |
644 | 1328 ++qi->qf_lists[qi->qf_curlist].qf_count; |
1329 if (qi->qf_lists[qi->qf_curlist].qf_index == 0 && qfp->qf_valid) | |
1330 /* first valid entry */ | |
7 | 1331 { |
644 | 1332 qi->qf_lists[qi->qf_curlist].qf_index = |
1333 qi->qf_lists[qi->qf_curlist].qf_count; | |
1334 qi->qf_lists[qi->qf_curlist].qf_ptr = qfp; | |
7 | 1335 } |
1336 | |
1337 return OK; | |
1338 } | |
1339 | |
1340 /* | |
659 | 1341 * Allocate a new location list |
644 | 1342 */ |
659 | 1343 static qf_info_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1344 ll_new_list(void) |
644 | 1345 { |
659 | 1346 qf_info_T *qi; |
1347 | |
1348 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T)); | |
1349 if (qi != NULL) | |
1350 { | |
1351 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T))); | |
1352 qi->qf_refcount++; | |
1353 } | |
1354 | |
1355 return qi; | |
644 | 1356 } |
1357 | |
1358 /* | |
1359 * Return the location list for window 'wp'. | |
1360 * If not present, allocate a location list | |
1361 */ | |
1362 static qf_info_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1363 ll_get_or_alloc_list(win_T *wp) |
644 | 1364 { |
1365 if (IS_LL_WINDOW(wp)) | |
1366 /* For a location list window, use the referenced location list */ | |
1367 return wp->w_llist_ref; | |
1368 | |
1369 /* | |
1370 * For a non-location list window, w_llist_ref should not point to a | |
1371 * location list. | |
1372 */ | |
1373 ll_free_all(&wp->w_llist_ref); | |
1374 | |
1375 if (wp->w_llist == NULL) | |
659 | 1376 wp->w_llist = ll_new_list(); /* new location list */ |
644 | 1377 return wp->w_llist; |
1378 } | |
1379 | |
1380 /* | |
1381 * Copy the location list from window "from" to window "to". | |
1382 */ | |
1383 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1384 copy_loclist(win_T *from, win_T *to) |
644 | 1385 { |
1386 qf_info_T *qi; | |
1387 int idx; | |
1388 int i; | |
1389 | |
1390 /* | |
1391 * When copying from a location list window, copy the referenced | |
1392 * location list. For other windows, copy the location list for | |
1393 * that window. | |
1394 */ | |
1395 if (IS_LL_WINDOW(from)) | |
1396 qi = from->w_llist_ref; | |
1397 else | |
1398 qi = from->w_llist; | |
1399 | |
1400 if (qi == NULL) /* no location list to copy */ | |
1401 return; | |
1402 | |
659 | 1403 /* allocate a new location list */ |
1404 if ((to->w_llist = ll_new_list()) == NULL) | |
644 | 1405 return; |
1406 | |
1407 to->w_llist->qf_listcount = qi->qf_listcount; | |
1408 | |
1409 /* Copy the location lists one at a time */ | |
1410 for (idx = 0; idx < qi->qf_listcount; idx++) | |
1411 { | |
1412 qf_list_T *from_qfl; | |
1413 qf_list_T *to_qfl; | |
1414 | |
1415 to->w_llist->qf_curlist = idx; | |
1416 | |
1417 from_qfl = &qi->qf_lists[idx]; | |
1418 to_qfl = &to->w_llist->qf_lists[idx]; | |
1419 | |
1420 /* Some of the fields are populated by qf_add_entry() */ | |
1421 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid; | |
1422 to_qfl->qf_count = 0; | |
1423 to_qfl->qf_index = 0; | |
1424 to_qfl->qf_start = NULL; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1425 to_qfl->qf_last = NULL; |
644 | 1426 to_qfl->qf_ptr = NULL; |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1427 if (from_qfl->qf_title != NULL) |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1428 to_qfl->qf_title = vim_strsave(from_qfl->qf_title); |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1429 else |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
1430 to_qfl->qf_title = NULL; |
644 | 1431 |
1432 if (from_qfl->qf_count) | |
1433 { | |
1434 qfline_T *from_qfp; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1435 qfline_T *prevp; |
644 | 1436 |
1437 /* copy all the location entries in this list */ | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1438 for (i = 0, from_qfp = from_qfl->qf_start; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1439 i < from_qfl->qf_count && from_qfp != NULL; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1440 ++i, from_qfp = from_qfp->qf_next) |
644 | 1441 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1442 if (qf_add_entry(to->w_llist, |
644 | 1443 NULL, |
1444 NULL, | |
1065 | 1445 0, |
644 | 1446 from_qfp->qf_text, |
1447 from_qfp->qf_lnum, | |
1448 from_qfp->qf_col, | |
1449 from_qfp->qf_viscol, | |
1450 from_qfp->qf_pattern, | |
1451 from_qfp->qf_nr, | |
1452 0, | |
1453 from_qfp->qf_valid) == FAIL) | |
1454 { | |
1455 qf_free_all(to); | |
1456 return; | |
1457 } | |
1458 /* | |
1459 * qf_add_entry() will not set the qf_num field, as the | |
1460 * directory and file names are not supplied. So the qf_fnum | |
1461 * field is copied here. | |
1462 */ | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1463 prevp = to->w_llist->qf_lists[to->w_llist->qf_curlist].qf_last; |
644 | 1464 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */ |
1465 prevp->qf_type = from_qfp->qf_type; /* error type */ | |
1466 if (from_qfl->qf_ptr == from_qfp) | |
1467 to_qfl->qf_ptr = prevp; /* current location */ | |
1468 } | |
1469 } | |
1470 | |
1471 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */ | |
1472 | |
1473 /* When no valid entries are present in the list, qf_ptr points to | |
1474 * the first item in the list */ | |
2795 | 1475 if (to_qfl->qf_nonevalid) |
5060
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1476 { |
644 | 1477 to_qfl->qf_ptr = to_qfl->qf_start; |
5060
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1478 to_qfl->qf_index = 1; |
30910831e5b0
updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
1479 } |
644 | 1480 } |
1481 | |
1482 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */ | |
1483 } | |
1484 | |
1485 /* | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1486 * Get buffer number for file "dir.name". |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1487 * Also sets the b_has_qf_entry flag. |
7 | 1488 */ |
1489 static int | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1490 qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname) |
7 | 1491 { |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1492 char_u *ptr; |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1493 buf_T *buf; |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1494 |
7 | 1495 if (fname == NULL || *fname == NUL) /* no file name */ |
1496 return 0; | |
1497 | |
2823 | 1498 #ifdef VMS |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1499 vms_remove_version(fname); |
2823 | 1500 #endif |
1501 #ifdef BACKSLASH_IN_FILENAME | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1502 if (directory != NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1503 slash_adjust(directory); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1504 slash_adjust(fname); |
2823 | 1505 #endif |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1506 if (directory != NULL && !vim_isAbsName(fname) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1507 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1508 { |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1509 /* |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1510 * Here we check if the file really exists. |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1511 * This should normally be true, but if make works without |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1512 * "leaving directory"-messages we might have missed a |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1513 * directory change. |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1514 */ |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1515 if (mch_getperm(ptr) < 0) |
7 | 1516 { |
1517 vim_free(ptr); | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1518 directory = qf_guess_filepath(qi, fname); |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1519 if (directory) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1520 ptr = concat_fnames(directory, fname, TRUE); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1521 else |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1522 ptr = vim_strsave(fname); |
7 | 1523 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1524 /* Use concatenated directory name and file name */ |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1525 buf = buflist_new(ptr, NULL, (linenr_T)0, 0); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1526 vim_free(ptr); |
7 | 1527 } |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1528 else |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1529 buf = buflist_new(fname, NULL, (linenr_T)0, 0); |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1530 if (buf == NULL) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1531 return 0; |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1532 buf->b_has_qf_entry = TRUE; |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
1533 return buf->b_fnum; |
7 | 1534 } |
1535 | |
1536 /* | |
9334
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
1537 * Push dirbuf onto the directory stack and return pointer to actual dir or |
674f9e3ccd1a
commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents:
9201
diff
changeset
|
1538 * NULL on error. |
7 | 1539 */ |
1540 static char_u * | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1541 qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) |
7 | 1542 { |
1543 struct dir_stack_T *ds_new; | |
1544 struct dir_stack_T *ds_ptr; | |
1545 | |
1546 /* allocate new stack element and hook it in */ | |
1547 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T)); | |
1548 if (ds_new == NULL) | |
1549 return NULL; | |
1550 | |
1551 ds_new->next = *stackptr; | |
1552 *stackptr = ds_new; | |
1553 | |
1554 /* store directory on the stack */ | |
1555 if (vim_isAbsName(dirbuf) | |
1556 || (*stackptr)->next == NULL | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1557 || (*stackptr && is_file_stack)) |
7 | 1558 (*stackptr)->dirname = vim_strsave(dirbuf); |
1559 else | |
1560 { | |
1561 /* Okay we don't have an absolute path. | |
1562 * dirbuf must be a subdir of one of the directories on the stack. | |
1563 * Let's search... | |
1564 */ | |
1565 ds_new = (*stackptr)->next; | |
1566 (*stackptr)->dirname = NULL; | |
1567 while (ds_new) | |
1568 { | |
1569 vim_free((*stackptr)->dirname); | |
1570 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, | |
1571 TRUE); | |
1572 if (mch_isdir((*stackptr)->dirname) == TRUE) | |
1573 break; | |
1574 | |
1575 ds_new = ds_new->next; | |
1576 } | |
1577 | |
1578 /* clean up all dirs we already left */ | |
1579 while ((*stackptr)->next != ds_new) | |
1580 { | |
1581 ds_ptr = (*stackptr)->next; | |
1582 (*stackptr)->next = (*stackptr)->next->next; | |
1583 vim_free(ds_ptr->dirname); | |
1584 vim_free(ds_ptr); | |
1585 } | |
1586 | |
1587 /* Nothing found -> it must be on top level */ | |
1588 if (ds_new == NULL) | |
1589 { | |
1590 vim_free((*stackptr)->dirname); | |
1591 (*stackptr)->dirname = vim_strsave(dirbuf); | |
1592 } | |
1593 } | |
1594 | |
1595 if ((*stackptr)->dirname != NULL) | |
1596 return (*stackptr)->dirname; | |
1597 else | |
1598 { | |
1599 ds_ptr = *stackptr; | |
1600 *stackptr = (*stackptr)->next; | |
1601 vim_free(ds_ptr); | |
1602 return NULL; | |
1603 } | |
1604 } | |
1605 | |
1606 | |
1607 /* | |
1608 * pop dirbuf from the directory stack and return previous directory or NULL if | |
1609 * stack is empty | |
1610 */ | |
1611 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1612 qf_pop_dir(struct dir_stack_T **stackptr) |
7 | 1613 { |
1614 struct dir_stack_T *ds_ptr; | |
1615 | |
1616 /* TODO: Should we check if dirbuf is the directory on top of the stack? | |
1617 * What to do if it isn't? */ | |
1618 | |
1619 /* pop top element and free it */ | |
1620 if (*stackptr != NULL) | |
1621 { | |
1622 ds_ptr = *stackptr; | |
1623 *stackptr = (*stackptr)->next; | |
1624 vim_free(ds_ptr->dirname); | |
1625 vim_free(ds_ptr); | |
1626 } | |
1627 | |
1628 /* return NEW top element as current dir or NULL if stack is empty*/ | |
1629 return *stackptr ? (*stackptr)->dirname : NULL; | |
1630 } | |
1631 | |
1632 /* | |
1633 * clean up directory stack | |
1634 */ | |
1635 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1636 qf_clean_dir_stack(struct dir_stack_T **stackptr) |
7 | 1637 { |
1638 struct dir_stack_T *ds_ptr; | |
1639 | |
1640 while ((ds_ptr = *stackptr) != NULL) | |
1641 { | |
1642 *stackptr = (*stackptr)->next; | |
1643 vim_free(ds_ptr->dirname); | |
1644 vim_free(ds_ptr); | |
1645 } | |
1646 } | |
1647 | |
1648 /* | |
1649 * Check in which directory of the directory stack the given file can be | |
1650 * found. | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
1651 * Returns a pointer to the directory name or NULL if not found. |
7 | 1652 * Cleans up intermediate directory entries. |
1653 * | |
1654 * TODO: How to solve the following problem? | |
1655 * If we have the this directory tree: | |
1656 * ./ | |
1657 * ./aa | |
1658 * ./aa/bb | |
1659 * ./bb | |
1660 * ./bb/x.c | |
1661 * and make says: | |
1662 * making all in aa | |
1663 * making all in bb | |
1664 * x.c:9: Error | |
1665 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb. | |
1666 * qf_guess_filepath will return NULL. | |
1667 */ | |
1668 static char_u * | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1669 qf_guess_filepath(qf_info_T *qi, char_u *filename) |
7 | 1670 { |
1671 struct dir_stack_T *ds_ptr; | |
1672 struct dir_stack_T *ds_tmp; | |
1673 char_u *fullname; | |
1674 | |
1675 /* no dirs on the stack - there's nothing we can do */ | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1676 if (qi->qf_dir_stack == NULL) |
7 | 1677 return NULL; |
1678 | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1679 ds_ptr = qi->qf_dir_stack->next; |
7 | 1680 fullname = NULL; |
1681 while (ds_ptr) | |
1682 { | |
1683 vim_free(fullname); | |
1684 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE); | |
1685 | |
1686 /* If concat_fnames failed, just go on. The worst thing that can happen | |
1687 * is that we delete the entire stack. | |
1688 */ | |
1689 if ((fullname != NULL) && (mch_getperm(fullname) >= 0)) | |
1690 break; | |
1691 | |
1692 ds_ptr = ds_ptr->next; | |
1693 } | |
1694 | |
1695 vim_free(fullname); | |
1696 | |
1697 /* clean up all dirs we already left */ | |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1698 while (qi->qf_dir_stack->next != ds_ptr) |
7 | 1699 { |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1700 ds_tmp = qi->qf_dir_stack->next; |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
1701 qi->qf_dir_stack->next = qi->qf_dir_stack->next->next; |
7 | 1702 vim_free(ds_tmp->dirname); |
1703 vim_free(ds_tmp); | |
1704 } | |
1705 | |
1706 return ds_ptr==NULL? NULL: ds_ptr->dirname; | |
1707 } | |
1708 | |
1709 /* | |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1710 * When loading a file from the quickfix, the auto commands may modify it. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1711 * This may invalidate the current quickfix entry. This function checks |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1712 * whether a entry is still present in the quickfix. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1713 * Similar to location list. |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1714 */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1715 static int |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1716 is_qf_entry_present(qf_info_T *qi, qfline_T *qf_ptr) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1717 { |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1718 qf_list_T *qfl; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1719 qfline_T *qfp; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1720 int i; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1721 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1722 qfl = &qi->qf_lists[qi->qf_curlist]; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1723 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1724 /* Search for the entry in the current list */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1725 for (i = 0, qfp = qfl->qf_start; i < qfl->qf_count; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1726 ++i, qfp = qfp->qf_next) |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
1727 if (qfp == NULL || qfp == qf_ptr) |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1728 break; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1729 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1730 if (i == qfl->qf_count) /* Entry is not found */ |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1731 return FALSE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1732 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1733 return TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1734 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1735 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1736 /* |
7 | 1737 * jump to a quickfix line |
1738 * if dir == FORWARD go "errornr" valid entries forward | |
1739 * if dir == BACKWARD go "errornr" valid entries backward | |
1740 * if dir == FORWARD_FILE go "errornr" valid entries files backward | |
1741 * if dir == BACKWARD_FILE go "errornr" valid entries files backward | |
1742 * else if "errornr" is zero, redisplay the same line | |
1743 * else go to entry "errornr" | |
1744 */ | |
1745 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1746 qf_jump( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1747 qf_info_T *qi, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1748 int dir, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1749 int errornr, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1750 int forceit) |
7 | 1751 { |
644 | 1752 qf_info_T *ll_ref; |
230 | 1753 qfline_T *qf_ptr; |
1754 qfline_T *old_qf_ptr; | |
7 | 1755 int qf_index; |
1756 int old_qf_fnum; | |
1757 int old_qf_index; | |
1758 int prev_index; | |
1759 static char_u *e_no_more_items = (char_u *)N_("E553: No more items"); | |
1760 char_u *err = e_no_more_items; | |
1761 linenr_T i; | |
1762 buf_T *old_curbuf; | |
1763 linenr_T old_lnum; | |
1764 colnr_T screen_col; | |
1765 colnr_T char_col; | |
1766 char_u *line; | |
1767 #ifdef FEAT_WINDOWS | |
639 | 1768 char_u *old_swb = p_swb; |
1621 | 1769 unsigned old_swb_flags = swb_flags; |
7 | 1770 int opened_window = FALSE; |
1771 win_T *win; | |
1772 win_T *altwin; | |
1822 | 1773 int flags; |
7 | 1774 #endif |
1743 | 1775 win_T *oldwin = curwin; |
7 | 1776 int print_message = TRUE; |
1777 int len; | |
1778 #ifdef FEAT_FOLDING | |
1779 int old_KeyTyped = KeyTyped; /* getting file may reset it */ | |
1780 #endif | |
9 | 1781 int ok = OK; |
644 | 1782 int usable_win; |
1783 | |
659 | 1784 if (qi == NULL) |
1785 qi = &ql_info; | |
644 | 1786 |
1787 if (qi->qf_curlist >= qi->qf_listcount | |
1788 || qi->qf_lists[qi->qf_curlist].qf_count == 0) | |
7 | 1789 { |
1790 EMSG(_(e_quickfix)); | |
1791 return; | |
1792 } | |
1793 | |
644 | 1794 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr; |
7 | 1795 old_qf_ptr = qf_ptr; |
644 | 1796 qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
7 | 1797 old_qf_index = qf_index; |
1798 if (dir == FORWARD || dir == FORWARD_FILE) /* next valid entry */ | |
1799 { | |
1800 while (errornr--) | |
1801 { | |
1802 old_qf_ptr = qf_ptr; | |
1803 prev_index = qf_index; | |
1804 old_qf_fnum = qf_ptr->qf_fnum; | |
1805 do | |
1806 { | |
644 | 1807 if (qf_index == qi->qf_lists[qi->qf_curlist].qf_count |
7 | 1808 || qf_ptr->qf_next == NULL) |
1809 { | |
1810 qf_ptr = old_qf_ptr; | |
1811 qf_index = prev_index; | |
1812 if (err != NULL) | |
1813 { | |
1814 EMSG(_(err)); | |
1815 goto theend; | |
1816 } | |
1817 errornr = 0; | |
1818 break; | |
1819 } | |
1820 ++qf_index; | |
1821 qf_ptr = qf_ptr->qf_next; | |
644 | 1822 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid |
1823 && !qf_ptr->qf_valid) | |
7 | 1824 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
1825 err = NULL; | |
1826 } | |
1827 } | |
1828 else if (dir == BACKWARD || dir == BACKWARD_FILE) /* prev. valid entry */ | |
1829 { | |
1830 while (errornr--) | |
1831 { | |
1832 old_qf_ptr = qf_ptr; | |
1833 prev_index = qf_index; | |
1834 old_qf_fnum = qf_ptr->qf_fnum; | |
1835 do | |
1836 { | |
1837 if (qf_index == 1 || qf_ptr->qf_prev == NULL) | |
1838 { | |
1839 qf_ptr = old_qf_ptr; | |
1840 qf_index = prev_index; | |
1841 if (err != NULL) | |
1842 { | |
1843 EMSG(_(err)); | |
1844 goto theend; | |
1845 } | |
1846 errornr = 0; | |
1847 break; | |
1848 } | |
1849 --qf_index; | |
1850 qf_ptr = qf_ptr->qf_prev; | |
644 | 1851 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid |
1852 && !qf_ptr->qf_valid) | |
7 | 1853 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); |
1854 err = NULL; | |
1855 } | |
1856 } | |
1857 else if (errornr != 0) /* go to specified number */ | |
1858 { | |
1859 while (errornr < qf_index && qf_index > 1 && qf_ptr->qf_prev != NULL) | |
1860 { | |
1861 --qf_index; | |
1862 qf_ptr = qf_ptr->qf_prev; | |
1863 } | |
644 | 1864 while (errornr > qf_index && qf_index < |
1865 qi->qf_lists[qi->qf_curlist].qf_count | |
7 | 1866 && qf_ptr->qf_next != NULL) |
1867 { | |
1868 ++qf_index; | |
1869 qf_ptr = qf_ptr->qf_next; | |
1870 } | |
1871 } | |
1872 | |
1873 #ifdef FEAT_WINDOWS | |
644 | 1874 qi->qf_lists[qi->qf_curlist].qf_index = qf_index; |
1875 if (qf_win_pos_update(qi, old_qf_index)) | |
7 | 1876 /* No need to print the error message if it's visible in the error |
1877 * window */ | |
1878 print_message = FALSE; | |
1879 | |
1880 /* | |
9 | 1881 * For ":helpgrep" find a help window or open one. |
1882 */ | |
682 | 1883 if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0)) |
9 | 1884 { |
1885 win_T *wp; | |
1886 | |
682 | 1887 if (cmdmod.tab != 0) |
1888 wp = NULL; | |
1889 else | |
1890 for (wp = firstwin; wp != NULL; wp = wp->w_next) | |
1891 if (wp->w_buffer != NULL && wp->w_buffer->b_help) | |
1892 break; | |
9 | 1893 if (wp != NULL && wp->w_buffer->b_nwindows > 0) |
1894 win_enter(wp, TRUE); | |
1895 else | |
1896 { | |
1897 /* | |
1898 * Split off help window; put it at far top if no position | |
1899 * specified, the current window is vertically split and narrow. | |
1900 */ | |
1822 | 1901 flags = WSP_HELP; |
9 | 1902 if (cmdmod.split == 0 && curwin->w_width != Columns |
1903 && curwin->w_width < 80) | |
1822 | 1904 flags |= WSP_TOP; |
1905 if (qi != &ql_info) | |
1906 flags |= WSP_NEWLOC; /* don't copy the location list */ | |
1907 | |
1908 if (win_split(0, flags) == FAIL) | |
9 | 1909 goto theend; |
26 | 1910 opened_window = TRUE; /* close it when fail */ |
9 | 1911 |
1912 if (curwin->w_height < p_hh) | |
1913 win_setheight((int)p_hh); | |
659 | 1914 |
1915 if (qi != &ql_info) /* not a quickfix list */ | |
1916 { | |
1917 /* The new window should use the supplied location list */ | |
1918 curwin->w_llist = qi; | |
1919 qi->qf_refcount++; | |
1920 } | |
9 | 1921 } |
1922 | |
1923 if (!p_im) | |
1924 restart_edit = 0; /* don't want insert mode in help file */ | |
1925 } | |
1926 | |
1927 /* | |
7 | 1928 * If currently in the quickfix window, find another window to show the |
1929 * file in. | |
1930 */ | |
26 | 1931 if (bt_quickfix(curbuf) && !opened_window) |
7 | 1932 { |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1933 win_T *usable_win_ptr = NULL; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1934 |
7 | 1935 /* |
1936 * If there is no file specified, we don't know where to go. | |
1937 * But do advance, otherwise ":cn" gets stuck. | |
1938 */ | |
1939 if (qf_ptr->qf_fnum == 0) | |
1940 goto theend; | |
1941 | |
644 | 1942 usable_win = 0; |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1943 |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1944 ll_ref = curwin->w_llist_ref; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1945 if (ll_ref != NULL) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1946 { |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1947 /* Find a window using the same location list that is not a |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1948 * quickfix window. */ |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1949 FOR_ALL_WINDOWS(usable_win_ptr) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1950 if (usable_win_ptr->w_llist == ll_ref |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1951 && usable_win_ptr->w_buffer->b_p_bt[0] != 'q') |
5084
14e7a115d54d
updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents:
5062
diff
changeset
|
1952 { |
14e7a115d54d
updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents:
5062
diff
changeset
|
1953 usable_win = 1; |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1954 break; |
5084
14e7a115d54d
updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents:
5062
diff
changeset
|
1955 } |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1956 } |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1957 |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1958 if (!usable_win) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1959 { |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1960 /* Locate a window showing a normal buffer */ |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1961 FOR_ALL_WINDOWS(win) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1962 if (win->w_buffer->b_p_bt[0] == NUL) |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1963 { |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1964 usable_win = 1; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1965 break; |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1966 } |
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
1967 } |
644 | 1968 |
7 | 1969 /* |
1621 | 1970 * If no usable window is found and 'switchbuf' contains "usetab" |
1020 | 1971 * then search in other tabs. |
7 | 1972 */ |
1621 | 1973 if (!usable_win && (swb_flags & SWB_USETAB)) |
1020 | 1974 { |
1975 tabpage_T *tp; | |
1976 win_T *wp; | |
1977 | |
1978 FOR_ALL_TAB_WINDOWS(tp, wp) | |
1979 { | |
1980 if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum) | |
1981 { | |
1982 goto_tabpage_win(tp, wp); | |
1983 usable_win = 1; | |
1819 | 1984 goto win_found; |
1020 | 1985 } |
1986 } | |
1987 } | |
1819 | 1988 win_found: |
1020 | 1989 |
1990 /* | |
1396 | 1991 * If there is only one window and it is the quickfix window, create a |
1992 * new one above the quickfix window. | |
1020 | 1993 */ |
1994 if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win) | |
7 | 1995 { |
1822 | 1996 flags = WSP_ABOVE; |
1997 if (ll_ref != NULL) | |
1998 flags |= WSP_NEWLOC; | |
1999 if (win_split(0, flags) == FAIL) | |
7 | 2000 goto failed; /* not enough room for window */ |
2001 opened_window = TRUE; /* close it when fail */ | |
2002 p_swb = empty_option; /* don't split again */ | |
1621 | 2003 swb_flags = 0; |
2583 | 2004 RESET_BINDING(curwin); |
644 | 2005 if (ll_ref != NULL) |
2006 { | |
2007 /* The new window should use the location list from the | |
2008 * location list window */ | |
2009 curwin->w_llist = ll_ref; | |
2010 ll_ref->qf_refcount++; | |
2011 } | |
7 | 2012 } |
2013 else | |
2014 { | |
644 | 2015 if (curwin->w_llist_ref != NULL) |
2016 { | |
2017 /* In a location window */ | |
5062
761cef8f5d1d
updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents:
5060
diff
changeset
|
2018 win = usable_win_ptr; |
644 | 2019 if (win == NULL) |
2020 { | |
2021 /* Find the window showing the selected file */ | |
2022 FOR_ALL_WINDOWS(win) | |
2023 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum) | |
2024 break; | |
2025 if (win == NULL) | |
2026 { | |
2027 /* Find a previous usable window */ | |
2028 win = curwin; | |
2029 do | |
2030 { | |
2031 if (win->w_buffer->b_p_bt[0] == NUL) | |
2032 break; | |
2033 if (win->w_prev == NULL) | |
2034 win = lastwin; /* wrap around the top */ | |
2035 else | |
2036 win = win->w_prev; /* go to previous window */ | |
2037 } while (win != curwin); | |
2038 } | |
2039 } | |
2040 win_goto(win); | |
2041 | |
2042 /* If the location list for the window is not set, then set it | |
2043 * to the location list from the location window */ | |
2044 if (win->w_llist == NULL) | |
2045 { | |
2046 win->w_llist = ll_ref; | |
2047 ll_ref->qf_refcount++; | |
2048 } | |
2049 } | |
2050 else | |
2051 { | |
2052 | |
7 | 2053 /* |
2054 * Try to find a window that shows the right buffer. | |
2055 * Default to the window just above the quickfix buffer. | |
2056 */ | |
2057 win = curwin; | |
2058 altwin = NULL; | |
2059 for (;;) | |
2060 { | |
2061 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum) | |
2062 break; | |
2063 if (win->w_prev == NULL) | |
2064 win = lastwin; /* wrap around the top */ | |
2065 else | |
2066 win = win->w_prev; /* go to previous window */ | |
2067 | |
644 | 2068 if (IS_QF_WINDOW(win)) |
7 | 2069 { |
2070 /* Didn't find it, go to the window before the quickfix | |
2071 * window. */ | |
2072 if (altwin != NULL) | |
2073 win = altwin; | |
2074 else if (curwin->w_prev != NULL) | |
2075 win = curwin->w_prev; | |
2076 else | |
2077 win = curwin->w_next; | |
2078 break; | |
2079 } | |
2080 | |
2081 /* Remember a usable window. */ | |
2082 if (altwin == NULL && !win->w_p_pvw | |
2083 && win->w_buffer->b_p_bt[0] == NUL) | |
2084 altwin = win; | |
2085 } | |
2086 | |
2087 win_goto(win); | |
644 | 2088 } |
7 | 2089 } |
2090 } | |
2091 #endif | |
2092 | |
2093 /* | |
2094 * If there is a file name, | |
2095 * read the wanted file if needed, and check autowrite etc. | |
2096 */ | |
2097 old_curbuf = curbuf; | |
2098 old_lnum = curwin->w_cursor.lnum; | |
9 | 2099 |
2100 if (qf_ptr->qf_fnum != 0) | |
2101 { | |
2102 if (qf_ptr->qf_type == 1) | |
2103 { | |
2104 /* Open help file (do_ecmd() will set b_help flag, readfile() will | |
2105 * set b_p_ro flag). */ | |
2106 if (!can_abandon(curbuf, forceit)) | |
2107 { | |
2108 EMSG(_(e_nowrtmsg)); | |
2109 ok = FALSE; | |
2110 } | |
2111 else | |
2112 ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, | |
1743 | 2113 ECMD_HIDE + ECMD_SET_HELP, |
2114 oldwin == curwin ? curwin : NULL); | |
9 | 2115 } |
2116 else | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2117 { |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2118 int old_qf_curlist = qi->qf_curlist; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2119 int is_abort = FALSE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2120 |
9 | 2121 ok = buflist_getfile(qf_ptr->qf_fnum, |
2122 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2123 if (qi != &ql_info && !win_valid(oldwin)) |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2124 { |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2125 EMSG(_("E924: Current window was closed")); |
8702
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2126 is_abort = TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2127 opened_window = FALSE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2128 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2129 else if (old_qf_curlist != qi->qf_curlist |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2130 || !is_qf_entry_present(qi, qf_ptr)) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2131 { |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2132 if (qi == &ql_info) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2133 EMSG(_("E925: Current quickfix was changed")); |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2134 else |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2135 EMSG(_("E926: Current location list was changed")); |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2136 is_abort = TRUE; |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2137 } |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2138 |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2139 if (is_abort) |
39d6e4f2f748
commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
2140 { |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2141 ok = FALSE; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2142 qi = NULL; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2143 qf_ptr = NULL; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2144 } |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2145 } |
9 | 2146 } |
2147 | |
2148 if (ok == OK) | |
7 | 2149 { |
2150 /* When not switched to another buffer, still need to set pc mark */ | |
2151 if (curbuf == old_curbuf) | |
2152 setpcmark(); | |
2153 | |
230 | 2154 if (qf_ptr->qf_pattern == NULL) |
7 | 2155 { |
230 | 2156 /* |
2157 * Go to line with error, unless qf_lnum is 0. | |
2158 */ | |
2159 i = qf_ptr->qf_lnum; | |
2160 if (i > 0) | |
2161 { | |
2162 if (i > curbuf->b_ml.ml_line_count) | |
2163 i = curbuf->b_ml.ml_line_count; | |
2164 curwin->w_cursor.lnum = i; | |
2165 } | |
2166 if (qf_ptr->qf_col > 0) | |
7 | 2167 { |
230 | 2168 curwin->w_cursor.col = qf_ptr->qf_col - 1; |
6853 | 2169 #ifdef FEAT_VIRTUALEDIT |
2170 curwin->w_cursor.coladd = 0; | |
2171 #endif | |
230 | 2172 if (qf_ptr->qf_viscol == TRUE) |
7 | 2173 { |
230 | 2174 /* |
2175 * Check each character from the beginning of the error | |
2176 * line up to the error column. For each tab character | |
2177 * found, reduce the error column value by the length of | |
2178 * a tab character. | |
2179 */ | |
2180 line = ml_get_curline(); | |
2181 screen_col = 0; | |
2182 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) | |
7 | 2183 { |
230 | 2184 if (*line == NUL) |
2185 break; | |
2186 if (*line++ == '\t') | |
2187 { | |
2188 curwin->w_cursor.col -= 7 - (screen_col % 8); | |
2189 screen_col += 8 - (screen_col % 8); | |
2190 } | |
2191 else | |
2192 ++screen_col; | |
7 | 2193 } |
2194 } | |
230 | 2195 check_cursor(); |
7 | 2196 } |
230 | 2197 else |
2198 beginline(BL_WHITE | BL_FIX); | |
7 | 2199 } |
2200 else | |
230 | 2201 { |
2202 pos_T save_cursor; | |
2203 | |
2204 /* Move the cursor to the first line in the buffer */ | |
2205 save_cursor = curwin->w_cursor; | |
2206 curwin->w_cursor.lnum = 0; | |
1521 | 2207 if (!do_search(NULL, '/', qf_ptr->qf_pattern, (long)1, |
2208 SEARCH_KEEP, NULL)) | |
230 | 2209 curwin->w_cursor = save_cursor; |
2210 } | |
7 | 2211 |
2212 #ifdef FEAT_FOLDING | |
2213 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped) | |
2214 foldOpenCursor(); | |
2215 #endif | |
2216 if (print_message) | |
2217 { | |
3267 | 2218 /* Update the screen before showing the message, unless the screen |
2219 * scrolled up. */ | |
2220 if (!msg_scrolled) | |
2221 update_topline_redraw(); | |
7 | 2222 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index, |
644 | 2223 qi->qf_lists[qi->qf_curlist].qf_count, |
7 | 2224 qf_ptr->qf_cleared ? _(" (line deleted)") : "", |
2225 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr)); | |
2226 /* Add the message, skipping leading whitespace and newlines. */ | |
2227 len = (int)STRLEN(IObuff); | |
2228 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len); | |
2229 | |
2230 /* Output the message. Overwrite to avoid scrolling when the 'O' | |
2231 * flag is present in 'shortmess'; But when not jumping, print the | |
2232 * whole message. */ | |
2233 i = msg_scroll; | |
2234 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum) | |
2235 msg_scroll = TRUE; | |
2236 else if (!msg_scrolled && shortmess(SHM_OVERALL)) | |
2237 msg_scroll = FALSE; | |
2238 msg_attr_keep(IObuff, 0, TRUE); | |
2239 msg_scroll = i; | |
2240 } | |
2241 } | |
2242 else | |
2243 { | |
2244 #ifdef FEAT_WINDOWS | |
2245 if (opened_window) | |
2246 win_close(curwin, TRUE); /* Close opened window */ | |
2247 #endif | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2248 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) |
7 | 2249 { |
2250 /* | |
2251 * Couldn't open file, so put index back where it was. This could | |
2252 * happen if the file was readonly and we changed something. | |
2253 */ | |
2254 #ifdef FEAT_WINDOWS | |
2255 failed: | |
2256 #endif | |
2257 qf_ptr = old_qf_ptr; | |
2258 qf_index = old_qf_index; | |
2259 } | |
2260 } | |
2261 theend: | |
8605
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2262 if (qi != NULL) |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2263 { |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2264 qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2265 qi->qf_lists[qi->qf_curlist].qf_index = qf_index; |
536b9b88d1ca
commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents:
8603
diff
changeset
|
2266 } |
7 | 2267 #ifdef FEAT_WINDOWS |
2268 if (p_swb != old_swb && opened_window) | |
2269 { | |
2270 /* Restore old 'switchbuf' value, but not when an autocommand or | |
2271 * modeline has changed the value. */ | |
2272 if (p_swb == empty_option) | |
1621 | 2273 { |
7 | 2274 p_swb = old_swb; |
1621 | 2275 swb_flags = old_swb_flags; |
2276 } | |
7 | 2277 else |
2278 free_string_option(old_swb); | |
2279 } | |
2280 #endif | |
2281 } | |
2282 | |
2283 /* | |
2284 * ":clist": list all errors | |
644 | 2285 * ":llist": list all locations |
7 | 2286 */ |
2287 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2288 qf_list(exarg_T *eap) |
7 | 2289 { |
230 | 2290 buf_T *buf; |
2291 char_u *fname; | |
2292 qfline_T *qfp; | |
2293 int i; | |
2294 int idx1 = 1; | |
2295 int idx2 = -1; | |
2296 char_u *arg = eap->arg; | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2297 int plus = FALSE; |
230 | 2298 int all = eap->forceit; /* if not :cl!, only show |
7 | 2299 recognised errors */ |
644 | 2300 qf_info_T *qi = &ql_info; |
2301 | |
2302 if (eap->cmdidx == CMD_llist) | |
2303 { | |
2304 qi = GET_LOC_LIST(curwin); | |
2305 if (qi == NULL) | |
2306 { | |
2307 EMSG(_(e_loclist)); | |
2308 return; | |
2309 } | |
2310 } | |
2311 | |
2312 if (qi->qf_curlist >= qi->qf_listcount | |
2313 || qi->qf_lists[qi->qf_curlist].qf_count == 0) | |
7 | 2314 { |
2315 EMSG(_(e_quickfix)); | |
2316 return; | |
2317 } | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2318 if (*arg == '+') |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2319 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2320 ++arg; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2321 plus = TRUE; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2322 } |
7 | 2323 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) |
2324 { | |
2325 EMSG(_(e_trailing)); | |
2326 return; | |
2327 } | |
9379
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2328 if (plus) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2329 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2330 i = qi->qf_lists[qi->qf_curlist].qf_index; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2331 idx2 = i + idx1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2332 idx1 = i; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2333 } |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2334 else |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2335 { |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2336 i = qi->qf_lists[qi->qf_curlist].qf_count; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2337 if (idx1 < 0) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2338 idx1 = (-idx1 > i) ? 0 : idx1 + i + 1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2339 if (idx2 < 0) |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2340 idx2 = (-idx2 > i) ? 0 : idx2 + i + 1; |
b398e4e12751
commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents:
9369
diff
changeset
|
2341 } |
7 | 2342 |
644 | 2343 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid) |
7 | 2344 all = TRUE; |
644 | 2345 qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
2346 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ) | |
7 | 2347 { |
2348 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2) | |
2349 { | |
2047
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2350 msg_putchar('\n'); |
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2351 if (got_int) |
85da03763130
updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
2352 break; |
446 | 2353 |
2354 fname = NULL; | |
2355 if (qfp->qf_fnum != 0 | |
7 | 2356 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) |
446 | 2357 { |
2358 fname = buf->b_fname; | |
2359 if (qfp->qf_type == 1) /* :helpgrep */ | |
2360 fname = gettail(fname); | |
2361 } | |
2362 if (fname == NULL) | |
2363 sprintf((char *)IObuff, "%2d", i); | |
2364 else | |
2365 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", | |
273 | 2366 i, (char *)fname); |
644 | 2367 msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index |
446 | 2368 ? hl_attr(HLF_L) : hl_attr(HLF_D)); |
2369 if (qfp->qf_lnum == 0) | |
2370 IObuff[0] = NUL; | |
2371 else if (qfp->qf_col == 0) | |
2372 sprintf((char *)IObuff, ":%ld", qfp->qf_lnum); | |
2373 else | |
2374 sprintf((char *)IObuff, ":%ld col %d", | |
7 | 2375 qfp->qf_lnum, qfp->qf_col); |
446 | 2376 sprintf((char *)IObuff + STRLEN(IObuff), "%s:", |
7 | 2377 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); |
446 | 2378 msg_puts_attr(IObuff, hl_attr(HLF_N)); |
2379 if (qfp->qf_pattern != NULL) | |
2380 { | |
2381 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE); | |
2382 STRCAT(IObuff, ":"); | |
2383 msg_puts(IObuff); | |
2384 } | |
2385 msg_puts((char_u *)" "); | |
230 | 2386 |
446 | 2387 /* Remove newlines and leading whitespace from the text. For an |
2388 * unrecognized line keep the indent, the compiler may mark a word | |
2389 * with ^^^^. */ | |
2390 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0) | |
7 | 2391 ? skipwhite(qfp->qf_text) : qfp->qf_text, |
2392 IObuff, IOSIZE); | |
446 | 2393 msg_prt_line(IObuff, FALSE); |
2394 out_flush(); /* show one line at a time */ | |
7 | 2395 } |
446 | 2396 |
2397 qfp = qfp->qf_next; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2398 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2399 break; |
446 | 2400 ++i; |
7 | 2401 ui_breakcheck(); |
2402 } | |
2403 } | |
2404 | |
2405 /* | |
2406 * Remove newlines and leading whitespace from an error message. | |
2407 * Put the result in "buf[bufsize]". | |
2408 */ | |
2409 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2410 qf_fmt_text(char_u *text, char_u *buf, int bufsize) |
7 | 2411 { |
2412 int i; | |
2413 char_u *p = text; | |
2414 | |
2415 for (i = 0; *p != NUL && i < bufsize - 1; ++i) | |
2416 { | |
2417 if (*p == '\n') | |
2418 { | |
2419 buf[i] = ' '; | |
2420 while (*++p != NUL) | |
2421 if (!vim_iswhite(*p) && *p != '\n') | |
2422 break; | |
2423 } | |
2424 else | |
2425 buf[i] = *p++; | |
2426 } | |
2427 buf[i] = NUL; | |
2428 } | |
2429 | |
2430 /* | |
2431 * ":colder [count]": Up in the quickfix stack. | |
2432 * ":cnewer [count]": Down in the quickfix stack. | |
644 | 2433 * ":lolder [count]": Up in the location list stack. |
2434 * ":lnewer [count]": Down in the location list stack. | |
7 | 2435 */ |
2436 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2437 qf_age(exarg_T *eap) |
7 | 2438 { |
644 | 2439 qf_info_T *qi = &ql_info; |
7 | 2440 int count; |
2441 | |
644 | 2442 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer) |
2443 { | |
2444 qi = GET_LOC_LIST(curwin); | |
2445 if (qi == NULL) | |
2446 { | |
2447 EMSG(_(e_loclist)); | |
2448 return; | |
2449 } | |
2450 } | |
2451 | |
7 | 2452 if (eap->addr_count != 0) |
2453 count = eap->line2; | |
2454 else | |
2455 count = 1; | |
2456 while (count--) | |
2457 { | |
644 | 2458 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder) |
7 | 2459 { |
644 | 2460 if (qi->qf_curlist == 0) |
7 | 2461 { |
2462 EMSG(_("E380: At bottom of quickfix stack")); | |
4371 | 2463 break; |
7 | 2464 } |
644 | 2465 --qi->qf_curlist; |
7 | 2466 } |
2467 else | |
2468 { | |
644 | 2469 if (qi->qf_curlist >= qi->qf_listcount - 1) |
7 | 2470 { |
2471 EMSG(_("E381: At top of quickfix stack")); | |
4371 | 2472 break; |
7 | 2473 } |
644 | 2474 ++qi->qf_curlist; |
7 | 2475 } |
2476 } | |
644 | 2477 qf_msg(qi); |
7 | 2478 } |
2479 | |
2480 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2481 qf_msg(qf_info_T *qi) |
7 | 2482 { |
2483 smsg((char_u *)_("error list %d of %d; %d errors"), | |
644 | 2484 qi->qf_curlist + 1, qi->qf_listcount, |
2485 qi->qf_lists[qi->qf_curlist].qf_count); | |
7 | 2486 #ifdef FEAT_WINDOWS |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2487 qf_update_buffer(qi, NULL); |
7 | 2488 #endif |
2489 } | |
2490 | |
2491 /* | |
581 | 2492 * Free error list "idx". |
7 | 2493 */ |
2494 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2495 qf_free(qf_info_T *qi, int idx) |
7 | 2496 { |
230 | 2497 qfline_T *qfp; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2498 qfline_T *qfpnext; |
3982 | 2499 int stop = FALSE; |
7 | 2500 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2501 while (qi->qf_lists[idx].qf_count && qi->qf_lists[idx].qf_start != NULL) |
7 | 2502 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2503 qfp = qi->qf_lists[idx].qf_start; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2504 qfpnext = qfp->qf_next; |
3982 | 2505 if (qi->qf_lists[idx].qf_title != NULL && !stop) |
3949 | 2506 { |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2507 vim_free(qfp->qf_text); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2508 stop = (qfp == qfpnext); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2509 vim_free(qfp->qf_pattern); |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2510 vim_free(qfp); |
3982 | 2511 if (stop) |
2512 /* Somehow qf_count may have an incorrect value, set it to 1 | |
2513 * to avoid crashing when it's wrong. | |
2514 * TODO: Avoid qf_count being incorrect. */ | |
2515 qi->qf_lists[idx].qf_count = 1; | |
3949 | 2516 } |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2517 qi->qf_lists[idx].qf_start = qfpnext; |
644 | 2518 --qi->qf_lists[idx].qf_count; |
7 | 2519 } |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
2520 vim_free(qi->qf_lists[idx].qf_title); |
2576 | 2521 qi->qf_lists[idx].qf_title = NULL; |
6081 | 2522 qi->qf_lists[idx].qf_index = 0; |
9397
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
2523 |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
2524 qf_clean_dir_stack(&qi->qf_dir_stack); |
e08e8b00fe48
commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
2525 qf_clean_dir_stack(&qi->qf_file_stack); |
7 | 2526 } |
2527 | |
2528 /* | |
2529 * qf_mark_adjust: adjust marks | |
2530 */ | |
2531 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2532 qf_mark_adjust( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2533 win_T *wp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2534 linenr_T line1, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2535 linenr_T line2, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2536 long amount, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2537 long amount_after) |
7 | 2538 { |
230 | 2539 int i; |
2540 qfline_T *qfp; | |
2541 int idx; | |
644 | 2542 qf_info_T *qi = &ql_info; |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2543 int found_one = FALSE; |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2544 |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2545 if (!curbuf->b_has_qf_entry) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2546 return; |
644 | 2547 if (wp != NULL) |
2548 { | |
2549 if (wp->w_llist == NULL) | |
2550 return; | |
2551 qi = wp->w_llist; | |
2552 } | |
2553 | |
2554 for (idx = 0; idx < qi->qf_listcount; ++idx) | |
2555 if (qi->qf_lists[idx].qf_count) | |
2556 for (i = 0, qfp = qi->qf_lists[idx].qf_start; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2557 i < qi->qf_lists[idx].qf_count && qfp != NULL; |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
2558 ++i, qfp = qfp->qf_next) |
7 | 2559 if (qfp->qf_fnum == curbuf->b_fnum) |
2560 { | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2561 found_one = TRUE; |
7 | 2562 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2) |
2563 { | |
2564 if (amount == MAXLNUM) | |
2565 qfp->qf_cleared = TRUE; | |
2566 else | |
2567 qfp->qf_lnum += amount; | |
2568 } | |
2569 else if (amount_after && qfp->qf_lnum > line2) | |
2570 qfp->qf_lnum += amount_after; | |
2571 } | |
9201
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2572 |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2573 if (!found_one) |
692e156c7023
commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents:
9197
diff
changeset
|
2574 curbuf->b_has_qf_entry = FALSE; |
7 | 2575 } |
2576 | |
2577 /* | |
2578 * Make a nice message out of the error character and the error number: | |
2579 * char number message | |
2580 * e or E 0 " error" | |
2581 * w or W 0 " warning" | |
2582 * i or I 0 " info" | |
2583 * 0 0 "" | |
2584 * other 0 " c" | |
2585 * e or E n " error n" | |
2586 * w or W n " warning n" | |
2587 * i or I n " info n" | |
2588 * 0 n " error n" | |
2589 * other n " c n" | |
2590 * 1 x "" :helpgrep | |
2591 */ | |
2592 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2593 qf_types(int c, int nr) |
7 | 2594 { |
2595 static char_u buf[20]; | |
2596 static char_u cc[3]; | |
2597 char_u *p; | |
2598 | |
2599 if (c == 'W' || c == 'w') | |
2600 p = (char_u *)" warning"; | |
2601 else if (c == 'I' || c == 'i') | |
2602 p = (char_u *)" info"; | |
2603 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0)) | |
2604 p = (char_u *)" error"; | |
2605 else if (c == 0 || c == 1) | |
2606 p = (char_u *)""; | |
2607 else | |
2608 { | |
2609 cc[0] = ' '; | |
2610 cc[1] = c; | |
2611 cc[2] = NUL; | |
2612 p = cc; | |
2613 } | |
2614 | |
2615 if (nr <= 0) | |
2616 return p; | |
2617 | |
2618 sprintf((char *)buf, "%s %3d", (char *)p, nr); | |
2619 return buf; | |
2620 } | |
2621 | |
2622 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
2623 /* | |
2624 * ":cwindow": open the quickfix window if we have errors to display, | |
2625 * close it if not. | |
644 | 2626 * ":lwindow": open the location list window if we have locations to display, |
2627 * close it if not. | |
7 | 2628 */ |
2629 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2630 ex_cwindow(exarg_T *eap) |
7 | 2631 { |
644 | 2632 qf_info_T *qi = &ql_info; |
7 | 2633 win_T *win; |
2634 | |
644 | 2635 if (eap->cmdidx == CMD_lwindow) |
2636 { | |
2637 qi = GET_LOC_LIST(curwin); | |
2638 if (qi == NULL) | |
2639 return; | |
2640 } | |
2641 | |
2642 /* Look for an existing quickfix window. */ | |
2643 win = qf_find_win(qi); | |
7 | 2644 |
2645 /* | |
2646 * If a quickfix window is open but we have no errors to display, | |
2647 * close the window. If a quickfix window is not open, then open | |
2648 * it if we have errors; otherwise, leave it closed. | |
2649 */ | |
644 | 2650 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid |
2795 | 2651 || qi->qf_lists[qi->qf_curlist].qf_count == 0 |
857 | 2652 || qi->qf_curlist >= qi->qf_listcount) |
7 | 2653 { |
2654 if (win != NULL) | |
2655 ex_cclose(eap); | |
2656 } | |
2657 else if (win == NULL) | |
2658 ex_copen(eap); | |
2659 } | |
2660 | |
2661 /* | |
2662 * ":cclose": close the window showing the list of errors. | |
644 | 2663 * ":lclose": close the window showing the location list |
7 | 2664 */ |
2665 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2666 ex_cclose(exarg_T *eap) |
7 | 2667 { |
644 | 2668 win_T *win = NULL; |
2669 qf_info_T *qi = &ql_info; | |
2670 | |
2671 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow) | |
2672 { | |
2673 qi = GET_LOC_LIST(curwin); | |
2674 if (qi == NULL) | |
2675 return; | |
2676 } | |
2677 | |
2678 /* Find existing quickfix window and close it. */ | |
2679 win = qf_find_win(qi); | |
7 | 2680 if (win != NULL) |
2681 win_close(win, FALSE); | |
2682 } | |
2683 | |
2684 /* | |
2685 * ":copen": open a window that shows the list of errors. | |
644 | 2686 * ":lopen": open a window that shows the location list. |
7 | 2687 */ |
2688 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2689 ex_copen(exarg_T *eap) |
7 | 2690 { |
644 | 2691 qf_info_T *qi = &ql_info; |
7 | 2692 int height; |
2693 win_T *win; | |
682 | 2694 tabpage_T *prevtab = curtab; |
859 | 2695 buf_T *qf_buf; |
1743 | 2696 win_T *oldwin = curwin; |
7 | 2697 |
644 | 2698 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
2699 { | |
2700 qi = GET_LOC_LIST(curwin); | |
2701 if (qi == NULL) | |
2702 { | |
2703 EMSG(_(e_loclist)); | |
2704 return; | |
2705 } | |
2706 } | |
2707 | |
7 | 2708 if (eap->addr_count != 0) |
2709 height = eap->line2; | |
2710 else | |
2711 height = QF_WINHEIGHT; | |
2712 | |
2713 reset_VIsual_and_resel(); /* stop Visual mode */ | |
2714 #ifdef FEAT_GUI | |
2715 need_mouse_correct = TRUE; | |
2716 #endif | |
2717 | |
2718 /* | |
2719 * Find existing quickfix window, or open a new one. | |
2720 */ | |
644 | 2721 win = qf_find_win(qi); |
2722 | |
682 | 2723 if (win != NULL && cmdmod.tab == 0) |
5753 | 2724 { |
7 | 2725 win_goto(win); |
5753 | 2726 if (eap->addr_count != 0) |
2727 { | |
2728 if (cmdmod.split & WSP_VERT) | |
2729 { | |
2730 if (height != W_WIDTH(win)) | |
2731 win_setwidth(height); | |
2732 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8605
diff
changeset
|
2733 else if (height != win->w_height) |
5753 | 2734 win_setheight(height); |
2735 } | |
2736 } | |
7 | 2737 else |
2738 { | |
859 | 2739 qf_buf = qf_find_buf(qi); |
2740 | |
7 | 2741 /* The current window becomes the previous window afterwards. */ |
2742 win = curwin; | |
2743 | |
3939 | 2744 if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow) |
2745 && cmdmod.split == 0) | |
2746 /* Create the new window at the very bottom, except when | |
2747 * :belowright or :aboveleft is used. */ | |
644 | 2748 win_goto(lastwin); |
1822 | 2749 if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL) |
7 | 2750 return; /* not enough room for window */ |
2583 | 2751 RESET_BINDING(curwin); |
7 | 2752 |
644 | 2753 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
7 | 2754 { |
644 | 2755 /* |
2756 * For the location list window, create a reference to the | |
2757 * location list from the window 'win'. | |
2758 */ | |
2759 curwin->w_llist_ref = win->w_llist; | |
2760 win->w_llist->qf_refcount++; | |
7 | 2761 } |
644 | 2762 |
1743 | 2763 if (oldwin != curwin) |
2764 oldwin = NULL; /* don't store info when in another window */ | |
859 | 2765 if (qf_buf != NULL) |
2766 /* Use the existing quickfix buffer */ | |
2767 (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, | |
1743 | 2768 ECMD_HIDE + ECMD_OLDBUF, oldwin); |
859 | 2769 else |
2770 { | |
2771 /* Create a new quickfix buffer */ | |
1743 | 2772 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin); |
859 | 2773 /* switch off 'swapfile' */ |
2774 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); | |
2775 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", | |
729 | 2776 OPT_LOCAL); |
859 | 2777 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); |
2651 | 2778 RESET_BINDING(curwin); |
1864 | 2779 #ifdef FEAT_DIFF |
2780 curwin->w_p_diff = FALSE; | |
2781 #endif | |
2782 #ifdef FEAT_FOLDING | |
2783 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual", | |
2784 OPT_LOCAL); | |
2785 #endif | |
859 | 2786 } |
7 | 2787 |
682 | 2788 /* Only set the height when still in the same tab page and there is no |
2789 * window to the side. */ | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8605
diff
changeset
|
2790 if (curtab == prevtab && curwin->w_width == Columns) |
7 | 2791 win_setheight(height); |
2792 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */ | |
2793 if (win_valid(win)) | |
2794 prevwin = win; | |
2795 } | |
2796 | |
6793 | 2797 qf_set_title_var(qi); |
2798 | |
7 | 2799 /* |
2800 * Fill the buffer with the quickfix list. | |
2801 */ | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2802 qf_fill_buffer(qi, curbuf, NULL); |
644 | 2803 |
2804 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; | |
7 | 2805 curwin->w_cursor.col = 0; |
2806 check_cursor(); | |
2807 update_topline(); /* scroll to show the line */ | |
2808 } | |
2809 | |
2810 /* | |
2811 * Return the number of the current entry (line number in the quickfix | |
2812 * window). | |
2813 */ | |
2814 linenr_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2815 qf_current_entry(win_T *wp) |
7 | 2816 { |
644 | 2817 qf_info_T *qi = &ql_info; |
2818 | |
2819 if (IS_LL_WINDOW(wp)) | |
2820 /* In the location list window, use the referenced location list */ | |
2821 qi = wp->w_llist_ref; | |
2822 | |
2823 return qi->qf_lists[qi->qf_curlist].qf_index; | |
7 | 2824 } |
2825 | |
2826 /* | |
2827 * Update the cursor position in the quickfix window to the current error. | |
2828 * Return TRUE if there is a quickfix window. | |
2829 */ | |
2830 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2831 qf_win_pos_update( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2832 qf_info_T *qi, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2833 int old_qf_index) /* previous qf_index or zero */ |
7 | 2834 { |
2835 win_T *win; | |
644 | 2836 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
7 | 2837 |
2838 /* | |
2839 * Put the cursor on the current error in the quickfix window, so that | |
2840 * it's viewable. | |
2841 */ | |
644 | 2842 win = qf_find_win(qi); |
7 | 2843 if (win != NULL |
2844 && qf_index <= win->w_buffer->b_ml.ml_line_count | |
2845 && old_qf_index != qf_index) | |
2846 { | |
2847 win_T *old_curwin = curwin; | |
2848 | |
2849 curwin = win; | |
2850 curbuf = win->w_buffer; | |
2851 if (qf_index > old_qf_index) | |
2852 { | |
2853 curwin->w_redraw_top = old_qf_index; | |
2854 curwin->w_redraw_bot = qf_index; | |
2855 } | |
2856 else | |
2857 { | |
2858 curwin->w_redraw_top = qf_index; | |
2859 curwin->w_redraw_bot = old_qf_index; | |
2860 } | |
2861 curwin->w_cursor.lnum = qf_index; | |
2862 curwin->w_cursor.col = 0; | |
2863 update_topline(); /* scroll to show the line */ | |
2864 redraw_later(VALID); | |
2865 curwin->w_redr_status = TRUE; /* update ruler */ | |
2866 curwin = old_curwin; | |
2867 curbuf = curwin->w_buffer; | |
2868 } | |
2869 return win != NULL; | |
2870 } | |
2871 | |
2872 /* | |
859 | 2873 * Check whether the given window is displaying the specified quickfix/location |
2874 * list buffer | |
2875 */ | |
2876 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2877 is_qf_win(win_T *win, qf_info_T *qi) |
859 | 2878 { |
2879 /* | |
2880 * A window displaying the quickfix buffer will have the w_llist_ref field | |
2881 * set to NULL. | |
2882 * A window displaying a location list buffer will have the w_llist_ref | |
2883 * pointing to the location list. | |
2884 */ | |
2885 if (bt_quickfix(win->w_buffer)) | |
2886 if ((qi == &ql_info && win->w_llist_ref == NULL) | |
2887 || (qi != &ql_info && win->w_llist_ref == qi)) | |
2888 return TRUE; | |
2889 | |
2890 return FALSE; | |
2891 } | |
2892 | |
2893 /* | |
644 | 2894 * Find a window displaying the quickfix/location list 'qi' |
859 | 2895 * Searches in only the windows opened in the current tab. |
644 | 2896 */ |
2897 static win_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2898 qf_find_win(qf_info_T *qi) |
644 | 2899 { |
2900 win_T *win; | |
2901 | |
2902 FOR_ALL_WINDOWS(win) | |
859 | 2903 if (is_qf_win(win, qi)) |
2904 break; | |
644 | 2905 |
2906 return win; | |
2907 } | |
2908 | |
2909 /* | |
859 | 2910 * Find a quickfix buffer. |
2911 * Searches in windows opened in all the tabs. | |
7 | 2912 */ |
2913 static buf_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2914 qf_find_buf(qf_info_T *qi) |
7 | 2915 { |
859 | 2916 tabpage_T *tp; |
644 | 2917 win_T *win; |
2918 | |
859 | 2919 FOR_ALL_TAB_WINDOWS(tp, win) |
2920 if (is_qf_win(win, qi)) | |
2921 return win->w_buffer; | |
2922 | |
2923 return NULL; | |
7 | 2924 } |
2925 | |
2926 /* | |
2927 * Find the quickfix buffer. If it exists, update the contents. | |
2928 */ | |
2929 static void | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2930 qf_update_buffer(qf_info_T *qi, qfline_T *old_last) |
7 | 2931 { |
2932 buf_T *buf; | |
3016 | 2933 win_T *win; |
2934 win_T *curwin_save; | |
7 | 2935 aco_save_T aco; |
2936 | |
2937 /* Check if a buffer for the quickfix list exists. Update it. */ | |
644 | 2938 buf = qf_find_buf(qi); |
7 | 2939 if (buf != NULL) |
2940 { | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2941 linenr_T old_line_count = buf->b_ml.ml_line_count; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2942 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2943 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2944 /* set curwin/curbuf to buf and save a few things */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2945 aucmd_prepbuf(&aco, buf); |
7 | 2946 |
6793 | 2947 if ((win = qf_find_win(qi)) != NULL) |
3016 | 2948 { |
2949 curwin_save = curwin; | |
2950 curwin = win; | |
6079 | 2951 qf_set_title_var(qi); |
3016 | 2952 curwin = curwin_save; |
2953 } | |
2954 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2955 qf_fill_buffer(qi, buf, old_last); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2956 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2957 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2958 { |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
2959 (void)qf_win_pos_update(qi, 0); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2960 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2961 /* restore curwin/curbuf and a few other things */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2962 aucmd_restbuf(&aco); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2963 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2964 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2965 /* Only redraw when added lines are visible. This avoids flickering |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2966 * when the added lines are not visible. */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2967 if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2968 redraw_buf_later(buf, NOT_VALID); |
7 | 2969 } |
2970 } | |
2971 | |
6793 | 2972 /* |
2973 * Set "w:quickfix_title" if "qi" has a title. | |
2974 */ | |
3016 | 2975 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2976 qf_set_title_var(qf_info_T *qi) |
3016 | 2977 { |
6793 | 2978 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) |
2979 set_internal_string_var((char_u *)"w:quickfix_title", | |
3016 | 2980 qi->qf_lists[qi->qf_curlist].qf_title); |
2981 } | |
2982 | |
7 | 2983 /* |
2984 * Fill current buffer with quickfix errors, replacing any previous contents. | |
2985 * curbuf must be the quickfix buffer! | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2986 * If "old_last" is not NULL append the items after this one. |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2987 * When "old_last" is NULL then "buf" must equal "curbuf"! Because |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2988 * ml_delete() is used and autocommands will be triggered. |
7 | 2989 */ |
2990 static void | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2991 qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) |
7 | 2992 { |
230 | 2993 linenr_T lnum; |
2994 qfline_T *qfp; | |
2995 buf_T *errbuf; | |
2996 int len; | |
2997 int old_KeyTyped = KeyTyped; | |
7 | 2998 |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
2999 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3000 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3001 if (buf != curbuf) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3002 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3003 EMSG2(_(e_intern2), "qf_fill_buffer()"); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3004 return; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3005 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3006 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3007 /* delete all existing lines */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3008 while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3009 (void)ml_delete((linenr_T)1, FALSE); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3010 } |
7 | 3011 |
3012 /* Check if there is anything to display */ | |
644 | 3013 if (qi->qf_curlist < qi->qf_listcount) |
7 | 3014 { |
3015 /* Add one line for each error */ | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3016 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3017 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3018 qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3019 lnum = 0; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3020 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3021 else |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3022 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3023 qfp = old_last->qf_next; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3024 lnum = buf->b_ml.ml_line_count; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3025 } |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3026 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count) |
7 | 3027 { |
3028 if (qfp->qf_fnum != 0 | |
3029 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL | |
3030 && errbuf->b_fname != NULL) | |
3031 { | |
3032 if (qfp->qf_type == 1) /* :helpgrep */ | |
3033 STRCPY(IObuff, gettail(errbuf->b_fname)); | |
3034 else | |
3035 STRCPY(IObuff, errbuf->b_fname); | |
3036 len = (int)STRLEN(IObuff); | |
3037 } | |
3038 else | |
3039 len = 0; | |
3040 IObuff[len++] = '|'; | |
3041 | |
3042 if (qfp->qf_lnum > 0) | |
3043 { | |
3044 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum); | |
3045 len += (int)STRLEN(IObuff + len); | |
3046 | |
3047 if (qfp->qf_col > 0) | |
3048 { | |
3049 sprintf((char *)IObuff + len, " col %d", qfp->qf_col); | |
3050 len += (int)STRLEN(IObuff + len); | |
3051 } | |
3052 | |
3053 sprintf((char *)IObuff + len, "%s", | |
3054 (char *)qf_types(qfp->qf_type, qfp->qf_nr)); | |
3055 len += (int)STRLEN(IObuff + len); | |
3056 } | |
230 | 3057 else if (qfp->qf_pattern != NULL) |
3058 { | |
3059 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); | |
3060 len += (int)STRLEN(IObuff + len); | |
3061 } | |
7 | 3062 IObuff[len++] = '|'; |
3063 IObuff[len++] = ' '; | |
3064 | |
3065 /* Remove newlines and leading whitespace from the text. | |
3066 * For an unrecognized line keep the indent, the compiler may | |
3067 * mark a word with ^^^^. */ | |
3068 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, | |
3069 IObuff + len, IOSIZE - len); | |
3070 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3071 if (ml_append_buf(buf, lnum, IObuff, |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3072 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL) |
7 | 3073 break; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3074 ++lnum; |
7 | 3075 qfp = qfp->qf_next; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3076 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3077 break; |
7 | 3078 } |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3079 |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3080 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3081 /* Delete the empty line which is now at the end */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3082 (void)ml_delete(lnum + 1, FALSE); |
7 | 3083 } |
3084 | |
3085 /* correct cursor position */ | |
3086 check_lnums(TRUE); | |
3087 | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3088 if (old_last == NULL) |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3089 { |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3090 /* Set the 'filetype' to "qf" each time after filling the buffer. |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3091 * This resembles reading a file into a buffer, it's more logical when |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3092 * using autocommands. */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3093 set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3094 curbuf->b_p_ma = FALSE; |
7 | 3095 |
3096 #ifdef FEAT_AUTOCMD | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3097 keep_filetype = TRUE; /* don't detect 'filetype' */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3098 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, |
7 | 3099 FALSE, curbuf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3100 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL, |
7 | 3101 FALSE, curbuf); |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3102 keep_filetype = FALSE; |
7 | 3103 #endif |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3104 /* make sure it will be redrawn */ |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3105 redraw_curbuf_later(NOT_VALID); |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
3106 } |
7 | 3107 |
3108 /* Restore KeyTyped, setting 'filetype' may reset it. */ | |
3109 KeyTyped = old_KeyTyped; | |
3110 } | |
3111 | |
3112 #endif /* FEAT_WINDOWS */ | |
3113 | |
3114 /* | |
3115 * Return TRUE if "buf" is the quickfix buffer. | |
3116 */ | |
3117 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3118 bt_quickfix(buf_T *buf) |
7 | 3119 { |
3242 | 3120 return buf != NULL && buf->b_p_bt[0] == 'q'; |
7 | 3121 } |
3122 | |
3123 /* | |
17 | 3124 * Return TRUE if "buf" is a "nofile" or "acwrite" buffer. |
3125 * This means the buffer name is not a file name. | |
7 | 3126 */ |
3127 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3128 bt_nofile(buf_T *buf) |
7 | 3129 { |
3242 | 3130 return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f') |
3131 || buf->b_p_bt[0] == 'a'); | |
7 | 3132 } |
3133 | |
3134 /* | |
3135 * Return TRUE if "buf" is a "nowrite" or "nofile" buffer. | |
3136 */ | |
3137 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3138 bt_dontwrite(buf_T *buf) |
7 | 3139 { |
3242 | 3140 return buf != NULL && buf->b_p_bt[0] == 'n'; |
7 | 3141 } |
3142 | |
3143 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3144 bt_dontwrite_msg(buf_T *buf) |
7 | 3145 { |
3146 if (bt_dontwrite(buf)) | |
3147 { | |
3148 EMSG(_("E382: Cannot write, 'buftype' option is set")); | |
3149 return TRUE; | |
3150 } | |
3151 return FALSE; | |
3152 } | |
3153 | |
3154 /* | |
3155 * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide" | |
3156 * and 'bufhidden'. | |
3157 */ | |
3158 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3159 buf_hide(buf_T *buf) |
7 | 3160 { |
3161 /* 'bufhidden' overrules 'hidden' and ":hide", check it first */ | |
3162 switch (buf->b_p_bh[0]) | |
3163 { | |
3164 case 'u': /* "unload" */ | |
3165 case 'w': /* "wipe" */ | |
3166 case 'd': return FALSE; /* "delete" */ | |
3167 case 'h': return TRUE; /* "hide" */ | |
3168 } | |
3169 return (p_hid || cmdmod.hide); | |
3170 } | |
3171 | |
3172 /* | |
41 | 3173 * Return TRUE when using ":vimgrep" for ":grep". |
3174 */ | |
3175 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3176 grep_internal(cmdidx_T cmdidx) |
41 | 3177 { |
661 | 3178 return ((cmdidx == CMD_grep |
3179 || cmdidx == CMD_lgrep | |
3180 || cmdidx == CMD_grepadd | |
3181 || cmdidx == CMD_lgrepadd) | |
41 | 3182 && STRCMP("internal", |
3183 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0); | |
3184 } | |
3185 | |
3186 /* | |
657 | 3187 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd" |
7 | 3188 */ |
3189 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3190 ex_make(exarg_T *eap) |
7 | 3191 { |
161 | 3192 char_u *fname; |
7 | 3193 char_u *cmd; |
3194 unsigned len; | |
657 | 3195 win_T *wp = NULL; |
659 | 3196 qf_info_T *qi = &ql_info; |
842 | 3197 int res; |
161 | 3198 #ifdef FEAT_AUTOCMD |
3199 char_u *au_name = NULL; | |
3200 | |
2782 | 3201 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */ |
3202 if (grep_internal(eap->cmdidx)) | |
3203 { | |
3204 ex_vimgrep(eap); | |
3205 return; | |
3206 } | |
3207 | |
161 | 3208 switch (eap->cmdidx) |
3209 { | |
661 | 3210 case CMD_make: au_name = (char_u *)"make"; break; |
3211 case CMD_lmake: au_name = (char_u *)"lmake"; break; | |
3212 case CMD_grep: au_name = (char_u *)"grep"; break; | |
3213 case CMD_lgrep: au_name = (char_u *)"lgrep"; break; | |
3214 case CMD_grepadd: au_name = (char_u *)"grepadd"; break; | |
3215 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break; | |
161 | 3216 default: break; |
3217 } | |
3218 if (au_name != NULL) | |
3219 { | |
3220 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, | |
3221 curbuf->b_fname, TRUE, curbuf); | |
532 | 3222 # ifdef FEAT_EVAL |
161 | 3223 if (did_throw || force_abort) |
3224 return; | |
532 | 3225 # endif |
161 | 3226 } |
3227 #endif | |
7 | 3228 |
657 | 3229 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep |
3230 || eap->cmdidx == CMD_lgrepadd) | |
3231 wp = curwin; | |
3232 | |
7 | 3233 autowrite_all(); |
161 | 3234 fname = get_mef_name(); |
3235 if (fname == NULL) | |
7 | 3236 return; |
161 | 3237 mch_remove(fname); /* in case it's not unique */ |
7 | 3238 |
3239 /* | |
3240 * If 'shellpipe' empty: don't redirect to 'errorfile'. | |
3241 */ | |
3242 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1; | |
3243 if (*p_sp != NUL) | |
161 | 3244 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3; |
7 | 3245 cmd = alloc(len); |
3246 if (cmd == NULL) | |
3247 return; | |
3248 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg, | |
3249 (char *)p_shq); | |
3250 if (*p_sp != NUL) | |
1872 | 3251 append_redir(cmd, len, p_sp, fname); |
7 | 3252 /* |
3253 * Output a newline if there's something else than the :make command that | |
3254 * was typed (in which case the cursor is in column 0). | |
3255 */ | |
3256 if (msg_col == 0) | |
3257 msg_didout = FALSE; | |
3258 msg_start(); | |
3259 MSG_PUTS(":!"); | |
3260 msg_outtrans(cmd); /* show what we are doing */ | |
3261 | |
3262 /* let the shell know if we are redirecting output or not */ | |
3263 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0); | |
3264 | |
3265 #ifdef AMIGA | |
3266 out_flush(); | |
3267 /* read window status report and redraw before message */ | |
3268 (void)char_avail(); | |
3269 #endif | |
3270 | |
842 | 3271 res = qf_init(wp, fname, (eap->cmdidx != CMD_make |
657 | 3272 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, |
3273 (eap->cmdidx != CMD_grepadd | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
3274 && eap->cmdidx != CMD_lgrepadd), |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
3275 *eap->cmdlinep); |
2847 | 3276 if (wp != NULL) |
3277 qi = GET_LOC_LIST(wp); | |
842 | 3278 #ifdef FEAT_AUTOCMD |
3279 if (au_name != NULL) | |
2847 | 3280 { |
842 | 3281 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
3282 curbuf->b_fname, TRUE, curbuf); | |
2847 | 3283 if (qi->qf_curlist < qi->qf_listcount) |
3284 res = qi->qf_lists[qi->qf_curlist].qf_count; | |
3285 else | |
3286 res = 0; | |
3287 } | |
842 | 3288 #endif |
3289 if (res > 0 && !eap->forceit) | |
659 | 3290 qf_jump(qi, 0, 0, FALSE); /* display first error */ |
7 | 3291 |
161 | 3292 mch_remove(fname); |
3293 vim_free(fname); | |
7 | 3294 vim_free(cmd); |
3295 } | |
3296 | |
3297 /* | |
3298 * Return the name for the errorfile, in allocated memory. | |
3299 * Find a new unique name when 'makeef' contains "##". | |
3300 * Returns NULL for error. | |
3301 */ | |
3302 static char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3303 get_mef_name(void) |
7 | 3304 { |
3305 char_u *p; | |
3306 char_u *name; | |
3307 static int start = -1; | |
3308 static int off = 0; | |
3309 #ifdef HAVE_LSTAT | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9379
diff
changeset
|
3310 stat_T sb; |
7 | 3311 #endif |
3312 | |
3313 if (*p_mef == NUL) | |
3314 { | |
6721 | 3315 name = vim_tempname('e', FALSE); |
7 | 3316 if (name == NULL) |
3317 EMSG(_(e_notmp)); | |
3318 return name; | |
3319 } | |
3320 | |
3321 for (p = p_mef; *p; ++p) | |
3322 if (p[0] == '#' && p[1] == '#') | |
3323 break; | |
3324 | |
3325 if (*p == NUL) | |
3326 return vim_strsave(p_mef); | |
3327 | |
3328 /* Keep trying until the name doesn't exist yet. */ | |
3329 for (;;) | |
3330 { | |
3331 if (start == -1) | |
3332 start = mch_get_pid(); | |
3333 else | |
3334 off += 19; | |
3335 | |
3336 name = alloc((unsigned)STRLEN(p_mef) + 30); | |
3337 if (name == NULL) | |
3338 break; | |
3339 STRCPY(name, p_mef); | |
3340 sprintf((char *)name + (p - p_mef), "%d%d", start, off); | |
3341 STRCAT(name, p + 2); | |
3342 if (mch_getperm(name) < 0 | |
3343 #ifdef HAVE_LSTAT | |
3344 /* Don't accept a symbolic link, its a security risk. */ | |
3345 && mch_lstat((char *)name, &sb) < 0 | |
3346 #endif | |
3347 ) | |
3348 break; | |
3349 vim_free(name); | |
3350 } | |
3351 return name; | |
3352 } | |
3353 | |
3354 /* | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3355 * Returns the number of valid entries in the current quickfix/location list. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3356 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3357 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3358 qf_get_size(exarg_T *eap) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3359 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3360 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3361 qfline_T *qfp; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3362 int i, sz = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3363 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3364 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3365 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3366 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3367 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3368 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3369 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3370 return 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3371 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3372 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3373 for (i = 0, qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3374 i < qi->qf_lists[qi->qf_curlist].qf_count && qfp != NULL; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3375 ++i, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3376 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3377 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3378 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3379 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3380 sz++; /* Count all valid entries */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3381 else if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3382 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3383 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3384 sz++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3385 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3386 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3387 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3388 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3389 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3390 return sz; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3391 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3392 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3393 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3394 * Returns the current index of the quickfix/location list. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3395 * Returns 0 if there is an error. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3396 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3397 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3398 qf_get_cur_idx(exarg_T *eap) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3399 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3400 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3401 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3402 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3403 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3404 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3405 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3406 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3407 return 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3408 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3409 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3410 return qi->qf_lists[qi->qf_curlist].qf_index; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3411 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3412 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3413 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3414 * Returns the current index in the quickfix/location list (counting only valid |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3415 * entries). If no valid entries are in the list, then returns 1. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3416 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3417 int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3418 qf_get_cur_valid_idx(exarg_T *eap) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3419 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3420 qf_info_T *qi = &ql_info; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3421 qf_list_T *qfl; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3422 qfline_T *qfp; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3423 int i, eidx = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3424 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3425 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3426 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3427 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3428 /* Location list */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3429 qi = GET_LOC_LIST(curwin); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3430 if (qi == NULL) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3431 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3432 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3433 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3434 qfl = &qi->qf_lists[qi->qf_curlist]; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3435 qfp = qfl->qf_start; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3436 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3437 /* check if the list has valid errors */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3438 if (qfl->qf_count <= 0 || qfl->qf_nonevalid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3439 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3440 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3441 for (i = 1; i <= qfl->qf_index && qfp!= NULL; i++, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3442 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3443 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3444 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3445 if (eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3446 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3447 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3448 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3449 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3450 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3451 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3452 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3453 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3454 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3455 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3456 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3457 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3458 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3459 return eidx ? eidx : 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3460 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3461 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3462 /* |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3463 * Get the 'n'th valid error entry in the quickfix or location list. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3464 * Used by :cdo, :ldo, :cfdo and :lfdo commands. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3465 * For :cdo and :ldo returns the 'n'th valid error entry. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3466 * For :cfdo and :lfdo returns the 'n'th valid file entry. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3467 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3468 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3469 qf_get_nth_valid_entry(qf_info_T *qi, int n, int fdo) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3470 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3471 qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist]; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3472 qfline_T *qfp = qfl->qf_start; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3473 int i, eidx; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3474 int prev_fnum = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3475 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3476 /* check if the list has valid errors */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3477 if (qfl->qf_count <= 0 || qfl->qf_nonevalid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3478 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3479 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3480 for (i = 1, eidx = 0; i <= qfl->qf_count && qfp != NULL; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3481 i++, qfp = qfp->qf_next) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3482 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3483 if (qfp->qf_valid) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3484 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3485 if (fdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3486 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3487 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3488 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3489 /* Count the number of files */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3490 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3491 prev_fnum = qfp->qf_fnum; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3492 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3493 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3494 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3495 eidx++; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3496 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3497 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3498 if (eidx == n) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3499 break; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3500 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3501 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3502 if (i <= qfl->qf_count) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3503 return i; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3504 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3505 return 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3506 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3507 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3508 /* |
7 | 3509 * ":cc", ":crewind", ":cfirst" and ":clast". |
644 | 3510 * ":ll", ":lrewind", ":lfirst" and ":llast". |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3511 * ":cdo", ":ldo", ":cfdo" and ":lfdo" |
7 | 3512 */ |
3513 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3514 ex_cc(exarg_T *eap) |
7 | 3515 { |
659 | 3516 qf_info_T *qi = &ql_info; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3517 int errornr; |
659 | 3518 |
3519 if (eap->cmdidx == CMD_ll | |
3520 || eap->cmdidx == CMD_lrewind | |
3521 || eap->cmdidx == CMD_lfirst | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3522 || eap->cmdidx == CMD_llast |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3523 || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3524 || eap->cmdidx == CMD_lfdo) |
644 | 3525 { |
3526 qi = GET_LOC_LIST(curwin); | |
3527 if (qi == NULL) | |
3528 { | |
3529 EMSG(_(e_loclist)); | |
3530 return; | |
3531 } | |
3532 } | |
3533 | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3534 if (eap->addr_count > 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3535 errornr = (int)eap->line2; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3536 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3537 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3538 if (eap->cmdidx == CMD_cc || eap->cmdidx == CMD_ll) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3539 errornr = 0; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3540 else if (eap->cmdidx == CMD_crewind || eap->cmdidx == CMD_lrewind |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3541 || eap->cmdidx == CMD_cfirst || eap->cmdidx == CMD_lfirst) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3542 errornr = 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3543 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3544 errornr = 32767; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3545 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3546 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3547 /* For cdo and ldo commands, jump to the nth valid error. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3548 * For cfdo and lfdo commands, jump to the nth valid file entry. |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3549 */ |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3550 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo || |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3551 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3552 errornr = qf_get_nth_valid_entry(qi, |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3553 eap->addr_count > 0 ? (int)eap->line1 : 1, |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3554 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3555 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3556 qf_jump(qi, 0, errornr, eap->forceit); |
7 | 3557 } |
3558 | |
3559 /* | |
3560 * ":cnext", ":cnfile", ":cNext" and ":cprevious". | |
644 | 3561 * ":lnext", ":lNext", ":lprevious", ":lnfile", ":lNfile" and ":lpfile". |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3562 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands. |
7 | 3563 */ |
3564 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3565 ex_cnext(exarg_T *eap) |
7 | 3566 { |
659 | 3567 qf_info_T *qi = &ql_info; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3568 int errornr; |
659 | 3569 |
3570 if (eap->cmdidx == CMD_lnext | |
3571 || eap->cmdidx == CMD_lNext | |
3572 || eap->cmdidx == CMD_lprevious | |
3573 || eap->cmdidx == CMD_lnfile | |
3574 || eap->cmdidx == CMD_lNfile | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3575 || eap->cmdidx == CMD_lpfile |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3576 || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3577 || eap->cmdidx == CMD_lfdo) |
644 | 3578 { |
3579 qi = GET_LOC_LIST(curwin); | |
3580 if (qi == NULL) | |
3581 { | |
3582 EMSG(_(e_loclist)); | |
3583 return; | |
3584 } | |
3585 } | |
3586 | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3587 if (eap->addr_count > 0 && |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3588 (eap->cmdidx != CMD_cdo && eap->cmdidx != CMD_ldo && |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3589 eap->cmdidx != CMD_cfdo && eap->cmdidx != CMD_lfdo)) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3590 errornr = (int)eap->line2; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3591 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3592 errornr = 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3593 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3594 qf_jump(qi, (eap->cmdidx == CMD_cnext || eap->cmdidx == CMD_lnext |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3595 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
7 | 3596 ? FORWARD |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3597 : (eap->cmdidx == CMD_cnfile || eap->cmdidx == CMD_lnfile |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3598 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
7 | 3599 ? FORWARD_FILE |
644 | 3600 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile |
3601 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile) | |
7 | 3602 ? BACKWARD_FILE |
3603 : BACKWARD, | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
6853
diff
changeset
|
3604 errornr, eap->forceit); |
7 | 3605 } |
3606 | |
3607 /* | |
446 | 3608 * ":cfile"/":cgetfile"/":caddfile" commands. |
644 | 3609 * ":lfile"/":lgetfile"/":laddfile" commands. |
7 | 3610 */ |
3611 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3612 ex_cfile(exarg_T *eap) |
7 | 3613 { |
644 | 3614 win_T *wp = NULL; |
659 | 3615 qf_info_T *qi = &ql_info; |
3404 | 3616 #ifdef FEAT_AUTOCMD |
3617 char_u *au_name = NULL; | |
3618 #endif | |
644 | 3619 |
3620 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile | |
3404 | 3621 || eap->cmdidx == CMD_laddfile) |
644 | 3622 wp = curwin; |
3623 | |
3404 | 3624 #ifdef FEAT_AUTOCMD |
3625 switch (eap->cmdidx) | |
3626 { | |
3627 case CMD_cfile: au_name = (char_u *)"cfile"; break; | |
3628 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break; | |
3629 case CMD_caddfile: au_name = (char_u *)"caddfile"; break; | |
3630 case CMD_lfile: au_name = (char_u *)"lfile"; break; | |
3631 case CMD_lgetfile: au_name = (char_u *)"lgetfile"; break; | |
3632 case CMD_laddfile: au_name = (char_u *)"laddfile"; break; | |
3633 default: break; | |
3634 } | |
3635 if (au_name != NULL) | |
3636 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); | |
3637 #endif | |
2296
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3638 #ifdef FEAT_BROWSE |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3639 if (cmdmod.browse) |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3640 { |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3641 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg, |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3642 NULL, NULL, BROWSE_FILTER_ALL_FILES, NULL); |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3643 if (browse_file == NULL) |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3644 return; |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3645 set_string_option_direct((char_u *)"ef", -1, browse_file, OPT_FREE, 0); |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3646 vim_free(browse_file); |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3647 } |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3648 else |
eb7be7b075a6
Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2146
diff
changeset
|
3649 #endif |
7 | 3650 if (*eap->arg != NUL) |
694 | 3651 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); |
446 | 3652 |
3653 /* | |
3654 * This function is used by the :cfile, :cgetfile and :caddfile | |
3655 * commands. | |
3656 * :cfile always creates a new quickfix list and jumps to the | |
3657 * first error. | |
3658 * :cgetfile creates a new quickfix list but doesn't jump to the | |
3659 * first error. | |
3660 * :caddfile adds to an existing quickfix list. If there is no | |
3661 * quickfix list then a new list is created. | |
3662 */ | |
644 | 3663 if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
3664 && eap->cmdidx != CMD_laddfile), |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
3665 *eap->cmdlinep) > 0 |
644 | 3666 && (eap->cmdidx == CMD_cfile |
3667 || eap->cmdidx == CMD_lfile)) | |
665 | 3668 { |
3404 | 3669 #ifdef FEAT_AUTOCMD |
3670 if (au_name != NULL) | |
3671 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | |
3672 #endif | |
665 | 3673 if (wp != NULL) |
3674 qi = GET_LOC_LIST(wp); | |
659 | 3675 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
665 | 3676 } |
3404 | 3677 |
3678 else | |
3679 { | |
3680 #ifdef FEAT_AUTOCMD | |
3681 if (au_name != NULL) | |
3682 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | |
3683 #endif | |
3684 } | |
7 | 3685 } |
3686 | |
3687 /* | |
41 | 3688 * ":vimgrep {pattern} file(s)" |
657 | 3689 * ":vimgrepadd {pattern} file(s)" |
3690 * ":lvimgrep {pattern} file(s)" | |
3691 * ":lvimgrepadd {pattern} file(s)" | |
41 | 3692 */ |
3693 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3694 ex_vimgrep(exarg_T *eap) |
41 | 3695 { |
42 | 3696 regmmatch_T regmatch; |
153 | 3697 int fcount; |
41 | 3698 char_u **fnames; |
1411 | 3699 char_u *fname; |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
3700 char_u *title; |
153 | 3701 char_u *s; |
3702 char_u *p; | |
3703 int fi; | |
657 | 3704 qf_info_T *qi = &ql_info; |
4003 | 3705 #ifdef FEAT_AUTOCMD |
3706 qfline_T *cur_qf_start; | |
3707 #endif | |
41 | 3708 long lnum; |
42 | 3709 buf_T *buf; |
3710 int duplicate_name = FALSE; | |
3711 int using_dummy; | |
1396 | 3712 int redraw_for_dummy = FALSE; |
42 | 3713 int found_match; |
123 | 3714 buf_T *first_match_buf = NULL; |
3715 time_t seconds = 0; | |
677 | 3716 int save_mls; |
123 | 3717 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
3718 char_u *save_ei = NULL; | |
677 | 3719 #endif |
123 | 3720 aco_save_T aco; |
170 | 3721 int flags = 0; |
3722 colnr_T col; | |
716 | 3723 long tomatch; |
2770 | 3724 char_u *dirname_start = NULL; |
3725 char_u *dirname_now = NULL; | |
1411 | 3726 char_u *target_dir = NULL; |
1683 | 3727 #ifdef FEAT_AUTOCMD |
3728 char_u *au_name = NULL; | |
161 | 3729 |
3730 switch (eap->cmdidx) | |
3731 { | |
2782 | 3732 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break; |
3733 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break; | |
3734 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break; | |
657 | 3735 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break; |
2782 | 3736 case CMD_grep: au_name = (char_u *)"grep"; break; |
3737 case CMD_lgrep: au_name = (char_u *)"lgrep"; break; | |
3738 case CMD_grepadd: au_name = (char_u *)"grepadd"; break; | |
3739 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break; | |
161 | 3740 default: break; |
3741 } | |
3742 if (au_name != NULL) | |
3743 { | |
3744 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, | |
3745 curbuf->b_fname, TRUE, curbuf); | |
3746 if (did_throw || force_abort) | |
3747 return; | |
3748 } | |
3749 #endif | |
41 | 3750 |
661 | 3751 if (eap->cmdidx == CMD_lgrep |
659 | 3752 || eap->cmdidx == CMD_lvimgrep |
3753 || eap->cmdidx == CMD_lgrepadd | |
3754 || eap->cmdidx == CMD_lvimgrepadd) | |
657 | 3755 { |
3756 qi = ll_get_or_alloc_list(curwin); | |
3757 if (qi == NULL) | |
3758 return; | |
3759 } | |
3760 | |
716 | 3761 if (eap->addr_count > 0) |
3762 tomatch = eap->line2; | |
3763 else | |
3764 tomatch = MAXLNUM; | |
3765 | |
42 | 3766 /* Get the search pattern: either white-separated or enclosed in // */ |
41 | 3767 regmatch.regprog = NULL; |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
3768 title = vim_strsave(*eap->cmdlinep); |
170 | 3769 p = skip_vimgrep_pat(eap->arg, &s, &flags); |
153 | 3770 if (p == NULL) |
41 | 3771 { |
282 | 3772 EMSG(_(e_invalpat)); |
153 | 3773 goto theend; |
41 | 3774 } |
4197 | 3775 |
3776 if (s != NULL && *s == NUL) | |
3777 { | |
3778 /* Pattern is empty, use last search pattern. */ | |
3779 if (last_search_pat() == NULL) | |
3780 { | |
3781 EMSG(_(e_noprevre)); | |
3782 goto theend; | |
3783 } | |
3784 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); | |
3785 } | |
3786 else | |
3787 regmatch.regprog = vim_regcomp(s, RE_MAGIC); | |
3788 | |
41 | 3789 if (regmatch.regprog == NULL) |
3790 goto theend; | |
95 | 3791 regmatch.rmm_ic = p_ic; |
410 | 3792 regmatch.rmm_maxcol = 0; |
41 | 3793 |
3794 p = skipwhite(p); | |
3795 if (*p == NUL) | |
3796 { | |
3797 EMSG(_("E683: File name missing or invalid pattern")); | |
3798 goto theend; | |
3799 } | |
3800 | |
661 | 3801 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd && |
657 | 3802 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd) |
644 | 3803 || qi->qf_curlist == qi->qf_listcount) |
41 | 3804 /* make place for a new list */ |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
3805 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep); |
41 | 3806 |
3807 /* parse the list of arguments */ | |
3620 | 3808 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) |
41 | 3809 goto theend; |
3810 if (fcount == 0) | |
3811 { | |
3812 EMSG(_(e_nomatch)); | |
3813 goto theend; | |
3814 } | |
3815 | |
7558
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
3816 dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start); |
9a4c9dccd603
commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents:
7515
diff
changeset
|
3817 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now); |
2770 | 3818 if (dirname_start == NULL || dirname_now == NULL) |
7662
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
3819 { |
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
3820 FreeWild(fcount, fnames); |
2770 | 3821 goto theend; |
7662
4d34891e98f4
commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents:
7558
diff
changeset
|
3822 } |
2770 | 3823 |
1411 | 3824 /* Remember the current directory, because a BufRead autocommand that does |
3825 * ":lcd %:p:h" changes the meaning of short path names. */ | |
3826 mch_dirname(dirname_start, MAXPATHL); | |
3827 | |
4003 | 3828 #ifdef FEAT_AUTOCMD |
4352 | 3829 /* Remember the value of qf_start, so that we can check for autocommands |
4003 | 3830 * changing the current quickfix list. */ |
3831 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
3832 #endif | |
3833 | |
123 | 3834 seconds = (time_t)0; |
716 | 3835 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi) |
41 | 3836 { |
1411 | 3837 fname = shorten_fname1(fnames[fi]); |
123 | 3838 if (time(NULL) > seconds) |
3839 { | |
1411 | 3840 /* Display the file name every second or so, show the user we are |
3841 * working on it. */ | |
123 | 3842 seconds = time(NULL); |
3843 msg_start(); | |
1411 | 3844 p = msg_strtrunc(fname, TRUE); |
123 | 3845 if (p == NULL) |
1411 | 3846 msg_outtrans(fname); |
123 | 3847 else |
3848 { | |
3849 msg_outtrans(p); | |
3850 vim_free(p); | |
3851 } | |
3852 msg_clr_eos(); | |
3853 msg_didout = FALSE; /* overwrite this message */ | |
3854 msg_nowait = TRUE; /* don't wait for this message */ | |
3855 msg_col = 0; | |
3856 out_flush(); | |
3857 } | |
3858 | |
42 | 3859 buf = buflist_findname_exp(fnames[fi]); |
3860 if (buf == NULL || buf->b_ml.ml_mfp == NULL) | |
3861 { | |
3862 /* Remember that a buffer with this name already exists. */ | |
3863 duplicate_name = (buf != NULL); | |
123 | 3864 using_dummy = TRUE; |
1396 | 3865 redraw_for_dummy = TRUE; |
123 | 3866 |
3867 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) | |
3868 /* Don't do Filetype autocommands to avoid loading syntax and | |
3869 * indent scripts, a great speed improvement. */ | |
3870 save_ei = au_event_disable(",Filetype"); | |
3871 #endif | |
677 | 3872 /* Don't use modelines here, it's useless. */ |
3873 save_mls = p_mls; | |
3874 p_mls = 0; | |
42 | 3875 |
3876 /* Load file into a buffer, so that 'fileencoding' is detected, | |
3877 * autocommands applied, etc. */ | |
3490 | 3878 buf = load_dummy_buffer(fname, dirname_start, dirname_now); |
123 | 3879 |
677 | 3880 p_mls = save_mls; |
123 | 3881 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
3882 au_event_restore(save_ei); | |
3883 #endif | |
42 | 3884 } |
3885 else | |
3886 /* Use existing, loaded buffer. */ | |
3887 using_dummy = FALSE; | |
123 | 3888 |
4003 | 3889 #ifdef FEAT_AUTOCMD |
3890 if (cur_qf_start != qi->qf_lists[qi->qf_curlist].qf_start) | |
3891 { | |
3892 int idx; | |
3893 | |
3894 /* Autocommands changed the quickfix list. Find the one we were | |
3895 * using and restore it. */ | |
3896 for (idx = 0; idx < LISTCOUNT; ++idx) | |
3897 if (cur_qf_start == qi->qf_lists[idx].qf_start) | |
3898 { | |
3899 qi->qf_curlist = idx; | |
3900 break; | |
3901 } | |
3902 if (idx == LISTCOUNT) | |
3903 { | |
3904 /* List cannot be found, create a new one. */ | |
3905 qf_new_list(qi, *eap->cmdlinep); | |
3906 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
3907 } | |
3908 } | |
3909 #endif | |
3910 | |
42 | 3911 if (buf == NULL) |
123 | 3912 { |
3913 if (!got_int) | |
1411 | 3914 smsg((char_u *)_("Cannot open file \"%s\""), fname); |
123 | 3915 } |
41 | 3916 else |
3917 { | |
717 | 3918 /* Try for a match in all lines of the buffer. |
3919 * For ":1vimgrep" look for first match only. */ | |
42 | 3920 found_match = FALSE; |
716 | 3921 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; |
3922 ++lnum) | |
41 | 3923 { |
170 | 3924 col = 0; |
3925 while (vim_regexec_multi(®match, curwin, buf, lnum, | |
1521 | 3926 col, NULL) > 0) |
41 | 3927 { |
1411 | 3928 ; |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
3929 if (qf_add_entry(qi, |
41 | 3930 NULL, /* dir */ |
1411 | 3931 fname, |
1065 | 3932 0, |
42 | 3933 ml_get_buf(buf, |
3934 regmatch.startpos[0].lnum + lnum, FALSE), | |
3935 regmatch.startpos[0].lnum + lnum, | |
3936 regmatch.startpos[0].col + 1, | |
170 | 3937 FALSE, /* vis_col */ |
230 | 3938 NULL, /* search pattern */ |
856 | 3939 0, /* nr */ |
3940 0, /* type */ | |
3941 TRUE /* valid */ | |
41 | 3942 ) == FAIL) |
3943 { | |
3944 got_int = TRUE; | |
3945 break; | |
3946 } | |
716 | 3947 found_match = TRUE; |
3948 if (--tomatch == 0) | |
3949 break; | |
170 | 3950 if ((flags & VGR_GLOBAL) == 0 |
3951 || regmatch.endpos[0].lnum > 0) | |
3952 break; | |
3953 col = regmatch.endpos[0].col | |
3954 + (col == regmatch.endpos[0].col); | |
1883 | 3955 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE))) |
170 | 3956 break; |
41 | 3957 } |
3958 line_breakcheck(); | |
42 | 3959 if (got_int) |
3960 break; | |
41 | 3961 } |
4003 | 3962 #ifdef FEAT_AUTOCMD |
3963 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; | |
3964 #endif | |
42 | 3965 |
3966 if (using_dummy) | |
3967 { | |
123 | 3968 if (found_match && first_match_buf == NULL) |
3969 first_match_buf = buf; | |
42 | 3970 if (duplicate_name) |
123 | 3971 { |
42 | 3972 /* Never keep a dummy buffer if there is another buffer |
3973 * with the same name. */ | |
3490 | 3974 wipe_dummy_buffer(buf, dirname_start); |
123 | 3975 buf = NULL; |
3976 } | |
717 | 3977 else if (!cmdmod.hide |
3978 || buf->b_p_bh[0] == 'u' /* "unload" */ | |
3979 || buf->b_p_bh[0] == 'w' /* "wipe" */ | |
3980 || buf->b_p_bh[0] == 'd') /* "delete" */ | |
42 | 3981 { |
717 | 3982 /* When no match was found we don't need to remember the |
3983 * buffer, wipe it out. If there was a match and it | |
3984 * wasn't the first one or we won't jump there: only | |
3985 * unload the buffer. | |
3986 * Ignore 'hidden' here, because it may lead to having too | |
3987 * many swap files. */ | |
42 | 3988 if (!found_match) |
123 | 3989 { |
3490 | 3990 wipe_dummy_buffer(buf, dirname_start); |
123 | 3991 buf = NULL; |
3992 } | |
170 | 3993 else if (buf != first_match_buf || (flags & VGR_NOJUMP)) |
123 | 3994 { |
3490 | 3995 unload_dummy_buffer(buf, dirname_start); |
123 | 3996 buf = NULL; |
3997 } | |
42 | 3998 } |
123 | 3999 |
4000 if (buf != NULL) | |
4001 { | |
1411 | 4002 /* If the buffer is still loaded we need to use the |
4003 * directory we jumped to below. */ | |
4004 if (buf == first_match_buf | |
4005 && target_dir == NULL | |
4006 && STRCMP(dirname_start, dirname_now) != 0) | |
4007 target_dir = vim_strsave(dirname_now); | |
4008 | |
123 | 4009 /* The buffer is still loaded, the Filetype autocommands |
677 | 4010 * need to be done now, in that buffer. And the modelines |
717 | 4011 * need to be done (again). But not the window-local |
4012 * options! */ | |
123 | 4013 aucmd_prepbuf(&aco, buf); |
677 | 4014 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) |
123 | 4015 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, |
4016 buf->b_fname, TRUE, buf); | |
677 | 4017 #endif |
717 | 4018 do_modelines(OPT_NOWIN); |
123 | 4019 aucmd_restbuf(&aco); |
4020 } | |
42 | 4021 } |
41 | 4022 } |
4023 } | |
4024 | |
4025 FreeWild(fcount, fnames); | |
4026 | |
644 | 4027 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
4028 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; | |
4029 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
41 | 4030 |
4031 #ifdef FEAT_WINDOWS | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4032 qf_update_buffer(qi, NULL); |
41 | 4033 #endif |
4034 | |
842 | 4035 #ifdef FEAT_AUTOCMD |
4036 if (au_name != NULL) | |
4037 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | |
4038 curbuf->b_fname, TRUE, curbuf); | |
4039 #endif | |
4040 | |
41 | 4041 /* Jump to first match. */ |
644 | 4042 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
170 | 4043 { |
4044 if ((flags & VGR_NOJUMP) == 0) | |
1396 | 4045 { |
4046 buf = curbuf; | |
659 | 4047 qf_jump(qi, 0, 0, eap->forceit); |
1396 | 4048 if (buf != curbuf) |
4049 /* If we jumped to another buffer redrawing will already be | |
4050 * taken care of. */ | |
4051 redraw_for_dummy = FALSE; | |
1411 | 4052 |
4053 /* Jump to the directory used after loading the buffer. */ | |
4054 if (curbuf == first_match_buf && target_dir != NULL) | |
4055 { | |
4056 exarg_T ea; | |
4057 | |
4058 ea.arg = target_dir; | |
4059 ea.cmdidx = CMD_lcd; | |
4060 ex_cd(&ea); | |
4061 } | |
1396 | 4062 } |
170 | 4063 } |
42 | 4064 else |
4065 EMSG2(_(e_nomatch2), s); | |
41 | 4066 |
1396 | 4067 /* If we loaded a dummy buffer into the current window, the autocommands |
4068 * may have messed up things, need to redraw and recompute folds. */ | |
4069 if (redraw_for_dummy) | |
4070 { | |
4071 #ifdef FEAT_FOLDING | |
4072 foldUpdateAll(curwin); | |
4073 #else | |
4074 redraw_later(NOT_VALID); | |
4075 #endif | |
4076 } | |
4077 | |
41 | 4078 theend: |
8603
bfa74b84c41c
commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
4079 vim_free(title); |
2770 | 4080 vim_free(dirname_now); |
4081 vim_free(dirname_start); | |
1411 | 4082 vim_free(target_dir); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4371
diff
changeset
|
4083 vim_regfree(regmatch.regprog); |
41 | 4084 } |
4085 | |
4086 /* | |
170 | 4087 * Skip over the pattern argument of ":vimgrep /pat/[g][j]". |
153 | 4088 * Put the start of the pattern in "*s", unless "s" is NULL. |
170 | 4089 * If "flags" is not NULL put the flags in it: VGR_GLOBAL, VGR_NOJUMP. |
4090 * If "s" is not NULL terminate the pattern with a NUL. | |
4091 * Return a pointer to the char just past the pattern plus flags. | |
153 | 4092 */ |
4093 char_u * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4094 skip_vimgrep_pat(char_u *p, char_u **s, int *flags) |
153 | 4095 { |
4096 int c; | |
4097 | |
4098 if (vim_isIDc(*p)) | |
4099 { | |
170 | 4100 /* ":vimgrep pattern fname" */ |
153 | 4101 if (s != NULL) |
4102 *s = p; | |
170 | 4103 p = skiptowhite(p); |
4104 if (s != NULL && *p != NUL) | |
4105 *p++ = NUL; | |
153 | 4106 } |
170 | 4107 else |
4108 { | |
4109 /* ":vimgrep /pattern/[g][j] fname" */ | |
4110 if (s != NULL) | |
4111 *s = p + 1; | |
4112 c = *p; | |
4113 p = skip_regexp(p + 1, c, TRUE, NULL); | |
4114 if (*p != c) | |
4115 return NULL; | |
4116 | |
4117 /* Truncate the pattern. */ | |
4118 if (s != NULL) | |
4119 *p = NUL; | |
4120 ++p; | |
4121 | |
4122 /* Find the flags */ | |
4123 while (*p == 'g' || *p == 'j') | |
4124 { | |
4125 if (flags != NULL) | |
4126 { | |
4127 if (*p == 'g') | |
4128 *flags |= VGR_GLOBAL; | |
4129 else | |
4130 *flags |= VGR_NOJUMP; | |
4131 } | |
4132 ++p; | |
4133 } | |
4134 } | |
153 | 4135 return p; |
4136 } | |
4137 | |
4138 /* | |
3490 | 4139 * Restore current working directory to "dirname_start" if they differ, taking |
4140 * into account whether it is set locally or globally. | |
4141 */ | |
4142 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4143 restore_start_dir(char_u *dirname_start) |
3490 | 4144 { |
4145 char_u *dirname_now = alloc(MAXPATHL); | |
4146 | |
4147 if (NULL != dirname_now) | |
4148 { | |
4149 mch_dirname(dirname_now, MAXPATHL); | |
4150 if (STRCMP(dirname_start, dirname_now) != 0) | |
4151 { | |
4152 /* If the directory has changed, change it back by building up an | |
4153 * appropriate ex command and executing it. */ | |
4154 exarg_T ea; | |
4155 | |
4156 ea.arg = dirname_start; | |
4157 ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd; | |
4158 ex_cd(&ea); | |
4159 } | |
3974 | 4160 vim_free(dirname_now); |
3490 | 4161 } |
4162 } | |
4163 | |
4164 /* | |
4165 * Load file "fname" into a dummy buffer and return the buffer pointer, | |
4166 * placing the directory resulting from the buffer load into the | |
4167 * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller | |
4168 * prior to calling this function. Restores directory to "dirname_start" prior | |
4169 * to returning, if autocmds or the 'autochdir' option have changed it. | |
4170 * | |
4171 * If creating the dummy buffer does not fail, must call unload_dummy_buffer() | |
4172 * or wipe_dummy_buffer() later! | |
4173 * | |
42 | 4174 * Returns NULL if it fails. |
4175 */ | |
4176 static buf_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4177 load_dummy_buffer( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4178 char_u *fname, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4179 char_u *dirname_start, /* in: old directory */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4180 char_u *resulting_dir) /* out: new directory */ |
42 | 4181 { |
4182 buf_T *newbuf; | |
2646 | 4183 buf_T *newbuf_to_wipe = NULL; |
42 | 4184 int failed = TRUE; |
4185 aco_save_T aco; | |
4186 | |
4187 /* Allocate a buffer without putting it in the buffer list. */ | |
4188 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); | |
4189 if (newbuf == NULL) | |
4190 return NULL; | |
4191 | |
177 | 4192 /* Init the options. */ |
4193 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP); | |
4194 | |
1918 | 4195 /* need to open the memfile before putting the buffer in a window */ |
4196 if (ml_open(newbuf) == OK) | |
42 | 4197 { |
1918 | 4198 /* set curwin/curbuf to buf and save a few things */ |
4199 aucmd_prepbuf(&aco, newbuf); | |
4200 | |
4201 /* Need to set the filename for autocommands. */ | |
4202 (void)setfname(curbuf, fname, NULL, FALSE); | |
4203 | |
42 | 4204 /* Create swap file now to avoid the ATTENTION message. */ |
4205 check_need_swap(TRUE); | |
4206 | |
4207 /* Remove the "dummy" flag, otherwise autocommands may not | |
4208 * work. */ | |
4209 curbuf->b_flags &= ~BF_DUMMY; | |
4210 | |
4211 if (readfile(fname, NULL, | |
4212 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, | |
4213 NULL, READ_NEW | READ_DUMMY) == OK | |
857 | 4214 && !got_int |
42 | 4215 && !(curbuf->b_flags & BF_NEW)) |
4216 { | |
4217 failed = FALSE; | |
4218 if (curbuf != newbuf) | |
4219 { | |
2646 | 4220 /* Bloody autocommands changed the buffer! Can happen when |
4221 * using netrw and editing a remote file. Use the current | |
4222 * buffer instead, delete the dummy one after restoring the | |
4223 * window stuff. */ | |
4224 newbuf_to_wipe = newbuf; | |
42 | 4225 newbuf = curbuf; |
4226 } | |
4227 } | |
1918 | 4228 |
4229 /* restore curwin/curbuf and a few other things */ | |
4230 aucmd_restbuf(&aco); | |
2646 | 4231 if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe)) |
4232 wipe_buffer(newbuf_to_wipe, FALSE); | |
42 | 4233 } |
4234 | |
3490 | 4235 /* |
4236 * When autocommands/'autochdir' option changed directory: go back. | |
4237 * Let the caller know what the resulting dir was first, in case it is | |
4238 * important. | |
4239 */ | |
4240 mch_dirname(resulting_dir, MAXPATHL); | |
4241 restore_start_dir(dirname_start); | |
4242 | |
42 | 4243 if (!buf_valid(newbuf)) |
4244 return NULL; | |
4245 if (failed) | |
4246 { | |
3490 | 4247 wipe_dummy_buffer(newbuf, dirname_start); |
42 | 4248 return NULL; |
4249 } | |
4250 return newbuf; | |
4251 } | |
4252 | |
4253 /* | |
3490 | 4254 * Wipe out the dummy buffer that load_dummy_buffer() created. Restores |
4255 * directory to "dirname_start" prior to returning, if autocmds or the | |
4256 * 'autochdir' option have changed it. | |
42 | 4257 */ |
4258 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4259 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) |
42 | 4260 { |
4261 if (curbuf != buf) /* safety check */ | |
857 | 4262 { |
4263 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | |
4264 cleanup_T cs; | |
4265 | |
4266 /* Reset the error/interrupt/exception state here so that aborting() | |
4267 * returns FALSE when wiping out the buffer. Otherwise it doesn't | |
4268 * work when got_int is set. */ | |
4269 enter_cleanup(&cs); | |
4270 #endif | |
4271 | |
42 | 4272 wipe_buffer(buf, FALSE); |
857 | 4273 |
4274 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | |
4275 /* Restore the error/interrupt/exception state if not discarded by a | |
4276 * new aborting error, interrupt, or uncaught exception. */ | |
4277 leave_cleanup(&cs); | |
4278 #endif | |
3490 | 4279 /* When autocommands/'autochdir' option changed directory: go back. */ |
4280 restore_start_dir(dirname_start); | |
857 | 4281 } |
42 | 4282 } |
4283 | |
4284 /* | |
3490 | 4285 * Unload the dummy buffer that load_dummy_buffer() created. Restores |
4286 * directory to "dirname_start" prior to returning, if autocmds or the | |
4287 * 'autochdir' option have changed it. | |
42 | 4288 */ |
4289 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4290 unload_dummy_buffer(buf_T *buf, char_u *dirname_start) |
42 | 4291 { |
4292 if (curbuf != buf) /* safety check */ | |
3490 | 4293 { |
3365 | 4294 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE); |
3490 | 4295 |
4296 /* When autocommands/'autochdir' option changed directory: go back. */ | |
4297 restore_start_dir(dirname_start); | |
4298 } | |
42 | 4299 } |
4300 | |
170 | 4301 #if defined(FEAT_EVAL) || defined(PROTO) |
4302 /* | |
4303 * Add each quickfix error to list "list" as a dictionary. | |
4304 */ | |
4305 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4306 get_errorlist(win_T *wp, list_T *list) |
170 | 4307 { |
644 | 4308 qf_info_T *qi = &ql_info; |
230 | 4309 dict_T *dict; |
4310 char_u buf[2]; | |
4311 qfline_T *qfp; | |
4312 int i; | |
1065 | 4313 int bufnum; |
170 | 4314 |
647 | 4315 if (wp != NULL) |
4316 { | |
4317 qi = GET_LOC_LIST(wp); | |
4318 if (qi == NULL) | |
4319 return FAIL; | |
4320 } | |
4321 | |
644 | 4322 if (qi->qf_curlist >= qi->qf_listcount |
712 | 4323 || qi->qf_lists[qi->qf_curlist].qf_count == 0) |
170 | 4324 return FAIL; |
4325 | |
644 | 4326 qfp = qi->qf_lists[qi->qf_curlist].qf_start; |
4327 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i) | |
170 | 4328 { |
1065 | 4329 /* Handle entries with a non-existing buffer number. */ |
4330 bufnum = qfp->qf_fnum; | |
4331 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
4332 bufnum = 0; | |
4333 | |
170 | 4334 if ((dict = dict_alloc()) == NULL) |
4335 return FAIL; | |
4336 if (list_append_dict(list, dict) == FAIL) | |
4337 return FAIL; | |
4338 | |
4339 buf[0] = qfp->qf_type; | |
4340 buf[1] = NUL; | |
1065 | 4341 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL |
170 | 4342 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL |
4343 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL | |
4344 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL | |
4345 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL | |
960 | 4346 || dict_add_nr_str(dict, "pattern", 0L, |
4347 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL | |
4348 || dict_add_nr_str(dict, "text", 0L, | |
4349 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL | |
170 | 4350 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL |
4351 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL) | |
4352 return FAIL; | |
4353 | |
4354 qfp = qfp->qf_next; | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4355 if (qfp == NULL) |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4356 break; |
170 | 4357 } |
4358 return OK; | |
4359 } | |
230 | 4360 |
4361 /* | |
4362 * Populate the quickfix list with the items supplied in the list | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4363 * of dictionaries. "title" will be copied to w:quickfix_title. |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4364 * "action" is 'a' for add, 'r' for replace. Otherwise create a new list. |
230 | 4365 */ |
4366 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4367 set_errorlist( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4368 win_T *wp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4369 list_T *list, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4370 int action, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4371 char_u *title) |
230 | 4372 { |
4373 listitem_T *li; | |
4374 dict_T *d; | |
4375 char_u *filename, *pattern, *text, *type; | |
1065 | 4376 int bufnum; |
230 | 4377 long lnum; |
4378 int col, nr; | |
4379 int vcol; | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4380 #ifdef FEAT_WINDOWS |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4381 qfline_T *old_last = NULL; |
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4382 #endif |
230 | 4383 int valid, status; |
4384 int retval = OK; | |
644 | 4385 qf_info_T *qi = &ql_info; |
1065 | 4386 int did_bufnr_emsg = FALSE; |
644 | 4387 |
647 | 4388 if (wp != NULL) |
4389 { | |
648 | 4390 qi = ll_get_or_alloc_list(wp); |
647 | 4391 if (qi == NULL) |
4392 return FAIL; | |
4393 } | |
4394 | |
644 | 4395 if (action == ' ' || qi->qf_curlist == qi->qf_listcount) |
277 | 4396 /* make place for a new list */ |
3965 | 4397 qf_new_list(qi, title); |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4398 #ifdef FEAT_WINDOWS |
644 | 4399 else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0) |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4400 /* Adding to existing list, use last entry. */ |
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4401 old_last = qi->qf_lists[qi->qf_curlist].qf_last; |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4402 #endif |
277 | 4403 else if (action == 'r') |
6079 | 4404 { |
644 | 4405 qf_free(qi, qi->qf_curlist); |
6079 | 4406 qf_store_title(qi, title); |
4407 } | |
230 | 4408 |
4409 for (li = list->lv_first; li != NULL; li = li->li_next) | |
4410 { | |
4411 if (li->li_tv.v_type != VAR_DICT) | |
4412 continue; /* Skip non-dict items */ | |
4413 | |
4414 d = li->li_tv.vval.v_dict; | |
4415 if (d == NULL) | |
4416 continue; | |
4417 | |
659 | 4418 filename = get_dict_string(d, (char_u *)"filename", TRUE); |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4419 bufnum = (int)get_dict_number(d, (char_u *)"bufnr"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4420 lnum = (int)get_dict_number(d, (char_u *)"lnum"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4421 col = (int)get_dict_number(d, (char_u *)"col"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4422 vcol = (int)get_dict_number(d, (char_u *)"vcol"); |
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4423 nr = (int)get_dict_number(d, (char_u *)"nr"); |
659 | 4424 type = get_dict_string(d, (char_u *)"type", TRUE); |
4425 pattern = get_dict_string(d, (char_u *)"pattern", TRUE); | |
4426 text = get_dict_string(d, (char_u *)"text", TRUE); | |
230 | 4427 if (text == NULL) |
4428 text = vim_strsave((char_u *)""); | |
4429 | |
4430 valid = TRUE; | |
1065 | 4431 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL)) |
230 | 4432 valid = FALSE; |
4433 | |
1065 | 4434 /* Mark entries with non-existing buffer number as not valid. Give the |
4435 * error message only once. */ | |
4436 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) | |
4437 { | |
4438 if (!did_bufnr_emsg) | |
4439 { | |
4440 did_bufnr_emsg = TRUE; | |
4441 EMSGN(_("E92: Buffer %ld not found"), bufnum); | |
4442 } | |
4443 valid = FALSE; | |
4444 bufnum = 0; | |
4445 } | |
4446 | |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4447 status = qf_add_entry(qi, |
230 | 4448 NULL, /* dir */ |
4449 filename, | |
1065 | 4450 bufnum, |
230 | 4451 text, |
4452 lnum, | |
4453 col, | |
4454 vcol, /* vis_col */ | |
4455 pattern, /* search pattern */ | |
4456 nr, | |
4457 type == NULL ? NUL : *type, | |
4458 valid); | |
4459 | |
4460 vim_free(filename); | |
4461 vim_free(pattern); | |
4462 vim_free(text); | |
4463 vim_free(type); | |
4464 | |
4465 if (status == FAIL) | |
4466 { | |
4467 retval = FAIL; | |
4468 break; | |
4469 } | |
4470 } | |
4471 | |
2146
c17a42da3920
updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
4472 if (qi->qf_lists[qi->qf_curlist].qf_index == 0) |
2795 | 4473 /* no valid entry */ |
2146
c17a42da3920
updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
4474 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE; |
c17a42da3920
updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
4475 else |
c17a42da3920
updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
4476 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4477 if (action != 'a') { |
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4478 qi->qf_lists[qi->qf_curlist].qf_ptr = |
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4479 qi->qf_lists[qi->qf_curlist].qf_start; |
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4480 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4481 qi->qf_lists[qi->qf_curlist].qf_index = 1; |
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4482 } |
230 | 4483 |
4484 #ifdef FEAT_WINDOWS | |
8932
25c2031e9f9f
commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents:
8751
diff
changeset
|
4485 /* Don't update the cursor in quickfix window when appending entries */ |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4486 qf_update_buffer(qi, old_last); |
230 | 4487 #endif |
4488 | |
4489 return retval; | |
4490 } | |
170 | 4491 #endif |
4492 | |
42 | 4493 /* |
41 | 4494 * ":[range]cbuffer [bufnr]" command. |
657 | 4495 * ":[range]caddbuffer [bufnr]" command. |
798 | 4496 * ":[range]cgetbuffer [bufnr]" command. |
644 | 4497 * ":[range]lbuffer [bufnr]" command. |
657 | 4498 * ":[range]laddbuffer [bufnr]" command. |
798 | 4499 * ":[range]lgetbuffer [bufnr]" command. |
41 | 4500 */ |
4501 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4502 ex_cbuffer(exarg_T *eap) |
41 | 4503 { |
4504 buf_T *buf = NULL; | |
644 | 4505 qf_info_T *qi = &ql_info; |
4506 | |
798 | 4507 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer |
4508 || eap->cmdidx == CMD_laddbuffer) | |
644 | 4509 { |
4510 qi = ll_get_or_alloc_list(curwin); | |
4511 if (qi == NULL) | |
4512 return; | |
4513 } | |
41 | 4514 |
4515 if (*eap->arg == NUL) | |
4516 buf = curbuf; | |
4517 else if (*skipwhite(skipdigits(eap->arg)) == NUL) | |
4518 buf = buflist_findnr(atoi((char *)eap->arg)); | |
4519 if (buf == NULL) | |
4520 EMSG(_(e_invarg)); | |
4521 else if (buf->b_ml.ml_mfp == NULL) | |
4522 EMSG(_("E681: Buffer is not loaded")); | |
4523 else | |
4524 { | |
4525 if (eap->addr_count == 0) | |
4526 { | |
4527 eap->line1 = 1; | |
4528 eap->line2 = buf->b_ml.ml_line_count; | |
4529 } | |
4530 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count | |
4531 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) | |
4532 EMSG(_(e_invrange)); | |
4533 else | |
661 | 4534 { |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4535 char_u *qf_title = *eap->cmdlinep; |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4536 |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4537 if (buf->b_sfname) |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4538 { |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4539 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4540 (char *)qf_title, (char *)buf->b_sfname); |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4541 qf_title = IObuff; |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4542 } |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4543 |
798 | 4544 if (qf_init_ext(qi, NULL, buf, NULL, p_efm, |
4545 (eap->cmdidx != CMD_caddbuffer | |
4546 && eap->cmdidx != CMD_laddbuffer), | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4547 eap->line1, eap->line2, |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4548 qf_title) > 0 |
798 | 4549 && (eap->cmdidx == CMD_cbuffer |
4550 || eap->cmdidx == CMD_lbuffer)) | |
661 | 4551 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
4552 } | |
41 | 4553 } |
4554 } | |
4555 | |
532 | 4556 #if defined(FEAT_EVAL) || defined(PROTO) |
41 | 4557 /* |
798 | 4558 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command. |
4559 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command. | |
446 | 4560 */ |
4561 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4562 ex_cexpr(exarg_T *eap) |
446 | 4563 { |
4564 typval_T *tv; | |
644 | 4565 qf_info_T *qi = &ql_info; |
4566 | |
798 | 4567 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr |
4568 || eap->cmdidx == CMD_laddexpr) | |
644 | 4569 { |
4570 qi = ll_get_or_alloc_list(curwin); | |
4571 if (qi == NULL) | |
4572 return; | |
4573 } | |
446 | 4574 |
625 | 4575 /* Evaluate the expression. When the result is a string or a list we can |
4576 * use it to fill the errorlist. */ | |
446 | 4577 tv = eval_expr(eap->arg, NULL); |
625 | 4578 if (tv != NULL) |
4579 { | |
4580 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL) | |
4581 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) | |
4582 { | |
7701
075810b0cb6c
commit https://github.com/vim/vim/commit/d6357e8f93c50f984ffd69c3a0d247d8603f86c3
Christian Brabandt <cb@256bit.org>
parents:
7662
diff
changeset
|
4583 if (qf_init_ext(qi, NULL, NULL, tv, p_efm, |
798 | 4584 (eap->cmdidx != CMD_caddexpr |
4585 && eap->cmdidx != CMD_laddexpr), | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2296
diff
changeset
|
4586 (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0 |
798 | 4587 && (eap->cmdidx == CMD_cexpr |
4588 || eap->cmdidx == CMD_lexpr)) | |
659 | 4589 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ |
625 | 4590 } |
4591 else | |
626 | 4592 EMSG(_("E777: String or List expected")); |
625 | 4593 free_tv(tv); |
4594 } | |
446 | 4595 } |
532 | 4596 #endif |
446 | 4597 |
4598 /* | |
7 | 4599 * ":helpgrep {pattern}" |
4600 */ | |
4601 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4602 ex_helpgrep(exarg_T *eap) |
7 | 4603 { |
4604 regmatch_T regmatch; | |
4605 char_u *save_cpo; | |
4606 char_u *p; | |
4607 int fcount; | |
4608 char_u **fnames; | |
4609 FILE *fd; | |
4610 int fi; | |
4611 long lnum; | |
9 | 4612 #ifdef FEAT_MULTI_LANG |
4613 char_u *lang; | |
4614 #endif | |
644 | 4615 qf_info_T *qi = &ql_info; |
659 | 4616 int new_qi = FALSE; |
4617 win_T *wp; | |
3269 | 4618 #ifdef FEAT_AUTOCMD |
4619 char_u *au_name = NULL; | |
4620 #endif | |
7 | 4621 |
9 | 4622 #ifdef FEAT_MULTI_LANG |
4623 /* Check for a specified language */ | |
4624 lang = check_help_lang(eap->arg); | |
4625 #endif | |
4626 | |
3269 | 4627 #ifdef FEAT_AUTOCMD |
4628 switch (eap->cmdidx) | |
4629 { | |
4630 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break; | |
4631 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break; | |
4632 default: break; | |
4633 } | |
4634 if (au_name != NULL) | |
4635 { | |
4636 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, | |
4637 curbuf->b_fname, TRUE, curbuf); | |
4638 if (did_throw || force_abort) | |
4639 return; | |
4640 } | |
4641 #endif | |
4642 | |
4643 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ | |
4644 save_cpo = p_cpo; | |
4645 p_cpo = empty_option; | |
4646 | |
659 | 4647 if (eap->cmdidx == CMD_lhelpgrep) |
4648 { | |
4649 /* Find an existing help window */ | |
4650 FOR_ALL_WINDOWS(wp) | |
4651 if (wp->w_buffer != NULL && wp->w_buffer->b_help) | |
4652 break; | |
4653 | |
4654 if (wp == NULL) /* Help window not found */ | |
4655 qi = NULL; | |
4656 else | |
4657 qi = wp->w_llist; | |
4658 | |
4659 if (qi == NULL) | |
4660 { | |
4661 /* Allocate a new location list for help text matches */ | |
4662 if ((qi = ll_new_list()) == NULL) | |
4663 return; | |
4664 new_qi = TRUE; | |
4665 } | |
4666 } | |
4667 | |
7 | 4668 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); |
4669 regmatch.rm_ic = FALSE; | |
4670 if (regmatch.regprog != NULL) | |
4671 { | |
3257 | 4672 #ifdef FEAT_MBYTE |
4673 vimconv_T vc; | |
4674 | |
4675 /* Help files are in utf-8 or latin1, convert lines when 'encoding' | |
4676 * differs. */ | |
4677 vc.vc_type = CONV_NONE; | |
4678 if (!enc_utf8) | |
4679 convert_setup(&vc, (char_u *)"utf-8", p_enc); | |
4680 #endif | |
4681 | |
7 | 4682 /* create a new quickfix list */ |
3965 | 4683 qf_new_list(qi, *eap->cmdlinep); |
7 | 4684 |
4685 /* Go through all directories in 'runtimepath' */ | |
4686 p = p_rtp; | |
4687 while (*p != NUL && !got_int) | |
4688 { | |
4689 copy_option_part(&p, NameBuff, MAXPATHL, ","); | |
4690 | |
4691 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */ | |
4692 add_pathsep(NameBuff); | |
4693 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)"); | |
4694 if (gen_expand_wildcards(1, &NameBuff, &fcount, | |
4695 &fnames, EW_FILE|EW_SILENT) == OK | |
4696 && fcount > 0) | |
4697 { | |
4698 for (fi = 0; fi < fcount && !got_int; ++fi) | |
4699 { | |
9 | 4700 #ifdef FEAT_MULTI_LANG |
4701 /* Skip files for a different language. */ | |
4702 if (lang != NULL | |
4703 && STRNICMP(lang, fnames[fi] | |
4704 + STRLEN(fnames[fi]) - 3, 2) != 0 | |
4705 && !(STRNICMP(lang, "en", 2) == 0 | |
4706 && STRNICMP("txt", fnames[fi] | |
4707 + STRLEN(fnames[fi]) - 3, 3) == 0)) | |
4708 continue; | |
4709 #endif | |
531 | 4710 fd = mch_fopen((char *)fnames[fi], "r"); |
7 | 4711 if (fd != NULL) |
4712 { | |
4713 lnum = 1; | |
4714 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) | |
4715 { | |
3257 | 4716 char_u *line = IObuff; |
4717 #ifdef FEAT_MBYTE | |
4718 /* Convert a line if 'encoding' is not utf-8 and | |
4719 * the line contains a non-ASCII character. */ | |
4720 if (vc.vc_type != CONV_NONE | |
4721 && has_non_ascii(IObuff)) { | |
4722 line = string_convert(&vc, IObuff, NULL); | |
4723 if (line == NULL) | |
4724 line = IObuff; | |
4725 } | |
4726 #endif | |
4727 | |
4728 if (vim_regexec(®match, line, (colnr_T)0)) | |
7 | 4729 { |
3257 | 4730 int l = (int)STRLEN(line); |
7 | 4731 |
4732 /* remove trailing CR, LF, spaces, etc. */ | |
3257 | 4733 while (l > 0 && line[l - 1] <= ' ') |
4734 line[--l] = NUL; | |
7 | 4735 |
9195
543f068f3706
commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents:
9175
diff
changeset
|
4736 if (qf_add_entry(qi, |
7 | 4737 NULL, /* dir */ |
4738 fnames[fi], | |
1065 | 4739 0, |
3257 | 4740 line, |
7 | 4741 lnum, |
3257 | 4742 (int)(regmatch.startp[0] - line) |
42 | 4743 + 1, /* col */ |
170 | 4744 FALSE, /* vis_col */ |
230 | 4745 NULL, /* search pattern */ |
7 | 4746 0, /* nr */ |
4747 1, /* type */ | |
4748 TRUE /* valid */ | |
4749 ) == FAIL) | |
4750 { | |
4751 got_int = TRUE; | |
3257 | 4752 #ifdef FEAT_MBYTE |
4753 if (line != IObuff) | |
4754 vim_free(line); | |
4755 #endif | |
7 | 4756 break; |
4757 } | |
4758 } | |
3257 | 4759 #ifdef FEAT_MBYTE |
4760 if (line != IObuff) | |
4761 vim_free(line); | |
4762 #endif | |
7 | 4763 ++lnum; |
4764 line_breakcheck(); | |
4765 } | |
4766 fclose(fd); | |
4767 } | |
4768 } | |
4769 FreeWild(fcount, fnames); | |
4770 } | |
4771 } | |
3257 | 4772 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4371
diff
changeset
|
4773 vim_regfree(regmatch.regprog); |
3257 | 4774 #ifdef FEAT_MBYTE |
4775 if (vc.vc_type != CONV_NONE) | |
4776 convert_setup(&vc, NULL, NULL); | |
4777 #endif | |
7 | 4778 |
644 | 4779 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; |
4780 qi->qf_lists[qi->qf_curlist].qf_ptr = | |
4781 qi->qf_lists[qi->qf_curlist].qf_start; | |
4782 qi->qf_lists[qi->qf_curlist].qf_index = 1; | |
7 | 4783 } |
4784 | |
1672 | 4785 if (p_cpo == empty_option) |
4786 p_cpo = save_cpo; | |
4787 else | |
4788 /* Darn, some plugin changed the value. */ | |
4789 free_string_option(save_cpo); | |
7 | 4790 |
4791 #ifdef FEAT_WINDOWS | |
9175
d415c079f84e
commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents:
9114
diff
changeset
|
4792 qf_update_buffer(qi, NULL); |
7 | 4793 #endif |
4794 | |
3269 | 4795 #ifdef FEAT_AUTOCMD |
4796 if (au_name != NULL) | |
4797 { | |
4798 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | |
4799 curbuf->b_fname, TRUE, curbuf); | |
4800 if (!new_qi && qi != &ql_info && qf_find_buf(qi) == NULL) | |
4801 /* autocommands made "qi" invalid */ | |
4802 return; | |
4803 } | |
4804 #endif | |
4805 | |
7 | 4806 /* Jump to first match. */ |
644 | 4807 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) |
659 | 4808 qf_jump(qi, 0, 0, FALSE); |
9 | 4809 else |
4810 EMSG2(_(e_nomatch2), eap->arg); | |
659 | 4811 |
4812 if (eap->cmdidx == CMD_lhelpgrep) | |
4813 { | |
4814 /* If the help window is not opened or if it already points to the | |
661 | 4815 * correct location list, then free the new location list. */ |
659 | 4816 if (!curwin->w_buffer->b_help || curwin->w_llist == qi) |
4817 { | |
4818 if (new_qi) | |
4819 ll_free_all(&qi); | |
4820 } | |
4821 else if (curwin->w_llist == NULL) | |
4822 curwin->w_llist = qi; | |
4823 } | |
7 | 4824 } |
4825 | |
4826 #endif /* FEAT_QUICKFIX */ |