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