annotate src/quickfix.c @ 13076:7c071a3f7f8e v8.0.1413

patch 8.0.1413: accessing freed memory in :cbuffer commit https://github.com/vim/vim/commit/aaf6e43b7a99cedb89d73ba749a46f7a0f16bbb6 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 19 16:41:14 2017 +0100 patch 8.0.1413: accessing freed memory in :cbuffer Problem: Accessing freed memory in :cbuffer. Solution: Get quickfix list after executing autocmds. (closes https://github.com/vim/vim/issues/2470)
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Dec 2017 16:45:06 +0100
parents 66c014c71dad
children a1f8939a4644
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9982
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * quickfix.c: functions for quickfix mode, using a file with error messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #if defined(FEAT_QUICKFIX) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 struct dir_stack_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 struct dir_stack_T *next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char_u *dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 /*
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
25 * For each error the next struct is allocated and linked in a list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
27 typedef struct qfline_S qfline_T;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
28 struct qfline_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
30 qfline_T *qf_next; /* pointer to next error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
31 qfline_T *qf_prev; /* pointer to previous error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
32 linenr_T qf_lnum; /* line number where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
33 int qf_fnum; /* file number for the line */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
34 int qf_col; /* column where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
35 int qf_nr; /* error number */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
36 char_u *qf_pattern; /* search pattern for the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
37 char_u *qf_text; /* description of the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
38 char_u qf_viscol; /* set to TRUE if qf_col is screen column */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
39 char_u qf_cleared; /* set to TRUE if line has been deleted */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
40 char_u qf_type; /* type of the error (mostly 'E'); 1 for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 :helpgrep */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
42 char_u qf_valid; /* valid error message detected */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 * There is a stack of error lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #define LISTCOUNT 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
50 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
51 * Quickfix/Location list definition
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
52 * Contains a list of entries (qfline_T). qf_start points to the first entry
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
53 * and qf_last points to the last entry. qf_count contains the list size.
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
54 *
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
55 * Usually the list contains one or more entries. But an empty list can be
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
56 * created using setqflist()/setloclist() with a title and/or user context
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
57 * information and entries can be added later using setqflist()/setloclist().
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
58 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
59 typedef struct qf_list_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 {
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
61 int_u qf_id; /* Unique identifier for this list */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
62 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
63 qfline_T *qf_last; /* pointer to the last error */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
64 qfline_T *qf_ptr; /* pointer to the current error */
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
65 int qf_count; /* number of errors (0 means empty list) */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
66 int qf_index; /* current index in the error list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
67 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
68 char_u *qf_title; /* title derived from the command that created
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
69 * the error list or set by setqflist */
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
70 typval_T *qf_ctx; /* context set by setqflist/setloclist */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
71
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
72 struct dir_stack_T *qf_dir_stack;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
73 char_u *qf_directory;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
74 struct dir_stack_T *qf_file_stack;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
75 char_u *qf_currfile;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
76 int qf_multiline;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
77 int qf_multiignore;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
78 int qf_multiscan;
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
79 long qf_changedtick;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
80 } qf_list_T;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
81
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
82 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
83 * Quickfix/Location list stack definition
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
84 * Contains a list of quickfix/location lists (qf_list_T)
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
85 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
86 struct qf_info_S
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
87 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
88 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
89 * Count of references to this list. Used only for location lists.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
90 * When a location list window reference this list, qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
91 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
92 * reaches 0, the list is freed.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
93 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
94 int qf_refcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
95 int qf_listcount; /* current number of lists */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
96 int qf_curlist; /* current error list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
97 qf_list_T qf_lists[LISTCOUNT];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
98 };
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
99
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
100 static qf_info_T ql_info; /* global quickfix list */
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
101 static int_u last_qf_id = 0; /* Last used quickfix list id */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
103 #define FMT_PATTERNS 10 /* maximum number of % recognized */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 * Structure used to hold the info of one part of 'errorformat'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
108 typedef struct efm_S efm_T;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
109 struct efm_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 regprog_T *prog; /* pre-formatted part of 'errorformat' */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
112 efm_T *next; /* pointer to next (NULL if last) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 char_u prefix; /* prefix of this format line: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 /* 'D' enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 /* 'X' leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 /* 'A' start of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 /* 'E' error message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 /* 'W' warning message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 /* 'I' informational message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 /* 'C' continuation line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 /* 'Z' end of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 /* 'G' general, unspecific message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 /* 'P' push file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 /* 'Q' pop/quit file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 /* 'O' overread (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 char_u flags; /* additional flags given in prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 /* '-' do not include this line */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
129 /* '+' include whole line in message */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
130 int conthere; /* %> used */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
133 static efm_T *fmt_start = NULL; /* cached across qf_parse_line() calls */
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
134
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
135 static int qf_init_ext(qf_info_T *qi, int qf_idx, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title, char_u *enc);
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
136 static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
137 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
138 static void ll_free_all(qf_info_T **pqi);
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
139 static int qf_add_entry(qf_info_T *qi, int qf_idx, 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
140 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
141 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
142 static char_u *qf_types(int, int);
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
143 static int qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *, char_u *);
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
144 static char_u *qf_push_dir(char_u *, struct dir_stack_T **, int is_file_stack);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
145 static char_u *qf_pop_dir(struct dir_stack_T **);
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
146 static char_u *qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
147 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
148 static void qf_clean_dir_stack(struct dir_stack_T **);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
149 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
150 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
151 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
152 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
153 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
154 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
155 static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
156 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
157 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
158 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
159 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
160 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
161 static qf_info_T *ll_get_or_alloc_list(win_T *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
163 /* Quickfix window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
164 #define IS_QF_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
165 /* Location list window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
166 #define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
167 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
168 * Return location list for window 'wp'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
169 * For location list window, return the referenced location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
170 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
171 #define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
172
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 /*
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
174 * Looking up a buffer can be slow if there are many. Remember the last one
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
175 * to make this a lot faster if there are multiple matches in the same file.
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
176 */
11447
698ee9d4fe9f patch 8.0.0607: after :bwipe + :new bufref might still be valid
Christian Brabandt <cb@256bit.org>
parents: 11445
diff changeset
177 static char_u *qf_last_bufname = NULL;
698ee9d4fe9f patch 8.0.0607: after :bwipe + :new bufref might still be valid
Christian Brabandt <cb@256bit.org>
parents: 11445
diff changeset
178 static bufref_T qf_last_bufref = {NULL, 0, 0};
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
179
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
180 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
181 * 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
182 * list. Set the error list's title to qf_title.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 * Return -1 for error, number of errors for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 int
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
186 qf_init(win_T *wp,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
187 char_u *efile,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
188 char_u *errorformat,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
189 int newlist, /* TRUE: start a new error list */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
190 char_u *qf_title,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
191 char_u *enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
193 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
194
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
195 if (wp != NULL)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
196 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
197 qi = ll_get_or_alloc_list(wp);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
198 if (qi == NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
199 return FAIL;
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
200 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
201
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
202 return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
203 newlist, (linenr_T)0, (linenr_T)0, qf_title, enc);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
204 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
205
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
206 /*
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
207 * 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
208 */
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
209 #define LINE_MAXLEN 4096
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
210
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
211 static struct fmtpattern
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
212 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
213 char_u convchar;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
214 char *pattern;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
215 } fmt_pat[FMT_PATTERNS] =
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
216 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
217 {'f', ".\\+"}, /* only used when at end */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
218 {'n', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
219 {'l', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
220 {'c', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
221 {'t', "."},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
222 {'m', ".\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
223 {'r', ".*"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
224 {'p', "[- .]*"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
225 {'v', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
226 {'s', ".\\+"}
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
227 };
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 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
230 * 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
231 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
232 static int
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
233 efm_to_regpat(
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
234 char_u *efm,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
235 int len,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
236 efm_T *fmt_ptr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
237 char_u *regpat,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
238 char_u *errmsg)
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
239 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
240 char_u *ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
241 char_u *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
242 char_u *srcptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
243 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
244 int idx = 0;
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 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
247 * 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
248 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
249 ptr = regpat;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
250 *ptr++ = '^';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
251 round = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
252 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
253 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
254 if (*efmp == '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
255 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
256 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
257 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
258 if (fmt_pat[idx].convchar == *efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
259 break;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
260 if (idx < FMT_PATTERNS)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
261 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
262 if (fmt_ptr->addr[idx])
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
263 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
264 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
265 _("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
266 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
267 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
268 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
269 if ((idx
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 *)"DXOPQ",
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 || (idx == 6
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
274 && vim_strchr((char_u *)"OPQ",
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
275 fmt_ptr->prefix) == NULL))
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
276 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
277 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
278 _("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
279 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
280 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
281 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
282 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
283 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
284 *ptr++ = '(';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
285 #ifdef BACKSLASH_IN_FILENAME
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
286 if (*efmp == 'f')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
287 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
288 /* 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
289 * checking for a colon next: "%f:".
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
290 * "\%(\a:\)\=" */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
291 STRCPY(ptr, "\\%(\\a:\\)\\=");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
292 ptr += 10;
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 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
295 if (*efmp == 'f' && efmp[1] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
296 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
297 if (efmp[1] != '\\' && efmp[1] != '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
298 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
299 /* 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
300 * 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
301 * 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
302 * 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
303 * follows should work. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
304 STRCPY(ptr, ".\\{-1,}");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
305 ptr += 7;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
306 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
307 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
308 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
309 /* 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
310 * many file name chars as possible. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
311 STRCPY(ptr, "\\f\\+");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
312 ptr += 4;
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 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
315 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
316 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
317 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
318 while ((*ptr = *srcptr++) != NUL)
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 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
322 *ptr++ = ')';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
323 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
324 else if (*efmp == '*')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
325 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
326 if (*++efmp == '[' || *efmp == '\\')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
327 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
328 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
329 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
330 if (efmp[1] == '^')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
331 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
332 if (efmp < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
333 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
334 *ptr++ = *++efmp; /* could be ']' */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
335 while (efmp < efm + len
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
336 && (*ptr++ = *++efmp) != ']')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
337 /* skip */;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
338 if (efmp == efm + len)
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 EMSG(_("E374: Missing ] in format string"));
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
341 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
342 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
343 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
344 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
345 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
346 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
347 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
348 *ptr++ = '+';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
349 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
350 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
351 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
352 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
353 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
354 _("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
355 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
356 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
357 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
358 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
359 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
360 *ptr++ = *efmp; /* regexp magic characters */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
361 else if (*efmp == '#')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
362 *ptr++ = '*';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
363 else if (*efmp == '>')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
364 fmt_ptr->conthere = TRUE;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
365 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
366 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
367 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
368 fmt_ptr->flags = *efmp++;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
369 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
370 fmt_ptr->prefix = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
371 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
372 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
373 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
374 _("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
375 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
376 return -1;
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 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
379 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
380 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
381 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
382 _("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
383 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
384 return -1;
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 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
387 else /* copy normal character */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
388 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
389 if (*efmp == '\\' && efmp + 1 < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
390 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
391 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
392 *ptr++ = '\\'; /* escape regexp atoms */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
393 if (*efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
394 *ptr++ = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
395 }
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 *ptr++ = '$';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
398 *ptr = NUL;
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 return 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
401 }
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 static void
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
404 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
405 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
406 efm_T *efm_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
407
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
408 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
409 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
410 *efm_first = efm_ptr->next;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
411 vim_regfree(efm_ptr->prog);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
412 vim_free(efm_ptr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
413 }
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
414 fmt_start = NULL;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
415 }
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 /* Parse 'errorformat' option */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
418 static efm_T *
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
419 parse_efm_option(char_u *efm)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
420 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
421 char_u *errmsg = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
422 int errmsglen;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
423 efm_T *fmt_ptr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
424 efm_T *fmt_first = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
425 efm_T *fmt_last = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
426 char_u *fmtstr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
427 int len;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
428 int i;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
429 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
430
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
431 errmsglen = CMDBUFFSIZE + 1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
432 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
433 if (errmsg == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
434 goto parse_efm_end;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
435
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
436 /*
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
437 * Each part of the format string is copied and modified from errorformat
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
438 * to regex prog. Only a few % characters are allowed.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
439 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
440
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
441 /*
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
442 * 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
443 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
444 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
445 for (round = FMT_PATTERNS; round > 0; )
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
446 i += (int)STRLEN(fmt_pat[--round].pattern);
12531
c7164578e508 patch 8.0.1144: using wrong #ifdef for computing length
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
447 #ifdef BACKSLASH_IN_FILENAME
c7164578e508 patch 8.0.1144: using wrong #ifdef for computing length
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
448 i += 12; /* "%f" can become twelve chars longer (see efm_to_regpat) */
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
449 #else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
450 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
451 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
452 if ((fmtstr = alloc(i)) == 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
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
455 while (efm[0] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
456 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
457 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
458 * 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
459 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
460 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
461 if (fmt_ptr == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
462 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
463 if (fmt_first == NULL) /* first one */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
464 fmt_first = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
465 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
466 fmt_last->next = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
467 fmt_last = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
468
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
469 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
470 * 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
471 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
472 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
473 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
474 ++len;
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 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
477 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
478 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
479 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
480 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
481 * Advance to next part
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
482 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
483 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
484 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
485
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
486 if (fmt_first == NULL) /* nothing found */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
487 EMSG(_("E378: 'errorformat' contains no pattern"));
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 goto parse_efm_end;
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 parse_efm_error:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
492 free_efm_list(&fmt_first);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
493
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
494 parse_efm_end:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
495 vim_free(fmtstr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
496 vim_free(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
497
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
498 return fmt_first;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
499 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
500
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
501 enum {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
502 QF_FAIL = 0,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
503 QF_OK = 1,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
504 QF_END_OF_INPUT = 2,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
505 QF_NOMEM = 3,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
506 QF_IGNORE_LINE = 4
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
507 };
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
508
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
509 typedef struct {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
510 char_u *linebuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
511 int linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
512 char_u *growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
513 int growbufsiz;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
514 FILE *fd;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
515 typval_T *tv;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
516 char_u *p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
517 listitem_T *p_li;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
518 buf_T *buf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
519 linenr_T buflnum;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
520 linenr_T lnumlast;
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
521 vimconv_T vc;
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
522 } qfstate_T;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
523
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
524 static char_u *
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
525 qf_grow_linebuf(qfstate_T *state, int newsz)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
526 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
527 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
528 * If the line exceeds LINE_MAXLEN exclude the last
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
529 * byte since it's not a NL character.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
530 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
531 state->linelen = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
532 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
533 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
534 state->growbuf = alloc(state->linelen + 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
535 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
536 return NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
537 state->growbufsiz = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
538 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
539 else if (state->linelen > state->growbufsiz)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
540 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
541 state->growbuf = vim_realloc(state->growbuf, state->linelen + 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
542 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
543 return NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
544 state->growbufsiz = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
545 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
546 return state->growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
547 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
548
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
549 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
550 * Get the next string (separated by newline) from state->p_str.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
551 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
552 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
553 qf_get_next_str_line(qfstate_T *state)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
554 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
555 /* Get the next line from the supplied string */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
556 char_u *p_str = state->p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
557 char_u *p;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
558 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
559
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
560 if (*p_str == NUL) /* Reached the end of the string */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
561 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
562
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
563 p = vim_strchr(p_str, '\n');
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
564 if (p != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
565 len = (int)(p - p_str) + 1;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
566 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
567 len = (int)STRLEN(p_str);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
568
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
569 if (len > IOSIZE - 2)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
570 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
571 state->linebuf = qf_grow_linebuf(state, len);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
572 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
573 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
574 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
575 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
576 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
577 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
578 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
579 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
580 vim_strncpy(state->linebuf, p_str, state->linelen);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
581
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
582 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
583 * Increment using len in order to discard the rest of the
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
584 * line if it exceeds LINE_MAXLEN.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
585 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
586 p_str += len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
587 state->p_str = p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
588
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
589 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
590 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
591
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
592 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
593 * Get the next string from state->p_Li.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
594 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
595 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
596 qf_get_next_list_line(qfstate_T *state)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
597 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
598 listitem_T *p_li = state->p_li;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
599 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
600
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
601 while (p_li != NULL
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
602 && (p_li->li_tv.v_type != VAR_STRING
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
603 || p_li->li_tv.vval.v_string == NULL))
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
604 p_li = p_li->li_next; /* Skip non-string items */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
605
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
606 if (p_li == NULL) /* End of the list */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
607 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
608 state->p_li = NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
609 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
610 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
611
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
612 len = (int)STRLEN(p_li->li_tv.vval.v_string);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
613 if (len > IOSIZE - 2)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
614 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
615 state->linebuf = qf_grow_linebuf(state, len);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
616 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
617 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
618 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
619 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
620 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
621 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
622 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
623 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
624
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
625 vim_strncpy(state->linebuf, p_li->li_tv.vval.v_string, state->linelen);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
626
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
627 state->p_li = p_li->li_next; /* next item */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
628 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
629 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
630
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
631 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
632 * Get the next string from state->buf.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
633 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
634 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
635 qf_get_next_buf_line(qfstate_T *state)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
636 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
637 char_u *p_buf = NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
638 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
639
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
640 /* Get the next line from the supplied buffer */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
641 if (state->buflnum > state->lnumlast)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
642 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
643
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
644 p_buf = ml_get_buf(state->buf, state->buflnum, FALSE);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
645 state->buflnum += 1;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
646
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
647 len = (int)STRLEN(p_buf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
648 if (len > IOSIZE - 2)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
649 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
650 state->linebuf = qf_grow_linebuf(state, len);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
651 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
652 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
653 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
654 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
655 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
656 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
657 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
658 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
659 vim_strncpy(state->linebuf, p_buf, state->linelen);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
660
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
661 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
662 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
663
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
664 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
665 * Get the next string from file state->fd.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
666 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
667 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
668 qf_get_next_file_line(qfstate_T *state)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
669 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
670 int discard;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
671 int growbuflen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
672
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
673 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
674 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
675
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
676 discard = FALSE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
677 state->linelen = (int)STRLEN(IObuff);
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
678 if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\n'))
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
679 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
680 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
681 * The current line exceeds IObuff, continue reading using
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
682 * growbuf until EOL or LINE_MAXLEN bytes is read.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
683 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
684 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
685 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
686 state->growbufsiz = 2 * (IOSIZE - 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
687 state->growbuf = alloc(state->growbufsiz);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
688 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
689 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
690 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
691
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
692 /* Copy the read part of the line, excluding null-terminator */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
693 memcpy(state->growbuf, IObuff, IOSIZE - 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
694 growbuflen = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
695
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
696 for (;;)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
697 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
698 if (fgets((char *)state->growbuf + growbuflen,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
699 state->growbufsiz - growbuflen, state->fd) == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
700 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
701 state->linelen = (int)STRLEN(state->growbuf + growbuflen);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
702 growbuflen += state->linelen;
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
703 if ((state->growbuf)[growbuflen - 1] == '\n')
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
704 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
705 if (state->growbufsiz == LINE_MAXLEN)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
706 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
707 discard = TRUE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
708 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
709 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
710
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
711 state->growbufsiz = 2 * state->growbufsiz < LINE_MAXLEN
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
712 ? 2 * state->growbufsiz : LINE_MAXLEN;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
713 state->growbuf = vim_realloc(state->growbuf, state->growbufsiz);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
714 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
715 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
716 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
717
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
718 while (discard)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
719 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
720 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
721 * The current line is longer than LINE_MAXLEN, continue
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
722 * reading but discard everything until EOL or EOF is
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
723 * reached.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
724 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
725 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
726 || (int)STRLEN(IObuff) < IOSIZE - 1
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
727 || IObuff[IOSIZE - 1] == '\n')
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
728 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
729 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
730
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
731 state->linebuf = state->growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
732 state->linelen = growbuflen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
733 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
734 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
735 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
736
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
737 #ifdef FEAT_MBYTE
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
738 /* Convert a line if it contains a non-ASCII character. */
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
739 if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf))
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
740 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
741 char_u *line;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
742
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
743 line = string_convert(&state->vc, state->linebuf, &state->linelen);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
744 if (line != NULL)
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
745 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
746 if (state->linelen < IOSIZE)
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
747 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
748 STRCPY(state->linebuf, line);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
749 vim_free(line);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
750 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
751 else
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
752 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
753 vim_free(state->growbuf);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
754 state->linebuf = state->growbuf = line;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
755 state->growbufsiz = state->linelen < LINE_MAXLEN
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
756 ? state->linelen : LINE_MAXLEN;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
757 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
758 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
759 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
760 #endif
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
761
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
762 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
763 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
764
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
765 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
766 * Get the next string from a file/buffer/list/string.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
767 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
768 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
769 qf_get_nextline(qfstate_T *state)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
770 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
771 int status = QF_FAIL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
772
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
773 if (state->fd == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
774 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
775 if (state->tv != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
776 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
777 if (state->tv->v_type == VAR_STRING)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
778 /* Get the next line from the supplied string */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
779 status = qf_get_next_str_line(state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
780 else if (state->tv->v_type == VAR_LIST)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
781 /* Get the next line from the supplied list */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
782 status = qf_get_next_list_line(state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
783 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
784 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
785 /* Get the next line from the supplied buffer */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
786 status = qf_get_next_buf_line(state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
787 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
788 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
789 /* Get the next line from the supplied file */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
790 status = qf_get_next_file_line(state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
791
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
792 if (status != QF_OK)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
793 return status;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
794
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
795 /* remove newline/CR from the line */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
796 if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\n')
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
797 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
798 state->linebuf[state->linelen - 1] = NUL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
799 #ifdef USE_CRNL
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
800 if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r')
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
801 state->linebuf[state->linelen - 2] = NUL;
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
802 #endif
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
803 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
804
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
805 #ifdef FEAT_MBYTE
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
806 remove_bom(state->linebuf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
807 #endif
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
808
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
809 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
810 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
811
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
812 typedef struct {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
813 char_u *namebuf;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
814 char_u *errmsg;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
815 int errmsglen;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
816 long lnum;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
817 int col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
818 char_u use_viscol;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
819 char_u *pattern;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
820 int enr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
821 int type;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
822 int valid;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
823 } qffields_T;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
824
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
825 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
826 * Parse a line and get the quickfix fields.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
827 * Return the QF_ status.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
828 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
829 static int
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
830 qf_parse_line(
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
831 qf_info_T *qi,
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
832 int qf_idx,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
833 char_u *linebuf,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
834 int linelen,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
835 efm_T *fmt_first,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
836 qffields_T *fields)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
837 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
838 efm_T *fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
839 char_u *ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
840 int len;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
841 int i;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
842 int idx = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
843 char_u *tail = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
844 regmatch_T regmatch;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
845 qf_list_T *qfl = &qi->qf_lists[qf_idx];
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
846
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
847 /* Always ignore case when looking for a matching error. */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
848 regmatch.rm_ic = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
849
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
850 /* If there was no %> item start at the first pattern */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
851 if (fmt_start == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
852 fmt_ptr = fmt_first;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
853 else
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
854 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
855 fmt_ptr = fmt_start;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
856 fmt_start = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
857 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
858
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
859 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
860 * Try to match each part of 'errorformat' until we find a complete
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
861 * match or no match.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
862 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
863 fields->valid = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
864 restofline:
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
865 for ( ; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
866 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
867 int r;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
868
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
869 idx = fmt_ptr->prefix;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
870 if (qfl->qf_multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
871 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
872 fields->namebuf[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
873 fields->pattern[0] = NUL;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
874 if (!qfl->qf_multiscan)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
875 fields->errmsg[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
876 fields->lnum = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
877 fields->col = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
878 fields->use_viscol = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
879 fields->enr = -1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
880 fields->type = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
881 tail = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
882
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
883 regmatch.regprog = fmt_ptr->prog;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
884 r = vim_regexec(&regmatch, linebuf, (colnr_T)0);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
885 fmt_ptr->prog = regmatch.regprog;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
886 if (r)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
887 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
888 if ((idx == 'C' || idx == 'Z') && !qfl->qf_multiline)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
889 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
890 if (vim_strchr((char_u *)"EWI", idx) != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
891 fields->type = idx;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
892 else
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
893 fields->type = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
894 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
895 * Extract error message data from matched line.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
896 * We check for an actual submatch, because "\[" and "\]" in
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
897 * the 'errorformat' may cause the wrong submatch to be used.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
898 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
899 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
900 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
901 int c;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
902
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
903 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
904 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
905
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
906 /* Expand ~/file and $HOME/file to full path. */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
907 c = *regmatch.endp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
908 *regmatch.endp[i] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
909 expand_env(regmatch.startp[i], fields->namebuf, CMDBUFFSIZE);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
910 *regmatch.endp[i] = c;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
911
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
912 if (vim_strchr((char_u *)"OPQ", idx) != NULL
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
913 && mch_getperm(fields->namebuf) == -1)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
914 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
915 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
916 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
917 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
918 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
919 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
920 fields->enr = (int)atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
921 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
922 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
923 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
924 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
925 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
926 fields->lnum = atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
927 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
928 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
929 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
930 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
931 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
932 fields->col = (int)atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
933 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
934 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
935 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
936 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
937 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
938 fields->type = *regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
939 }
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
940 if (fmt_ptr->flags == '+' && !qfl->qf_multiscan) /* %+ */
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
941 {
11426
3270f080bf0a patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents: 11422
diff changeset
942 if (linelen >= fields->errmsglen)
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
943 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
944 /* linelen + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
945 if ((fields->errmsg = vim_realloc(fields->errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
946 linelen + 1)) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
947 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
948 fields->errmsglen = linelen + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
949 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
950 vim_strncpy(fields->errmsg, linebuf, linelen);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
951 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
952 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
953 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
954 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
955 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
956 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
11426
3270f080bf0a patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents: 11422
diff changeset
957 if (len >= fields->errmsglen)
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
958 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
959 /* len + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
960 if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
961 == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
962 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
963 fields->errmsglen = len + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
964 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
965 vim_strncpy(fields->errmsg, regmatch.startp[i], len);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
966 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
967 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
968 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
969 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
970 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
971 tail = regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
972 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
973 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
974 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
975 char_u *match_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
976
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
977 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
978 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
979 fields->col = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
980 for (match_ptr = regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
981 match_ptr != regmatch.endp[i]; ++match_ptr)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
982 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
983 ++fields->col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
984 if (*match_ptr == TAB)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
985 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
986 fields->col += 7;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
987 fields->col -= fields->col % 8;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
988 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
989 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
990 ++fields->col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
991 fields->use_viscol = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
992 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
993 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
994 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
995 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
996 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
997 fields->col = (int)atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
998 fields->use_viscol = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
999 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1000 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1001 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1002 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1003 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1004 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1005 if (len > CMDBUFFSIZE - 5)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1006 len = CMDBUFFSIZE - 5;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1007 STRCPY(fields->pattern, "^\\V");
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1008 STRNCAT(fields->pattern, regmatch.startp[i], len);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1009 fields->pattern[len + 3] = '\\';
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1010 fields->pattern[len + 4] = '$';
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1011 fields->pattern[len + 5] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1012 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1013 break;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1014 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1015 }
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1016 qfl->qf_multiscan = FALSE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1017
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1018 if (fmt_ptr == NULL || idx == 'D' || idx == 'X')
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1019 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1020 if (fmt_ptr != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1021 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1022 if (idx == 'D') /* enter directory */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1023 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1024 if (*fields->namebuf == NUL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1025 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1026 EMSG(_("E379: Missing or empty directory name"));
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1027 return QF_FAIL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1028 }
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1029 qfl->qf_directory =
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1030 qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE);
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1031 if (qfl->qf_directory == NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1032 return QF_FAIL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1033 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1034 else if (idx == 'X') /* leave directory */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1035 qfl->qf_directory = qf_pop_dir(&qfl->qf_dir_stack);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1036 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1037 fields->namebuf[0] = NUL; /* no match found, remove file name */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1038 fields->lnum = 0; /* don't jump to this line */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1039 fields->valid = FALSE;
11426
3270f080bf0a patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents: 11422
diff changeset
1040 if (linelen >= fields->errmsglen)
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
1041 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1042 /* linelen + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1043 if ((fields->errmsg = vim_realloc(fields->errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1044 linelen + 1)) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1045 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1046 fields->errmsglen = linelen + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1047 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1048 /* copy whole line to error message */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1049 vim_strncpy(fields->errmsg, linebuf, linelen);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1050 if (fmt_ptr == NULL)
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1051 qfl->qf_multiline = qfl->qf_multiignore = FALSE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1052 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1053 else if (fmt_ptr != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1054 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1055 /* honor %> item */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1056 if (fmt_ptr->conthere)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1057 fmt_start = fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1058
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1059 if (vim_strchr((char_u *)"AEWI", idx) != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1060 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1061 qfl->qf_multiline = TRUE; /* start of a multi-line message */
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1062 qfl->qf_multiignore = FALSE;/* reset continuation */
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1063 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1064 else if (vim_strchr((char_u *)"CZ", idx) != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1065 { /* continuation of multi-line msg */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1066 if (!qfl->qf_multiignore)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1067 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1068 qfline_T *qfprev = qfl->qf_last;
10257
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1069
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1070 if (qfprev == NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1071 return QF_FAIL;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1072 if (*fields->errmsg && !qfl->qf_multiignore)
10257
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1073 {
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1074 len = (int)STRLEN(qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1075 if ((ptr = alloc((unsigned)(len + STRLEN(fields->errmsg) + 2)))
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1076 == NULL)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1077 return QF_FAIL;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1078 STRCPY(ptr, qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1079 vim_free(qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1080 qfprev->qf_text = ptr;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1081 *(ptr += len) = '\n';
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1082 STRCPY(++ptr, fields->errmsg);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1083 }
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1084 if (qfprev->qf_nr == -1)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1085 qfprev->qf_nr = fields->enr;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1086 if (vim_isprintc(fields->type) && !qfprev->qf_type)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1087 /* only printable chars allowed */
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1088 qfprev->qf_type = fields->type;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1089
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1090 if (!qfprev->qf_lnum)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1091 qfprev->qf_lnum = fields->lnum;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1092 if (!qfprev->qf_col)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1093 qfprev->qf_col = fields->col;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1094 qfprev->qf_viscol = fields->use_viscol;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1095 if (!qfprev->qf_fnum)
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1096 qfprev->qf_fnum = qf_get_fnum(qi, qf_idx,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1097 qfl->qf_directory,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1098 *fields->namebuf || qfl->qf_directory != NULL
10257
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1099 ? fields->namebuf
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1100 : qfl->qf_currfile != NULL && fields->valid
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1101 ? qfl->qf_currfile : 0);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1102 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1103 if (idx == 'Z')
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1104 qfl->qf_multiline = qfl->qf_multiignore = FALSE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1105 line_breakcheck();
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1106 return QF_IGNORE_LINE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1107 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1108 else if (vim_strchr((char_u *)"OPQ", idx) != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1109 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1110 /* global file names */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1111 fields->valid = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1112 if (*fields->namebuf == NUL || mch_getperm(fields->namebuf) >= 0)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1113 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1114 if (*fields->namebuf && idx == 'P')
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1115 qfl->qf_currfile =
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1116 qf_push_dir(fields->namebuf, &qfl->qf_file_stack, TRUE);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1117 else if (idx == 'Q')
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1118 qfl->qf_currfile = qf_pop_dir(&qfl->qf_file_stack);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1119 *fields->namebuf = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1120 if (tail && *tail)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1121 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1122 STRMOVE(IObuff, skipwhite(tail));
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1123 qfl->qf_multiscan = TRUE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1124 goto restofline;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1125 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1126 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1127 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1128 if (fmt_ptr->flags == '-') /* generally exclude this line */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1129 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1130 if (qfl->qf_multiline)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1131 /* also exclude continuation lines */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1132 qfl->qf_multiignore = TRUE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1133 return QF_IGNORE_LINE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1134 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1135 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1136
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1137 return QF_OK;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1138 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1139
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
1140 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1141 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1142 * list.
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1143 * 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
1144 * Alternative: when "tv" is not NULL get errors from the string or list.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1145 * 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
1146 * 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
1147 * Set the title of the list to "qf_title".
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1148 * Return -1 for error, number of errors for success.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1149 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1150 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1151 qf_init_ext(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1152 qf_info_T *qi,
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1153 int qf_idx,
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1154 char_u *efile,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1155 buf_T *buf,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1156 typval_T *tv,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1157 char_u *errorformat,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1158 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
1159 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
1160 linenr_T lnumlast, /* last line number to use */
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1161 char_u *qf_title,
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1162 char_u *enc)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1163 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1164 qf_list_T *qfl;
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1165 qfstate_T state;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1166 qffields_T fields;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1167 qfline_T *old_last = NULL;
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1168 int adding = FALSE;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1169 static efm_T *fmt_first = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 char_u *efm;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1171 static char_u *last_efm = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 int retval = -1; /* default: return error flag */
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1173 int status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1174
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1175 /* Do not used the cached buffer, it may have been wiped out. */
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1176 vim_free(qf_last_bufname);
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1177 qf_last_bufname = NULL;
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1178
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1179 vim_memset(&state, 0, sizeof(state));
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1180 vim_memset(&fields, 0, sizeof(fields));
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1181 #ifdef FEAT_MBYTE
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1182 state.vc.vc_type = CONV_NONE;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1183 if (enc != NULL && *enc != NUL)
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1184 convert_setup(&state.vc, enc, p_enc);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1185 #endif
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1186 fields.namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1187 fields.errmsglen = CMDBUFFSIZE + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1188 fields.errmsg = alloc_id(fields.errmsglen, aid_qf_errmsg);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1189 fields.pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern);
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
1190 if (fields.namebuf == NULL || fields.errmsg == NULL || fields.pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1193 if (efile != NULL && (state.fd = mch_fopen((char *)efile, "r")) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 EMSG2(_(e_openerrf), efile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1199 if (newlist || qf_idx == qi->qf_listcount)
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1200 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
1202 qf_new_list(qi, qf_title);
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1203 qf_idx = qi->qf_curlist;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1204 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
1205 else
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1206 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1207 /* Adding to existing list, use last entry. */
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1208 adding = TRUE;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1209 if (qi->qf_lists[qf_idx].qf_count > 0)
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1210 old_last = qi->qf_lists[qf_idx].qf_last;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1211 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1213 qfl = &qi->qf_lists[qf_idx];
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1214
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 /* Use the local value of 'errorformat' if it's set. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1216 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1217 efm = buf->b_p_efm;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 efm = errorformat;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1220
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1221 /*
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1222 * If the errorformat didn't change between calls, then reuse the
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1223 * previously parsed values.
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1224 */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1225 if (last_efm == NULL || (STRCMP(last_efm, efm) != 0))
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1226 {
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1227 /* free the previously parsed data */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1228 vim_free(last_efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1229 last_efm = NULL;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1230 free_efm_list(&fmt_first);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1231
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1232 /* parse the current 'efm' */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1233 fmt_first = parse_efm_option(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1234 if (fmt_first != NULL)
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1235 last_efm = vim_strsave(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1236 }
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1237
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1238 if (fmt_first == NULL) /* nothing found */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 * got_int is reset here, because it was probably set when killing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 * ":make" command, but we still want to read the errorfile then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1247 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1248 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1249 if (tv->v_type == VAR_STRING)
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1250 state.p_str = tv->vval.v_string;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1251 else if (tv->v_type == VAR_LIST)
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1252 state.p_li = tv->vval.v_list->lv_first;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1253 state.tv = tv;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1254 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1255 state.buf = buf;
9534
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1256 state.buflnum = lnumfirst;
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1257 state.lnumlast = lnumlast;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1258
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 * Read the lines in the error file one by one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 * Try to recognize one of the error formats in each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1263 while (!got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1265 /* Get the next line from a file/buffer/list/string */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1266 status = qf_get_nextline(&state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1267 if (status == QF_NOMEM) /* memory alloc failure */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1268 goto qf_init_end;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1269 if (status == QF_END_OF_INPUT) /* end of input */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1270 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1272 status = qf_parse_line(qi, qf_idx, state.linebuf, state.linelen,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1273 fmt_first, &fields);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1274 if (status == QF_FAIL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1275 goto error2;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1276 if (status == QF_NOMEM)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1277 goto qf_init_end;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1278 if (status == QF_IGNORE_LINE)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1279 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1281 if (qf_add_entry(qi,
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1282 qf_idx,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1283 qfl->qf_directory,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1284 (*fields.namebuf || qfl->qf_directory != NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1285 ? fields.namebuf
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1286 : ((qfl->qf_currfile != NULL && fields.valid)
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1287 ? qfl->qf_currfile : (char_u *)NULL),
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1288 0,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1289 fields.errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1290 fields.lnum,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1291 fields.col,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1292 fields.use_viscol,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1293 fields.pattern,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1294 fields.enr,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1295 fields.type,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1296 fields.valid) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1300 if (state.fd == NULL || !ferror(state.fd))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1302 if (qfl->qf_index == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1304 /* no valid entry found */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1305 qfl->qf_ptr = qfl->qf_start;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1306 qfl->qf_index = 1;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1307 qfl->qf_nonevalid = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1311 qfl->qf_nonevalid = FALSE;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1312 if (qfl->qf_ptr == NULL)
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1313 qfl->qf_ptr = qfl->qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1315 /* return number of matches */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1316 retval = qfl->qf_count;
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1317 goto qf_init_end;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 EMSG(_(e_readerrf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 error2:
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1321 if (!adding)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1322 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1323 /* Error when creating a new list. Free the new list */
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1324 qf_free(qi, qi->qf_curlist);
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1325 qi->qf_listcount--;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1326 if (qi->qf_curlist > 0)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1327 --qi->qf_curlist;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1328 }
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1329 qf_init_end:
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1330 if (state.fd != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1331 fclose(state.fd);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1332 vim_free(fields.namebuf);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1333 vim_free(fields.errmsg);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1334 vim_free(fields.pattern);
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1335 vim_free(state.growbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1337 if (qf_idx == qi->qf_curlist)
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1338 qf_update_buffer(qi, old_last);
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1339 #ifdef FEAT_MBYTE
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1340 if (state.vc.vc_type != CONV_NONE)
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1341 convert_setup(&state.vc, NULL, NULL);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1342 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1347 static void
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1348 qf_store_title(qf_info_T *qi, int qf_idx, char_u *title)
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1349 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1350 vim_free(qi->qf_lists[qf_idx].qf_title);
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1351 qi->qf_lists[qf_idx].qf_title = NULL;
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1352
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1353 if (title != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1354 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1355 char_u *p = alloc((int)STRLEN(title) + 2);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1356
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1357 qi->qf_lists[qf_idx].qf_title = p;
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1358 if (p != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1359 sprintf((char *)p, ":%s", (char *)title);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1360 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1361 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1362
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 /*
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
1364 * Prepare for adding a new quickfix list. If the current list is in the
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
1365 * middle of the stack, then all the following lists are freed and then
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
1366 * the new list is added.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1369 qf_new_list(qf_info_T *qi, char_u *qf_title)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 /*
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1374 * If the current entry is not the last entry, delete entries beyond
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 * the current entry. This makes it possible to browse in a tree-like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 * way with ":grep'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1378 while (qi->qf_listcount > qi->qf_curlist + 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1379 qf_free(qi, --qi->qf_listcount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 * When the stack is full, remove to oldest entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 * Otherwise, add a new entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1385 if (qi->qf_listcount == LISTCOUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1387 qf_free(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 for (i = 1; i < LISTCOUNT; ++i)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1389 qi->qf_lists[i - 1] = qi->qf_lists[i];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1390 qi->qf_curlist = LISTCOUNT - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 else
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1393 qi->qf_curlist = qi->qf_listcount++;
3259
9eb7fdfb5e63 updated for version 7.3.398
Bram Moolenaar <bram@vim.org>
parents: 3257
diff changeset
1394 vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1395 qf_store_title(qi, qi->qf_curlist, qf_title);
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
1396 qi->qf_lists[qi->qf_curlist].qf_id = ++last_qf_id;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1399 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1400 * Free a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1401 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1402 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1403 ll_free_all(qf_info_T **pqi)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1404 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1405 int i;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1406 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1407
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1408 qi = *pqi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1409 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1410 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1411 *pqi = NULL; /* Remove reference to this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1412
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1413 qi->qf_refcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1414 if (qi->qf_refcount < 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1415 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1416 /* No references to this location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1417 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1418 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1419 vim_free(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1420 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1421 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1422
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1423 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1424 qf_free_all(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1425 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1426 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1427 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1428
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1429 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1430 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1431 /* location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1432 ll_free_all(&wp->w_llist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1433 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1434 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1435 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1436 /* quickfix list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1437 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1438 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1439 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1440
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 * Add an entry to the end of the list of errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1446 qf_add_entry(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1447 qf_info_T *qi, /* quickfix list */
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1448 int qf_idx, /* list index */
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1449 char_u *dir, /* optional directory name */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1450 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
1451 int bufnum, /* buffer number or zero */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1452 char_u *mesg, /* message */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1453 long lnum, /* line number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1454 int col, /* column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1455 int vis_col, /* using visual column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1456 char_u *pattern, /* search pattern */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1457 int nr, /* error number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1458 int type, /* type character */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1459 int valid) /* valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1461 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1462 qfline_T **lastp; /* pointer to qf_last or NULL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1464 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 return FAIL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1466 if (bufnum != 0)
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1467 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1468 buf_T *buf = buflist_findnr(bufnum);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1469
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1470 qfp->qf_fnum = bufnum;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1471 if (buf != NULL)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1472 buf->b_has_qf_entry |=
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1473 (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1474 }
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1475 else
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1476 qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 vim_free(qfp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 qfp->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 qfp->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
1484 qfp->qf_viscol = vis_col;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1485 if (pattern == NULL || *pattern == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1486 qfp->qf_pattern = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1487 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1488 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1489 vim_free(qfp->qf_text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1490 vim_free(qfp);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1491 return FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1492 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 qfp->qf_nr = nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 qfp->qf_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 qfp->qf_valid = valid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1499 lastp = &qi->qf_lists[qf_idx].qf_last;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1500 if (qi->qf_lists[qf_idx].qf_count == 0)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1501 /* first element in the list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1503 qi->qf_lists[qf_idx].qf_start = qfp;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1504 qi->qf_lists[qf_idx].qf_ptr = qfp;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1505 qi->qf_lists[qf_idx].qf_index = 0;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1506 qfp->qf_prev = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1510 qfp->qf_prev = *lastp;
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1511 (*lastp)->qf_next = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 }
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1513 qfp->qf_next = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 qfp->qf_cleared = FALSE;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1515 *lastp = qfp;
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1516 ++qi->qf_lists[qf_idx].qf_count;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1517 if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1518 /* first valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1520 qi->qf_lists[qf_idx].qf_index =
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1521 qi->qf_lists[qf_idx].qf_count;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1522 qi->qf_lists[qf_idx].qf_ptr = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 /*
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1529 * Allocate a new location list
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1530 */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1531 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1532 ll_new_list(void)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1533 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1534 qf_info_T *qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1535
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1536 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1537 if (qi != NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1538 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1539 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1540 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1541 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1542
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1543 return qi;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1544 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1545
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1546 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1547 * Return the location list for window 'wp'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1548 * If not present, allocate a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1549 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1550 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1551 ll_get_or_alloc_list(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1552 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1553 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1554 /* For a location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1555 return wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1556
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1557 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1558 * For a non-location list window, w_llist_ref should not point to a
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1559 * location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1560 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1561 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1562
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1563 if (wp->w_llist == NULL)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1564 wp->w_llist = ll_new_list(); /* new location list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1565 return wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1566 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1567
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1568 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1569 * Copy the location list from window "from" to window "to".
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1570 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1571 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1572 copy_loclist(win_T *from, win_T *to)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1573 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1574 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1575 int idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1576 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1577
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1578 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1579 * When copying from a location list window, copy the referenced
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1580 * location list. For other windows, copy the location list for
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1581 * that window.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1582 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1583 if (IS_LL_WINDOW(from))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1584 qi = from->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1585 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1586 qi = from->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1587
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1588 if (qi == NULL) /* no location list to copy */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1589 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1590
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1591 /* allocate a new location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1592 if ((to->w_llist = ll_new_list()) == NULL)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1593 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1594
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1595 to->w_llist->qf_listcount = qi->qf_listcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1596
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1597 /* Copy the location lists one at a time */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1598 for (idx = 0; idx < qi->qf_listcount; idx++)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1599 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1600 qf_list_T *from_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1601 qf_list_T *to_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1602
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1603 to->w_llist->qf_curlist = idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1604
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1605 from_qfl = &qi->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1606 to_qfl = &to->w_llist->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1607
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1608 /* Some of the fields are populated by qf_add_entry() */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1609 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1610 to_qfl->qf_count = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1611 to_qfl->qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1612 to_qfl->qf_start = NULL;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1613 to_qfl->qf_last = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1614 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
1615 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
1616 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
1617 else
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1618 to_qfl->qf_title = NULL;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1619 if (from_qfl->qf_ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1620 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1621 to_qfl->qf_ctx = alloc_tv();
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1622 if (to_qfl->qf_ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1623 copy_tv(from_qfl->qf_ctx, to_qfl->qf_ctx);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1624 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1625 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1626 to_qfl->qf_ctx = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1627
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1628 if (from_qfl->qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1629 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1630 qfline_T *from_qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1631 qfline_T *prevp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1632
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1633 /* 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
1634 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
1635 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
1636 ++i, from_qfp = from_qfp->qf_next)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1637 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1638 if (qf_add_entry(to->w_llist,
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1639 to->w_llist->qf_curlist,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1640 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1641 NULL,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1642 0,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1643 from_qfp->qf_text,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1644 from_qfp->qf_lnum,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1645 from_qfp->qf_col,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1646 from_qfp->qf_viscol,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1647 from_qfp->qf_pattern,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1648 from_qfp->qf_nr,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1649 0,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1650 from_qfp->qf_valid) == FAIL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1651 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1652 qf_free_all(to);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1653 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1654 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1655 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1656 * qf_add_entry() will not set the qf_num field, as the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1657 * directory and file names are not supplied. So the qf_fnum
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1658 * field is copied here.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1659 */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1660 prevp = to->w_llist->qf_lists[to->w_llist->qf_curlist].qf_last;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1661 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1662 prevp->qf_type = from_qfp->qf_type; /* error type */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1663 if (from_qfl->qf_ptr == from_qfp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1664 to_qfl->qf_ptr = prevp; /* current location */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1665 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1666 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1667
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1668 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1669
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
1670 /* Assign a new ID for the location list */
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
1671 to_qfl->qf_id = ++last_qf_id;
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
1672 to_qfl->qf_changedtick = 0L;
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
1673
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1674 /* When no valid entries are present in the list, qf_ptr points to
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1675 * the first item in the list */
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
1676 if (to_qfl->qf_nonevalid)
5060
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1677 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1678 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
1679 to_qfl->qf_index = 1;
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1680 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1681 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1682
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1683 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1684 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1685
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1686 /*
10379
73e2a7abe2a3 commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents: 10369
diff changeset
1687 * Get buffer number for file "directory/fname".
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1688 * Also sets the b_has_qf_entry flag.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 static int
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1691 qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory, char_u *fname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 {
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1693 char_u *ptr = NULL;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1694 buf_T *buf;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1695 char_u *bufname;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1696
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 if (fname == NULL || *fname == NUL) /* no file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1700 #ifdef VMS
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1701 vms_remove_version(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1702 #endif
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1703 #ifdef BACKSLASH_IN_FILENAME
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1704 if (directory != NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1705 slash_adjust(directory);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1706 slash_adjust(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1707 #endif
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1708 if (directory != NULL && !vim_isAbsName(fname)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1709 && (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
1710 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1711 /*
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1712 * 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
1713 * 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
1714 * "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
1715 * directory change.
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1716 */
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1717 if (mch_getperm(ptr) < 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 vim_free(ptr);
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1720 directory = qf_guess_filepath(qi, qf_idx, fname);
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1721 if (directory)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1722 ptr = concat_fnames(directory, fname, TRUE);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1723 else
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1724 ptr = vim_strsave(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1726 /* Use concatenated directory name and file name */
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1727 bufname = ptr;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1728 }
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1729 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1730 bufname = fname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1731
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1732 if (qf_last_bufname != NULL && STRCMP(bufname, qf_last_bufname) == 0
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1733 && bufref_valid(&qf_last_bufref))
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1734 {
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1735 buf = qf_last_bufref.br_buf;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1736 vim_free(ptr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1738 else
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1739 {
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1740 vim_free(qf_last_bufname);
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1741 buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT);
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1742 if (bufname == ptr)
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1743 qf_last_bufname = bufname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1744 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1745 qf_last_bufname = vim_strsave(bufname);
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1746 set_bufref(&qf_last_bufref, buf);
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1747 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1748 if (buf == NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1749 return 0;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1750
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1751 buf->b_has_qf_entry =
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1752 (qi == &ql_info) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1753 return buf->b_fnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 /*
9334
674f9e3ccd1a commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents: 9201
diff changeset
1757 * 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
1758 * NULL on error.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 static char_u *
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1761 qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 struct dir_stack_T *ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 /* allocate new stack element and hook it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 ds_new->next = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 *stackptr = ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 /* store directory on the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 if (vim_isAbsName(dirbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 || (*stackptr)->next == NULL
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1777 || (*stackptr && is_file_stack))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 /* Okay we don't have an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 * dirbuf must be a subdir of one of the directories on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 * Let's search...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 ds_new = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 (*stackptr)->dirname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 while (ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 if (mch_isdir((*stackptr)->dirname) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 ds_new = ds_new->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 while ((*stackptr)->next != ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 ds_ptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 (*stackptr)->next = (*stackptr)->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 /* Nothing found -> it must be on top level */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 if ((*stackptr)->dirname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 return (*stackptr)->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 * pop dirbuf from the directory stack and return previous directory or NULL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 * stack is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1832 qf_pop_dir(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 /* TODO: Should we check if dirbuf is the directory on top of the stack?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 * What to do if it isn't? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 /* pop top element and free it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 if (*stackptr != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 /* return NEW top element as current dir or NULL if stack is empty*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 return *stackptr ? (*stackptr)->dirname : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 * clean up directory stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1856 qf_clean_dir_stack(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 while ((ds_ptr = *stackptr) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 * Check in which directory of the directory stack the given file can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 * found.
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
1871 * Returns a pointer to the directory name or NULL if not found.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 * Cleans up intermediate directory entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 * TODO: How to solve the following problem?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 * If we have the this directory tree:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 * ./
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 * ./aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 * ./aa/bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 * ./bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 * ./bb/x.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 * and make says:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 * making all in aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 * making all in bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 * x.c:9: Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 * qf_guess_filepath will return NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 static char_u *
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1889 qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *filename)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 struct dir_stack_T *ds_tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 char_u *fullname;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1894 qf_list_T *qfl = &qi->qf_lists[qf_idx];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 /* no dirs on the stack - there's nothing we can do */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1897 if (qfl->qf_dir_stack == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1900 ds_ptr = qfl->qf_dir_stack->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 fullname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 while (ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 /* If concat_fnames failed, just go on. The worst thing that can happen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 * is that we delete the entire stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 if ((fullname != NULL) && (mch_getperm(fullname) >= 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 ds_ptr = ds_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 /* clean up all dirs we already left */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1919 while (qfl->qf_dir_stack->next != ds_ptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1921 ds_tmp = qfl->qf_dir_stack->next;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
1922 qfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 vim_free(ds_tmp->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 vim_free(ds_tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 return ds_ptr==NULL? NULL: ds_ptr->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 /*
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1931 * 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
1932 * 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
1933 * 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
1934 * Similar to location list.
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1935 */
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1936 static int
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1937 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
1938 {
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1939 qf_list_T *qfl;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1940 qfline_T *qfp;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1941 int i;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1942
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1943 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
1944
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1945 /* 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
1946 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
1947 ++i, qfp = qfp->qf_next)
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1948 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
1949 break;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1950
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1951 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
1952 return FALSE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1953
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1954 return TRUE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1955 }
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1956
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1957 /*
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1958 * Get the next valid entry in the current quickfix/location list. The search
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
1959 * starts from the current entry. Returns NULL on failure.
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1960 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1961 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1962 get_next_valid_entry(
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1963 qf_info_T *qi,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1964 qfline_T *qf_ptr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1965 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1966 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1967 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1968 int idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1969 int old_qf_fnum;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1970
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1971 idx = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1972 old_qf_fnum = qf_ptr->qf_fnum;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1973
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1974 do
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1975 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1976 if (idx == qi->qf_lists[qi->qf_curlist].qf_count
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1977 || qf_ptr->qf_next == NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1978 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1979 ++idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1980 qf_ptr = qf_ptr->qf_next;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1981 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1982 && !qf_ptr->qf_valid)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1983 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1984
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1985 *qf_index = idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1986 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1987 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1988
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1989 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1990 * Get the previous valid entry in the current quickfix/location list. The
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
1991 * search starts from the current entry. Returns NULL on failure.
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1992 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1993 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1994 get_prev_valid_entry(
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1995 qf_info_T *qi,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1996 qfline_T *qf_ptr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1997 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1998 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1999 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2000 int idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2001 int old_qf_fnum;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2002
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2003 idx = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2004 old_qf_fnum = qf_ptr->qf_fnum;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2005
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2006 do
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2007 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2008 if (idx == 1 || qf_ptr->qf_prev == NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2009 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2010 --idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2011 qf_ptr = qf_ptr->qf_prev;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2012 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2013 && !qf_ptr->qf_valid)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2014 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2015
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2016 *qf_index = idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2017 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2018 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2019
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2020 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2021 * Get the n'th (errornr) previous/next valid entry from the current entry in
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2022 * the quickfix list.
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2023 * dir == FORWARD or FORWARD_FILE: next valid entry
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2024 * dir == BACKWARD or BACKWARD_FILE: previous valid entry
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2025 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2026 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2027 get_nth_valid_entry(
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2028 qf_info_T *qi,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2029 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2030 qfline_T *qf_ptr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2031 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2032 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2033 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2034 qfline_T *prev_qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2035 int prev_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2036 static char_u *e_no_more_items = (char_u *)N_("E553: No more items");
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2037 char_u *err = e_no_more_items;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2038
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2039 while (errornr--)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2040 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2041 prev_qf_ptr = qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2042 prev_index = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2043
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2044 if (dir == FORWARD || dir == FORWARD_FILE)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2045 qf_ptr = get_next_valid_entry(qi, qf_ptr, qf_index, dir);
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2046 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2047 qf_ptr = get_prev_valid_entry(qi, qf_ptr, qf_index, dir);
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2048 if (qf_ptr == NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2049 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2050 qf_ptr = prev_qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2051 *qf_index = prev_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2052 if (err != NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2053 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2054 EMSG(_(err));
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2055 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2056 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2057 break;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2058 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2059
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2060 err = NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2061 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2062
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2063 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2064 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2065
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2066 /*
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2067 * Get n'th (errornr) quickfix entry
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2068 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2069 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2070 get_nth_entry(
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2071 qf_info_T *qi,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2072 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2073 qfline_T *qf_ptr,
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2074 int *cur_qfidx)
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2075 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2076 int qf_idx = *cur_qfidx;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2077
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2078 /* New error number is less than the current error number */
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2079 while (errornr < qf_idx && qf_idx > 1 && qf_ptr->qf_prev != NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2080 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2081 --qf_idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2082 qf_ptr = qf_ptr->qf_prev;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2083 }
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2084 /* New error number is greater than the current error number */
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2085 while (errornr > qf_idx &&
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2086 qf_idx < qi->qf_lists[qi->qf_curlist].qf_count &&
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2087 qf_ptr->qf_next != NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2088 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2089 ++qf_idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2090 qf_ptr = qf_ptr->qf_next;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2091 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2092
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2093 *cur_qfidx = qf_idx;
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2094 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2095 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2096
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2097 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2098 * Find a help window or open one.
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2099 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2100 static int
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2101 jump_to_help_window(qf_info_T *qi, int *opened_window)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2102 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2103 win_T *wp;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2104 int flags;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2105
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2106 if (cmdmod.tab != 0)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2107 wp = NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2108 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2109 FOR_ALL_WINDOWS(wp)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2110 if (bt_help(wp->w_buffer))
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2111 break;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2112 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2113 win_enter(wp, TRUE);
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2114 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2115 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2116 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2117 * Split off help window; put it at far top if no position
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2118 * specified, the current window is vertically split and narrow.
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2119 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2120 flags = WSP_HELP;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2121 if (cmdmod.split == 0 && curwin->w_width != Columns
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2122 && curwin->w_width < 80)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2123 flags |= WSP_TOP;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2124 if (qi != &ql_info)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2125 flags |= WSP_NEWLOC; /* don't copy the location list */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2126
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2127 if (win_split(0, flags) == FAIL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2128 return FAIL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2129
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2130 *opened_window = TRUE;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2131
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2132 if (curwin->w_height < p_hh)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2133 win_setheight((int)p_hh);
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2134
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2135 if (qi != &ql_info) /* not a quickfix list */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2136 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2137 /* The new window should use the supplied location list */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2138 curwin->w_llist = qi;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2139 qi->qf_refcount++;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2140 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2141 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2142
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2143 if (!p_im)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2144 restart_edit = 0; /* don't want insert mode in help file */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2145
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2146 return OK;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2147 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2148
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2149 /*
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2150 * Find a suitable window for opening a file (qf_fnum) and jump to it.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2151 * If the file is already opened in a window, jump to it.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2152 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2153 static int
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2154 qf_jump_to_usable_window(int qf_fnum, int *opened_window)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2155 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2156 win_T *usable_win_ptr = NULL;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2157 int usable_win;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2158 qf_info_T *ll_ref;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2159 int flags;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2160 win_T *win;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2161 win_T *altwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2162
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2163 usable_win = 0;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2164
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2165 ll_ref = curwin->w_llist_ref;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2166 if (ll_ref != NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2167 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2168 /* Find a window using the same location list that is not a
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2169 * quickfix window. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2170 FOR_ALL_WINDOWS(usable_win_ptr)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2171 if (usable_win_ptr->w_llist == ll_ref
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2172 && !bt_quickfix(usable_win_ptr->w_buffer))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2173 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2174 usable_win = 1;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2175 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2176 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2177 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2178
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2179 if (!usable_win)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2180 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2181 /* Locate a window showing a normal buffer */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2182 FOR_ALL_WINDOWS(win)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2183 if (win->w_buffer->b_p_bt[0] == NUL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2184 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2185 usable_win = 1;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2186 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2187 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2188 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2189
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2190 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2191 * If no usable window is found and 'switchbuf' contains "usetab"
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2192 * then search in other tabs.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2193 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2194 if (!usable_win && (swb_flags & SWB_USETAB))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2195 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2196 tabpage_T *tp;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2197 win_T *wp;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2198
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2199 FOR_ALL_TAB_WINDOWS(tp, wp)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2200 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2201 if (wp->w_buffer->b_fnum == qf_fnum)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2202 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2203 goto_tabpage_win(tp, wp);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2204 usable_win = 1;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2205 goto win_found;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2206 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2207 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2208 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2209 win_found:
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2210
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2211 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2212 * If there is only one window and it is the quickfix window, create a
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2213 * new one above the quickfix window.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2214 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2215 if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2216 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2217 flags = WSP_ABOVE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2218 if (ll_ref != NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2219 flags |= WSP_NEWLOC;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2220 if (win_split(0, flags) == FAIL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2221 return FAIL; /* not enough room for window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2222 *opened_window = TRUE; /* close it when fail */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2223 p_swb = empty_option; /* don't split again */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2224 swb_flags = 0;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2225 RESET_BINDING(curwin);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2226 if (ll_ref != NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2227 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2228 /* The new window should use the location list from the
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2229 * location list window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2230 curwin->w_llist = ll_ref;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2231 ll_ref->qf_refcount++;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2232 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2233 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2234 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2235 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2236 if (curwin->w_llist_ref != NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2237 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2238 /* In a location window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2239 win = usable_win_ptr;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2240 if (win == NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2241 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2242 /* Find the window showing the selected file */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2243 FOR_ALL_WINDOWS(win)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2244 if (win->w_buffer->b_fnum == qf_fnum)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2245 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2246 if (win == NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2247 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2248 /* Find a previous usable window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2249 win = curwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2250 do
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2251 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2252 if (win->w_buffer->b_p_bt[0] == NUL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2253 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2254 if (win->w_prev == NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2255 win = lastwin; /* wrap around the top */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2256 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2257 win = win->w_prev; /* go to previous window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2258 } while (win != curwin);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2259 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2260 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2261 win_goto(win);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2262
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2263 /* If the location list for the window is not set, then set it
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2264 * to the location list from the location window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2265 if (win->w_llist == NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2266 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2267 win->w_llist = ll_ref;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2268 ll_ref->qf_refcount++;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2269 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2270 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2271 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2272 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2273
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2274 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2275 * Try to find a window that shows the right buffer.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2276 * Default to the window just above the quickfix buffer.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2277 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2278 win = curwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2279 altwin = NULL;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2280 for (;;)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2281 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2282 if (win->w_buffer->b_fnum == qf_fnum)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2283 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2284 if (win->w_prev == NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2285 win = lastwin; /* wrap around the top */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2286 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2287 win = win->w_prev; /* go to previous window */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2288
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2289 if (IS_QF_WINDOW(win))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2290 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2291 /* Didn't find it, go to the window before the quickfix
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2292 * window. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2293 if (altwin != NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2294 win = altwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2295 else if (curwin->w_prev != NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2296 win = curwin->w_prev;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2297 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2298 win = curwin->w_next;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2299 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2300 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2301
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2302 /* Remember a usable window. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2303 if (altwin == NULL && !win->w_p_pvw
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2304 && win->w_buffer->b_p_bt[0] == NUL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2305 altwin = win;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2306 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2307
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2308 win_goto(win);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2309 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2310 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2311
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2312 return OK;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2313 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2314
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2315 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2316 * Edit the selected file or help file.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2317 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2318 static int
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2319 qf_jump_edit_buffer(
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2320 qf_info_T *qi,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2321 qfline_T *qf_ptr,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2322 int forceit,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2323 win_T *oldwin,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2324 int *opened_window,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2325 int *abort)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2326 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2327 int retval = OK;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2328
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2329 if (qf_ptr->qf_type == 1)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2330 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2331 /* Open help file (do_ecmd() will set b_help flag, readfile() will
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2332 * set b_p_ro flag). */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2333 if (!can_abandon(curbuf, forceit))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2334 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2335 no_write_message();
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2336 retval = FALSE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2337 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2338 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2339 retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2340 ECMD_HIDE + ECMD_SET_HELP,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2341 oldwin == curwin ? curwin : NULL);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2342 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2343 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2344 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2345 int old_qf_curlist = qi->qf_curlist;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2346
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2347 retval = buflist_getfile(qf_ptr->qf_fnum,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2348 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2349 if (qi != &ql_info && !win_valid_any_tab(oldwin))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2350 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2351 EMSG(_("E924: Current window was closed"));
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2352 *abort = TRUE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2353 *opened_window = FALSE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2354 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2355 else if (old_qf_curlist != qi->qf_curlist
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2356 || !is_qf_entry_present(qi, qf_ptr))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2357 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2358 if (qi == &ql_info)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2359 EMSG(_("E925: Current quickfix was changed"));
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2360 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2361 EMSG(_("E926: Current location list was changed"));
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2362 *abort = TRUE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2363 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2364
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2365 if (*abort)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2366 retval = FALSE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2367 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2368
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2369 return retval;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2370 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2371
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2372 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2373 * Goto the error line in the current file using either line/column number or a
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2374 * search pattern.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2375 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2376 static void
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2377 qf_jump_goto_line(
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2378 linenr_T qf_lnum,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2379 int qf_col,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2380 char_u qf_viscol,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2381 char_u *qf_pattern)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2382 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2383 linenr_T i;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2384 char_u *line;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2385 colnr_T screen_col;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2386 colnr_T char_col;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2387
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2388 if (qf_pattern == NULL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2389 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2390 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2391 * Go to line with error, unless qf_lnum is 0.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2392 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2393 i = qf_lnum;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2394 if (i > 0)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2395 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2396 if (i > curbuf->b_ml.ml_line_count)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2397 i = curbuf->b_ml.ml_line_count;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2398 curwin->w_cursor.lnum = i;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2399 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2400 if (qf_col > 0)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2401 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2402 curwin->w_cursor.col = qf_col - 1;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2403 #ifdef FEAT_VIRTUALEDIT
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2404 curwin->w_cursor.coladd = 0;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2405 #endif
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2406 if (qf_viscol == TRUE)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2407 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2408 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2409 * Check each character from the beginning of the error
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2410 * line up to the error column. For each tab character
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2411 * found, reduce the error column value by the length of
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2412 * a tab character.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2413 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2414 line = ml_get_curline();
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2415 screen_col = 0;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2416 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2417 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2418 if (*line == NUL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2419 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2420 if (*line++ == '\t')
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2421 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2422 curwin->w_cursor.col -= 7 - (screen_col % 8);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2423 screen_col += 8 - (screen_col % 8);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2424 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2425 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2426 ++screen_col;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2427 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2428 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2429 check_cursor();
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2430 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2431 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2432 beginline(BL_WHITE | BL_FIX);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2433 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2434 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2435 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2436 pos_T save_cursor;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2437
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2438 /* Move the cursor to the first line in the buffer */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2439 save_cursor = curwin->w_cursor;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2440 curwin->w_cursor.lnum = 0;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2441 if (!do_search(NULL, '/', qf_pattern, (long)1,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2442 SEARCH_KEEP, NULL, NULL))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2443 curwin->w_cursor = save_cursor;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2444 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2445 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2446
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2447 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2448 * Display quickfix list index and size message
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2449 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2450 static void
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2451 qf_jump_print_msg(
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2452 qf_info_T *qi,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2453 int qf_index,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2454 qfline_T *qf_ptr,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2455 buf_T *old_curbuf,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2456 linenr_T old_lnum)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2457 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2458 linenr_T i;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2459 int len;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2460
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2461 /* Update the screen before showing the message, unless the screen
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2462 * scrolled up. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2463 if (!msg_scrolled)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2464 update_topline_redraw();
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2465 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2466 qi->qf_lists[qi->qf_curlist].qf_count,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2467 qf_ptr->qf_cleared ? _(" (line deleted)") : "",
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2468 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr));
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2469 /* Add the message, skipping leading whitespace and newlines. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2470 len = (int)STRLEN(IObuff);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2471 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2472
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2473 /* Output the message. Overwrite to avoid scrolling when the 'O'
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2474 * flag is present in 'shortmess'; But when not jumping, print the
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2475 * whole message. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2476 i = msg_scroll;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2477 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2478 msg_scroll = TRUE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2479 else if (!msg_scrolled && shortmess(SHM_OVERALL))
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2480 msg_scroll = FALSE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2481 msg_attr_keep(IObuff, 0, TRUE);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2482 msg_scroll = i;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2483 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2484
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2485 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 * jump to a quickfix line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 * if dir == FORWARD go "errornr" valid entries forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 * if dir == BACKWARD go "errornr" valid entries backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 * if dir == FORWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 * else if "errornr" is zero, redisplay the same line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 * else go to entry "errornr"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 void
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2495 qf_jump(qf_info_T *qi,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2496 int dir,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2497 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2498 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2500 qfline_T *qf_ptr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2501 qfline_T *old_qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 int qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 int old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 buf_T *old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 linenr_T old_lnum;
639
c79d4df4686e updated for version 7.0185
vimboss
parents: 634
diff changeset
2506 char_u *old_swb = p_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2507 unsigned old_swb_flags = swb_flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 int opened_window = FALSE;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2509 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 int print_message = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 int old_KeyTyped = KeyTyped; /* getting file may reset it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 #endif
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2514 int retval = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2515
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2516 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2517 qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2518
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2519 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2520 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2526 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 old_qf_ptr = qf_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2528 qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 old_qf_index = qf_index;
12465
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
2530 if (dir != 0) /* next/prev valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 {
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2532 qf_ptr = get_nth_valid_entry(qi, errornr, qf_ptr, &qf_index, dir);
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2533 if (qf_ptr == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 {
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2535 qf_ptr = old_qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2536 qf_index = old_qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2537 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 else if (errornr != 0) /* go to specified number */
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2541 qf_ptr = get_nth_entry(qi, errornr, qf_ptr, &qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2543 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2544 if (qf_win_pos_update(qi, old_qf_index))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 /* No need to print the error message if it's visible in the error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 * window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 print_message = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 /*
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2550 * For ":helpgrep" find a help window or open one.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2551 */
11800
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
2552 if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) || cmdmod.tab != 0))
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2553 if (jump_to_help_window(qi, &opened_window) == FAIL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2554 goto theend;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2555
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2556 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 * If currently in the quickfix window, find another window to show the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 * file in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
2560 if (bt_quickfix(curbuf) && !opened_window)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 * If there is no file specified, we don't know where to go.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 * But do advance, otherwise ":cn" gets stuck.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 if (qf_ptr->qf_fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2569 if (qf_jump_to_usable_window(qf_ptr->qf_fnum, &opened_window) == FAIL)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2570 goto failed;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 * If there is a file name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 * read the wanted file if needed, and check autowrite etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 old_lnum = curwin->w_cursor.lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2579
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2580 if (qf_ptr->qf_fnum != 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2581 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2582 int abort = FALSE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2583
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2584 retval = qf_jump_edit_buffer(qi, qf_ptr, forceit, oldwin,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2585 &opened_window, &abort);
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2586 if (abort)
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2587 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2588 qi = NULL;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2589 qf_ptr = NULL;
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2590 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2591 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2592
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2593 if (retval == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 /* When not switched to another buffer, still need to set pc mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596 if (curbuf == old_curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2599 qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2600 qf_ptr->qf_pattern);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 foldOpenCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 if (print_message)
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2607 qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 if (opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 win_close(curwin, TRUE); /* Close opened window */
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2613 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 * Couldn't open file, so put index back where it was. This could
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 * happen if the file was readonly and we changed something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 failed:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 qf_index = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 theend:
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2625 if (qi != NULL)
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2626 {
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2627 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
2628 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
2629 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 if (p_swb != old_swb && opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 /* Restore old 'switchbuf' value, but not when an autocommand or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 * modeline has changed the value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 if (p_swb == empty_option)
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2635 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 p_swb = old_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2637 swb_flags = old_swb_flags;
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2638 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 free_string_option(old_swb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 * ":clist": list all errors
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2646 * ":llist": list all locations
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2649 qf_list(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2651 buf_T *buf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2652 char_u *fname;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2653 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2654 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2655 int idx1 = 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2656 int idx2 = -1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2657 char_u *arg = eap->arg;
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2658 int plus = FALSE;
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2659 int qfFileAttr;
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2660 int qfSepAttr;
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2661 int qfLineAttr;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2662 int all = eap->forceit; /* if not :cl!, only show
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 recognised errors */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2664 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2665
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2666 if (eap->cmdidx == CMD_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2667 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2668 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2669 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2670 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2671 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2672 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2673 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2674 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2675
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2676 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2677 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2682 if (*arg == '+')
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2683 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2684 ++arg;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2685 plus = TRUE;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2686 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2692 if (plus)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2693 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2694 i = qi->qf_lists[qi->qf_curlist].qf_index;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2695 idx2 = i + idx1;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2696 idx1 = i;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2697 }
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2698 else
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2699 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2700 i = qi->qf_lists[qi->qf_curlist].qf_count;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2701 if (idx1 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2702 idx1 = (-idx1 > i) ? 0 : idx1 + i + 1;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2703 if (idx2 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2704 idx2 = (-idx2 > i) ? 0 : idx2 + i + 1;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2705 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2707 /*
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2708 * Get the attributes for the different quickfix highlight items. Note
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2709 * that this depends on syntax items defined in the qf.vim syntax file
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2710 */
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2711 qfFileAttr = syn_name2attr((char_u *)"qfFileName");
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2712 if (qfFileAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2713 qfFileAttr = HL_ATTR(HLF_D);
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2714 qfSepAttr = syn_name2attr((char_u *)"qfSeparator");
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2715 if (qfSepAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2716 qfSepAttr = HL_ATTR(HLF_D);
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2717 qfLineAttr = syn_name2attr((char_u *)"qfLineNr");
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2718 if (qfLineAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2719 qfLineAttr = HL_ATTR(HLF_N);
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2720
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2721 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 all = TRUE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2723 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2724 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 {
2047
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2728 msg_putchar('\n');
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2729 if (got_int)
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2730 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2731
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2732 fname = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2733 if (qfp->qf_fnum != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2735 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2736 fname = buf->b_fname;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2737 if (qfp->qf_type == 1) /* :helpgrep */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2738 fname = gettail(fname);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2739 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2740 if (fname == NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2741 sprintf((char *)IObuff, "%2d", i);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2742 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2743 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 236
diff changeset
2744 i, (char *)fname);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2745 msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2746 ? HL_ATTR(HLF_QFL) : qfFileAttr);
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2747
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2748 if (qfp->qf_lnum != 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2749 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2750 if (qfp->qf_lnum == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2751 IObuff[0] = NUL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2752 else if (qfp->qf_col == 0)
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2753 sprintf((char *)IObuff, "%ld", qfp->qf_lnum);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2754 else
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2755 sprintf((char *)IObuff, "%ld col %d",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 qfp->qf_lnum, qfp->qf_col);
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2757 sprintf((char *)IObuff + STRLEN(IObuff), "%s",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2759 msg_puts_attr(IObuff, qfLineAttr);
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2760 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2761 if (qfp->qf_pattern != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2762 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2763 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2764 msg_puts(IObuff);
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2765 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2766 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2767 msg_puts((char_u *)" ");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2768
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2769 /* Remove newlines and leading whitespace from the text. For an
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2770 * unrecognized line keep the indent, the compiler may mark a word
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2771 * with ^^^^. */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2772 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774 IObuff, IOSIZE);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2775 msg_prt_line(IObuff, FALSE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2776 out_flush(); /* show one line at a time */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2778
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2779 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2780 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2781 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2782 ++i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 * Remove newlines and leading whitespace from an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 * Put the result in "buf[bufsize]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2792 qf_fmt_text(char_u *text, char_u *buf, int bufsize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 char_u *p = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 for (i = 0; *p != NUL && i < bufsize - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 buf[i] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 while (*++p != NUL)
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11063
diff changeset
2803 if (!VIM_ISWHITE(*p) && *p != '\n')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 buf[i] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 buf[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2812 static void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2813 qf_msg(qf_info_T *qi, int which, char *lead)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2814 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2815 char *title = (char *)qi->qf_lists[which].qf_title;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2816 int count = qi->qf_lists[which].qf_count;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2817 char_u buf[IOSIZE];
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2818
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2819 vim_snprintf((char *)buf, IOSIZE, _("%serror list %d of %d; %d errors "),
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2820 lead,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2821 which + 1,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2822 qi->qf_listcount,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2823 count);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2824
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2825 if (title != NULL)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2826 {
9579
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2827 size_t len = STRLEN(buf);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2828
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2829 if (len < 34)
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2830 {
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2831 vim_memset(buf + len, ' ', 34 - len);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2832 buf[34] = NUL;
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2833 }
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2834 vim_strcat(buf, (char_u *)title, IOSIZE);
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2835 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2836 trunc_string(buf, buf, Columns - 1, IOSIZE);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2837 msg(buf);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2838 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2839
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 * ":colder [count]": Up in the quickfix stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 * ":cnewer [count]": Down in the quickfix stack.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2843 * ":lolder [count]": Up in the location list stack.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2844 * ":lnewer [count]": Down in the location list stack.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2847 qf_age(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2849 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2852 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2853 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2854 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2855 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2856 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2857 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2858 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2859 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2860 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2861
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 while (count--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2868 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2870 if (qi->qf_curlist == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 EMSG(_("E380: At bottom of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2873 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2875 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2879 if (qi->qf_curlist >= qi->qf_listcount - 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 EMSG(_("E381: At top of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2882 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2884 ++qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 }
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2887 qf_msg(qi, qi->qf_curlist, "");
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
2888 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2891 void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2892 qf_history(exarg_T *eap)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2893 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2894 qf_info_T *qi = &ql_info;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2895 int i;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2896
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2897 if (eap->cmdidx == CMD_lhistory)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2898 qi = GET_LOC_LIST(curwin);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2899 if (qi == NULL || (qi->qf_listcount == 0
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2900 && qi->qf_lists[qi->qf_curlist].qf_count == 0))
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2901 MSG(_("No entries"));
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2902 else
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2903 for (i = 0; i < qi->qf_listcount; ++i)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2904 qf_msg(qi, i, i == qi->qf_curlist ? "> " : " ");
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2905 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2906
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 /*
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2908 * Free all the entries in the error list "idx". Note that other information
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2909 * associated with the list like context and title are not freed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911 static void
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2912 qf_free_items(qf_info_T *qi, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2914 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2915 qfline_T *qfpnext;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2916 int stop = FALSE;
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2917 qf_list_T *qfl = &qi->qf_lists[idx];
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2918
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2919 while (qfl->qf_count && qfl->qf_start != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2921 qfp = qfl->qf_start;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2922 qfpnext = qfp->qf_next;
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
2923 if (!stop)
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2924 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2925 vim_free(qfp->qf_text);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2926 stop = (qfp == qfpnext);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2927 vim_free(qfp->qf_pattern);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2928 vim_free(qfp);
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2929 if (stop)
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2930 /* Somehow qf_count may have an incorrect value, set it to 1
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2931 * to avoid crashing when it's wrong.
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2932 * TODO: Avoid qf_count being incorrect. */
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2933 qfl->qf_count = 1;
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2934 }
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2935 qfl->qf_start = qfpnext;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2936 --qfl->qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2938
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2939 qfl->qf_index = 0;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2940 qfl->qf_start = NULL;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2941 qfl->qf_last = NULL;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2942 qfl->qf_ptr = NULL;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2943 qfl->qf_nonevalid = TRUE;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2944
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2945 qf_clean_dir_stack(&qfl->qf_dir_stack);
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2946 qfl->qf_directory = NULL;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2947 qf_clean_dir_stack(&qfl->qf_file_stack);
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2948 qfl->qf_currfile = NULL;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2949 qfl->qf_multiline = FALSE;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2950 qfl->qf_multiignore = FALSE;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2951 qfl->qf_multiscan = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 /*
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2955 * Free error list "idx". Frees all the entries in the quickfix list,
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2956 * associated context information and the title.
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2957 */
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2958 static void
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2959 qf_free(qf_info_T *qi, int idx)
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2960 {
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2961 qf_list_T *qfl = &qi->qf_lists[idx];
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2962
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2963 qf_free_items(qi, idx);
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2964
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2965 vim_free(qfl->qf_title);
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2966 qfl->qf_title = NULL;
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2967 free_tv(qfl->qf_ctx);
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
2968 qfl->qf_ctx = NULL;
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
2969 qfl->qf_id = 0;
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
2970 qfl->qf_changedtick = 0L;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2971 }
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2972
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2973 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 * qf_mark_adjust: adjust marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2977 qf_mark_adjust(
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2978 win_T *wp,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2979 linenr_T line1,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2980 linenr_T line2,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2981 long amount,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2982 long amount_after)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2984 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2985 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2986 int idx;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2987 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
2988 int found_one = FALSE;
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
2989 int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
2990
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
2991 if (!(curbuf->b_has_qf_entry & buf_has_flag))
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
2992 return;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2993 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2994 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2995 if (wp->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2996 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2997 qi = wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2998 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2999
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3000 for (idx = 0; idx < qi->qf_listcount; ++idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3001 if (qi->qf_lists[idx].qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3002 for (i = 0, qfp = qi->qf_lists[idx].qf_start;
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3003 i < qi->qf_lists[idx].qf_count && qfp != NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3004 ++i, qfp = qfp->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 if (qfp->qf_fnum == curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006 {
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3007 found_one = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3010 if (amount == MAXLNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 qfp->qf_cleared = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3013 qfp->qf_lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3014 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 else if (amount_after && qfp->qf_lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016 qfp->qf_lnum += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3018
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3019 if (!found_one)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3020 curbuf->b_has_qf_entry &= ~buf_has_flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024 * Make a nice message out of the error character and the error number:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3025 * char number message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3026 * e or E 0 " error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3027 * w or W 0 " warning"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3028 * i or I 0 " info"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3029 * 0 0 ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3030 * other 0 " c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3031 * e or E n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3032 * w or W n " warning n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3033 * i or I n " info n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3034 * 0 n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3035 * other n " c n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3036 * 1 x "" :helpgrep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3037 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3039 qf_types(int c, int nr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3041 static char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3042 static char_u cc[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3043 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3044
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 if (c == 'W' || c == 'w')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046 p = (char_u *)" warning";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 else if (c == 'I' || c == 'i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3048 p = (char_u *)" info";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3049 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050 p = (char_u *)" error";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 else if (c == 0 || c == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3052 p = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3053 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3055 cc[0] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056 cc[1] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3057 cc[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3058 p = cc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3060
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3061 if (nr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3064 sprintf((char *)buf, "%s %3d", (char *)p, nr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3065 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3066 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3067
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3068 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3069 * ":cwindow": open the quickfix window if we have errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3070 * close it if not.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3071 * ":lwindow": open the location list window if we have locations to display,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3072 * close it if not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3075 ex_cwindow(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3077 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3080 if (eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3081 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3082 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3083 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3084 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3085 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3086
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3087 /* Look for an existing quickfix window. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3088 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3090 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3091 * If a quickfix window is open but we have no errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3092 * close the window. If a quickfix window is not open, then open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 * it if we have errors; otherwise, leave it closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3095 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
3096 || qi->qf_lists[qi->qf_curlist].qf_count == 0
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3097 || qi->qf_curlist >= qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100 ex_cclose(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3102 else if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 ex_copen(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 * ":cclose": close the window showing the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3108 * ":lclose": close the window showing the location list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3111 ex_cclose(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3113 win_T *win = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3114 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3115
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3116 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3117 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3118 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3119 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3120 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3121 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3122
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3123 /* Find existing quickfix window and close it. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3124 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126 win_close(win, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130 * ":copen": open a window that shows the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3131 * ":lopen": open a window that shows the location list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3134 ex_copen(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3136 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3137 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 win_T *win;
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3139 tabpage_T *prevtab = curtab;
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3140 buf_T *qf_buf;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3141 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3143 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3144 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3145 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3146 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3147 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3148 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3149 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3150 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3151 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3152
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3154 height = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3155 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 height = QF_WINHEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 reset_VIsual_and_resel(); /* stop Visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3161 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3163 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3164 * Find existing quickfix window, or open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3165 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3166 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3167
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3168 if (win != NULL && cmdmod.tab == 0)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3169 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 win_goto(win);
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3171 if (eap->addr_count != 0)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3172 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3173 if (cmdmod.split & WSP_VERT)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3174 {
12515
972ea22c946f patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12503
diff changeset
3175 if (height != win->w_width)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3176 win_setwidth(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3177 }
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3178 else if (height != win->w_height)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3179 win_setheight(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3180 }
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3181 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3182 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3184 qf_buf = qf_find_buf(qi);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3185
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3186 /* The current window becomes the previous window afterwards. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3187 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3188
3939
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3189 if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3190 && cmdmod.split == 0)
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3191 /* Create the new window at the very bottom, except when
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3192 * :belowright or :aboveleft is used. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3193 win_goto(lastwin);
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
3194 if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195 return; /* not enough room for window */
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
3196 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3197
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3198 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3199 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3200 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3201 * For the location list window, create a reference to the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3202 * location list from the window 'win'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3203 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3204 curwin->w_llist_ref = win->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3205 win->w_llist->qf_refcount++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3206 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3207
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3208 if (oldwin != curwin)
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3209 oldwin = NULL; /* don't store info when in another window */
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3210 if (qf_buf != NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3211 /* Use the existing quickfix buffer */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3212 (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3213 ECMD_HIDE + ECMD_OLDBUF, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3214 else
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3215 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3216 /* Create a new quickfix buffer */
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3217 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3218 /* switch off 'swapfile' */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3219 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3220 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
729
3d0ca316efab updated for version 7.0221
vimboss
parents: 717
diff changeset
3221 OPT_LOCAL);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3222 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
2651
b254cfdd7405 updated for version 7.3.071
Bram Moolenaar <bram@vim.org>
parents: 2646
diff changeset
3223 RESET_BINDING(curwin);
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3224 #ifdef FEAT_DIFF
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3225 curwin->w_p_diff = FALSE;
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3226 #endif
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3227 #ifdef FEAT_FOLDING
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3228 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3229 OPT_LOCAL);
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3230 #endif
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3231 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3232
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3233 /* Only set the height when still in the same tab page and there is no
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3234 * window to the side. */
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3235 if (curtab == prevtab && curwin->w_width == Columns)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3236 win_setheight(height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3237 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238 if (win_valid(win))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3239 prevwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3242 qf_set_title_var(qi);
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3243
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3245 * Fill the buffer with the quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3246 */
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3247 qf_fill_buffer(qi, curbuf, NULL);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3248
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3249 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3250 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3252 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3255 /*
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3256 * Move the cursor in the quickfix window to "lnum".
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3257 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3258 static void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3259 qf_win_goto(win_T *win, linenr_T lnum)
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3260 {
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3261 win_T *old_curwin = curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3262
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3263 curwin = win;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3264 curbuf = win->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3265 curwin->w_cursor.lnum = lnum;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3266 curwin->w_cursor.col = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3267 #ifdef FEAT_VIRTUALEDIT
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3268 curwin->w_cursor.coladd = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3269 #endif
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3270 curwin->w_curswant = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3271 update_topline(); /* scroll to show the line */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3272 redraw_later(VALID);
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3273 curwin->w_redr_status = TRUE; /* update ruler */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3274 curwin = old_curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3275 curbuf = curwin->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3276 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3277
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3278 /*
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3279 * :cbottom/:lbottom commands.
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3280 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3281 void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3282 ex_cbottom(exarg_T *eap UNUSED)
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3283 {
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3284 qf_info_T *qi = &ql_info;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3285 win_T *win;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3286
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3287 if (eap->cmdidx == CMD_lbottom)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3288 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3289 qi = GET_LOC_LIST(curwin);
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3290 if (qi == NULL)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3291 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3292 EMSG(_(e_loclist));
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3293 return;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3294 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3295 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3296
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3297 win = qf_find_win(qi);
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3298 if (win != NULL && win->w_cursor.lnum != win->w_buffer->b_ml.ml_line_count)
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3299 qf_win_goto(win, win->w_buffer->b_ml.ml_line_count);
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3300 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3301
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3302 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3303 * Return the number of the current entry (line number in the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3304 * window).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3305 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3306 linenr_T
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3307 qf_current_entry(win_T *wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3308 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3309 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3310
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3311 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3312 /* In the location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3313 qi = wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3314
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3315 return qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3316 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3318 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 * Update the cursor position in the quickfix window to the current error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 * Return TRUE if there is a quickfix window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3323 qf_win_pos_update(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3324 qf_info_T *qi,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3325 int old_qf_index) /* previous qf_index or zero */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 win_T *win;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3328 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 * Put the cursor on the current error in the quickfix window, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 * it's viewable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3334 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3335 if (win != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336 && qf_index <= win->w_buffer->b_ml.ml_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 && old_qf_index != qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 if (qf_index > old_qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3341 win->w_redraw_top = old_qf_index;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3342 win->w_redraw_bot = qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3346 win->w_redraw_top = qf_index;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3347 win->w_redraw_bot = old_qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 }
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3349 qf_win_goto(win, qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 return win != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3355 * Check whether the given window is displaying the specified quickfix/location
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3356 * list buffer
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3357 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3358 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3359 is_qf_win(win_T *win, qf_info_T *qi)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3360 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3361 /*
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3362 * A window displaying the quickfix buffer will have the w_llist_ref field
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3363 * set to NULL.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3364 * A window displaying a location list buffer will have the w_llist_ref
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3365 * pointing to the location list.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3366 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3367 if (bt_quickfix(win->w_buffer))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3368 if ((qi == &ql_info && win->w_llist_ref == NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3369 || (qi != &ql_info && win->w_llist_ref == qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3370 return TRUE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3371
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3372 return FALSE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3373 }
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3374
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3375 /*
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3376 * Find a window displaying the quickfix/location list 'qi'
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3377 * Searches in only the windows opened in the current tab.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3378 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3379 static win_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3380 qf_find_win(qf_info_T *qi)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3381 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3382 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3383
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3384 FOR_ALL_WINDOWS(win)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3385 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3386 break;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3387
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3388 return win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3389 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3390
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3391 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3392 * Find a quickfix buffer.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3393 * Searches in windows opened in all the tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3394 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3395 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3396 qf_find_buf(qf_info_T *qi)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3397 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3398 tabpage_T *tp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3399 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3400
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3401 FOR_ALL_TAB_WINDOWS(tp, win)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3402 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3403 return win->w_buffer;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3404
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3405 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3409 * Update the w:quickfix_title variable in the quickfix/location list window
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3410 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3411 static void
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3412 qf_update_win_titlevar(qf_info_T *qi)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3413 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3414 win_T *win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3415 win_T *curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3416
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3417 if ((win = qf_find_win(qi)) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3418 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3419 curwin_save = curwin;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3420 curwin = win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3421 qf_set_title_var(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3422 curwin = curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3423 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3424 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3425
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3426 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3427 * Find the quickfix buffer. If it exists, update the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3428 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3429 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3430 qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3432 buf_T *buf;
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3433 win_T *win;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3434 aco_save_T aco;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3436 /* Check if a buffer for the quickfix list exists. Update it. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3437 buf = qf_find_buf(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3439 {
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3440 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
3441
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3442 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3443 /* 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
3444 aucmd_prepbuf(&aco, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3445
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3446 qf_update_win_titlevar(qi);
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3447
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3448 qf_fill_buffer(qi, buf, old_last);
11705
c43118ecb0a3 patch 8.0.0735: no indication that the quickfix window/buffer changed
Christian Brabandt <cb@256bit.org>
parents: 11700
diff changeset
3449 ++CHANGEDTICK(buf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3450
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3451 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3452 {
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
3453 (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
3454
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3455 /* 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
3456 aucmd_restbuf(&aco);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3457 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3458
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3459 /* 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
3460 * 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
3461 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
3462 redraw_buf_later(buf, NOT_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3464 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3465
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3466 /*
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3467 * Set "w:quickfix_title" if "qi" has a title.
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3468 */
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3469 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3470 qf_set_title_var(qf_info_T *qi)
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3471 {
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3472 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL)
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3473 set_internal_string_var((char_u *)"w:quickfix_title",
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3474 qi->qf_lists[qi->qf_curlist].qf_title);
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3475 }
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3476
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3477 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3478 * Fill current buffer with quickfix errors, replacing any previous contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3479 * 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
3480 * 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
3481 * 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
3482 * ml_delete() is used and autocommands will be triggered.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3483 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3484 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3485 qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3486 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3487 linenr_T lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3488 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3489 buf_T *errbuf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3490 int len;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3491 int old_KeyTyped = KeyTyped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3492
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3493 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3494 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3495 if (buf != curbuf)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3496 {
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
3497 internal_error("qf_fill_buffer()");
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3498 return;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3499 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3500
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3501 /* delete all existing lines */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3502 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
3503 (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
3504 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3506 /* Check if there is anything to display */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3507 if (qi->qf_curlist < qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3508 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3509 /* 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
3510 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3511 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3512 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
3513 lnum = 0;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3514 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3515 else
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3516 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3517 qfp = old_last->qf_next;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3518 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
3519 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3520 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3521 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3522 if (qfp->qf_fnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3524 && errbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3525 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3526 if (qfp->qf_type == 1) /* :helpgrep */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3527 STRCPY(IObuff, gettail(errbuf->b_fname));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3528 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3529 STRCPY(IObuff, errbuf->b_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3532 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3533 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3534 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3536 if (qfp->qf_lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3537 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3539 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3541 if (qfp->qf_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3542 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3543 sprintf((char *)IObuff + len, " col %d", qfp->qf_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3544 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3547 sprintf((char *)IObuff + len, "%s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3548 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3549 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3550 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3551 else if (qfp->qf_pattern != NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3552 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3553 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3554 len += (int)STRLEN(IObuff + len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3555 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557 IObuff[len++] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3559 /* Remove newlines and leading whitespace from the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3560 * For an unrecognized line keep the indent, the compiler may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3561 * mark a word with ^^^^. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3562 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3563 IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3564
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3565 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
3566 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3567 break;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3568 ++lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3569 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3570 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3571 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3572 }
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3573
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3574 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3575 /* 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
3576 (void)ml_delete(lnum + 1, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3577 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3579 /* correct cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3580 check_lnums(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3582 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3583 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3584 /* 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
3585 * 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
3586 * using autocommands. */
11589
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3587 #ifdef FEAT_AUTOCMD
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3588 ++curbuf_lock;
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3589 #endif
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3590 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
3591 curbuf->b_p_ma = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3593 #ifdef FEAT_AUTOCMD
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3594 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
3595 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3596 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3597 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3598 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3599 keep_filetype = FALSE;
11589
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3600 --curbuf_lock;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3601 #endif
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3602 /* make sure it will be redrawn */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3603 redraw_curbuf_later(NOT_VALID);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3604 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3605
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3606 /* Restore KeyTyped, setting 'filetype' may reset it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3607 KeyTyped = old_KeyTyped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3609
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3610 static void
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3611 qf_list_changed(qf_info_T *qi, int qf_idx)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3612 {
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3613 qi->qf_lists[qf_idx].qf_changedtick++;
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3614 }
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3615
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3616 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3617 * Return TRUE when using ":vimgrep" for ":grep".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3618 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3619 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3620 grep_internal(cmdidx_T cmdidx)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3621 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3622 return ((cmdidx == CMD_grep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3623 || cmdidx == CMD_lgrep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3624 || cmdidx == CMD_grepadd
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3625 || cmdidx == CMD_lgrepadd)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3626 && STRCMP("internal",
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3627 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3628 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3629
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3630 /*
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3631 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3634 ex_make(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635 {
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3636 char_u *fname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3637 char_u *cmd;
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3638 char_u *enc = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 unsigned len;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3640 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3641 qf_info_T *qi = &ql_info;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3642 int res;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3643 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3644 char_u *au_name = NULL;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3645
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3646 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3647 if (grep_internal(eap->cmdidx))
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3648 {
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3649 ex_vimgrep(eap);
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3650 return;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3651 }
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3652
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3653 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3654 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3655 case CMD_make: au_name = (char_u *)"make"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3656 case CMD_lmake: au_name = (char_u *)"lmake"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3657 case CMD_grep: au_name = (char_u *)"grep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3658 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3659 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3660 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3661 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3662 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3663 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3664 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3665 {
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3666 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3667 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3668 return;
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3669 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3670 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3671 #endif
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3672 #ifdef FEAT_MBYTE
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3673 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3674 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3675
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3676 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3677 || eap->cmdidx == CMD_lgrepadd)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3678 wp = curwin;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3679
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3680 autowrite_all();
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3681 fname = get_mef_name();
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3682 if (fname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3683 return;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3684 mch_remove(fname); /* in case it's not unique */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3685
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3686 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3687 * If 'shellpipe' empty: don't redirect to 'errorfile'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3688 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3689 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3690 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3691 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 cmd = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3693 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 (char *)p_shq);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 if (*p_sp != NUL)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1864
diff changeset
3698 append_redir(cmd, len, p_sp, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3699 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3700 * Output a newline if there's something else than the :make command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 * was typed (in which case the cursor is in column 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3702 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3703 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3704 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3705 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3706 MSG_PUTS(":!");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3707 msg_outtrans(cmd); /* show what we are doing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3709 /* let the shell know if we are redirecting output or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3710 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3712 #ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3713 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3714 /* read window status report and redraw before message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3715 (void)char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3716 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3717
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3718 res = qf_init(wp, fname, (eap->cmdidx != CMD_make
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3719 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3720 (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
3721 && eap->cmdidx != CMD_lgrepadd),
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3722 *eap->cmdlinep, enc);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3723 if (wp != NULL)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3724 qi = GET_LOC_LIST(wp);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3725 if (res >= 0 && qi != NULL)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3726 qf_list_changed(qi, qi->qf_curlist);
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3727 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3728 if (au_name != NULL)
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3729 {
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3730 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3731 curbuf->b_fname, TRUE, curbuf);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3732 if (qi->qf_curlist < qi->qf_listcount)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3733 res = qi->qf_lists[qi->qf_curlist].qf_count;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3734 else
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3735 res = 0;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3736 }
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3737 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3738 if (res > 0 && !eap->forceit)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3739 qf_jump(qi, 0, 0, FALSE); /* display first error */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3741 mch_remove(fname);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3742 vim_free(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3743 vim_free(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3744 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3746 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3747 * Return the name for the errorfile, in allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3748 * Find a new unique name when 'makeef' contains "##".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3749 * Returns NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3750 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3751 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3752 get_mef_name(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3753 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3754 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3755 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3756 static int start = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3757 static int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3758 #ifdef HAVE_LSTAT
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents: 9379
diff changeset
3759 stat_T sb;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3760 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3762 if (*p_mef == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3763 {
6721
7347229a646a updated for version 7.4.684
Bram Moolenaar <bram@vim.org>
parents: 6450
diff changeset
3764 name = vim_tempname('e', FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3765 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3766 EMSG(_(e_notmp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3767 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3769
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3770 for (p = p_mef; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3771 if (p[0] == '#' && p[1] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3772 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3773
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3774 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3775 return vim_strsave(p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3777 /* Keep trying until the name doesn't exist yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3778 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3779 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3780 if (start == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3781 start = mch_get_pid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3782 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3783 off += 19;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3785 name = alloc((unsigned)STRLEN(p_mef) + 30);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3786 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3787 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3788 STRCPY(name, p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3789 sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3790 STRCAT(name, p + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3791 if (mch_getperm(name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3792 #ifdef HAVE_LSTAT
10226
7a4fb555c83a commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents: 10056
diff changeset
3793 /* Don't accept a symbolic link, it's a security risk. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3794 && mch_lstat((char *)name, &sb) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3795 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3798 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3799 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3800 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 /*
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3804 * 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
3805 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3806 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3807 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
3808 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3809 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3810 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3811 int i, sz = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3812 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3813
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3814 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
3815 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3816 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3817 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3818 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3819 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3820 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3821
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3822 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
3823 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
3824 ++i, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3825 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3826 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3827 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3828 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
3829 sz++; /* Count all valid entries */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3830 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
3831 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3832 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3833 sz++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3834 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3835 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3836 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3837 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3838
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3839 return sz;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3840 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3841
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3842 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3843 * 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
3844 * 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
3845 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3846 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3847 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
3848 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3849 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3850
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3851 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
3852 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3853 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3854 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3855 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3856 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3857 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3858
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3859 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
3860 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3861
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3862 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3863 * 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
3864 * 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
3865 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3866 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3867 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
3868 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3869 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3870 qf_list_T *qfl;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3871 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3872 int i, eidx = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3873 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3874
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3875 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
3876 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3877 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3878 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3879 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3880 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3881 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3882
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3883 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
3884 qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3885
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3886 /* 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
3887 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
3888 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3889
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3890 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
3891 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3892 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3893 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3894 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
3895 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3896 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
3897 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3898 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3899 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3900 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3901 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3902 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3903 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3904 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3905 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3906 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3907
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3908 return eidx ? eidx : 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3909 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3910
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3911 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3912 * 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
3913 * 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
3914 * 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
3915 * 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
3916 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3917 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3918 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
3919 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3920 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
3921 qfline_T *qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3922 int i, eidx;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3923 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3924
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3925 /* 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
3926 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
3927 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3928
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3929 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
3930 i++, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3931 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3932 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3933 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3934 if (fdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3935 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3936 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
3937 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3938 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3939 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3940 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3941 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3942 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3943 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3944 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3945 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3946
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3947 if (eidx == n)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3948 break;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3949 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3950
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3951 if (i <= qfl->qf_count)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3952 return i;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3953 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3954 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3955 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3956
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3957 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3958 * ":cc", ":crewind", ":cfirst" and ":clast".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3959 * ":ll", ":lrewind", ":lfirst" and ":llast".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3960 * ":cdo", ":ldo", ":cfdo" and ":lfdo"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3961 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3962 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3963 ex_cc(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3964 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3965 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
3966 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3967
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3968 if (eap->cmdidx == CMD_ll
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3969 || eap->cmdidx == CMD_lrewind
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3970 || eap->cmdidx == CMD_lfirst
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3971 || eap->cmdidx == CMD_llast
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3972 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3973 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3974 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3975 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3976 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3977 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3978 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3979 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3980 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3981 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3982
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3983 if (eap->addr_count > 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3984 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3985 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3986 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3987 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
3988 errornr = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3989 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
3990 || 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
3991 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3992 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3993 errornr = 32767;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3994 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3995
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3996 /* 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
3997 * 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
3998 */
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
3999 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4000 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4001 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
4002 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
4003 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
4004
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4005 qf_jump(qi, 0, errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4006 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4009 * ":cnext", ":cnfile", ":cNext" and ":cprevious".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4010 * ":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
4011 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4013 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4014 ex_cnext(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4015 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4016 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
4017 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4018
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4019 if (eap->cmdidx == CMD_lnext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4020 || eap->cmdidx == CMD_lNext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4021 || eap->cmdidx == CMD_lprevious
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4022 || eap->cmdidx == CMD_lnfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4023 || eap->cmdidx == CMD_lNfile
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4024 || eap->cmdidx == CMD_lpfile
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4025 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4026 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4027 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4028 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4029 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4030 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4031 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4032 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4033 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4034 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4035
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4036 if (eap->addr_count > 0
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4037 && (eap->cmdidx != CMD_cdo && eap->cmdidx != CMD_ldo
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4038 && eap->cmdidx != CMD_cfdo && eap->cmdidx != CMD_lfdo))
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4039 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4040 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4041 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4042
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4043 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
4044 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4045 ? FORWARD
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4046 : (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
4047 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4048 ? FORWARD_FILE
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4049 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4050 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4051 ? BACKWARD_FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4052 : BACKWARD,
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4053 errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4055
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4056 /*
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4057 * ":cfile"/":cgetfile"/":caddfile" commands.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4058 * ":lfile"/":lgetfile"/":laddfile" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4059 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4060 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4061 ex_cfile(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4062 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4063 char_u *enc = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4064 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4065 qf_info_T *qi = &ql_info;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4066 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4067 char_u *au_name = NULL;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4068 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4069 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4070
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4071 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4072 || eap->cmdidx == CMD_laddfile)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4073 wp = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4074
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4075 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4076 switch (eap->cmdidx)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4077 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4078 case CMD_cfile: au_name = (char_u *)"cfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4079 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4080 case CMD_caddfile: au_name = (char_u *)"caddfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4081 case CMD_lfile: au_name = (char_u *)"lfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4082 case CMD_lgetfile: au_name = (char_u *)"lgetfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4083 case CMD_laddfile: au_name = (char_u *)"laddfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4084 default: break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4085 }
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4086 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4087 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4088 #endif
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4089 #ifdef FEAT_MBYTE
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4090 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4091 #endif
2296
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4092 #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
4093 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
4094 {
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4095 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
4096 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
4097 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
4098 return;
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4099 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
4100 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
4101 }
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4102 else
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4103 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 if (*eap->arg != NUL)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 682
diff changeset
4105 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4106
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4107 /*
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4108 * This function is used by the :cfile, :cgetfile and :caddfile
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4109 * commands.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4110 * :cfile always creates a new quickfix list and jumps to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4111 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4112 * :cgetfile creates a new quickfix list but doesn't jump to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4113 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4114 * :caddfile adds to an existing quickfix list. If there is no
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4115 * quickfix list then a new list is created.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4116 */
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4117 res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4118 && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4119 if (wp != NULL)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4120 qi = GET_LOC_LIST(wp);
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4121 if (res >= 0 && qi != NULL)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4122 qf_list_changed(qi, qi->qf_curlist);
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4123 #ifdef FEAT_AUTOCMD
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4124 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4125 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4126 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4127 if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4128 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4129 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
4130 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4131 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4133 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4134 * ":vimgrep {pattern} file(s)"
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4135 * ":vimgrepadd {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4136 * ":lvimgrep {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4137 * ":lvimgrepadd {pattern} file(s)"
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4138 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4139 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4140 ex_vimgrep(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4141 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4142 regmmatch_T regmatch;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4143 int fcount;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4144 char_u **fnames;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4145 char_u *fname;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4146 char_u *title;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4147 char_u *s;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4148 char_u *p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4149 int fi;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4150 qf_info_T *qi = &ql_info;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4151 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4152 qfline_T *cur_qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4153 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4154 long lnum;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4155 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4156 int duplicate_name = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4157 int using_dummy;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4158 int redraw_for_dummy = FALSE;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4159 int found_match;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4160 buf_T *first_match_buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4161 time_t seconds = 0;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4162 int save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4163 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4164 char_u *save_ei = NULL;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4165 #endif
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4166 aco_save_T aco;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4167 int flags = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4168 colnr_T col;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4169 long tomatch;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4170 char_u *dirname_start = NULL;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4171 char_u *dirname_now = NULL;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4172 char_u *target_dir = NULL;
1683
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4173 #ifdef FEAT_AUTOCMD
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4174 char_u *au_name = NULL;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4175
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4176 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4177 {
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4178 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4179 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4180 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4181 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break;
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4182 case CMD_grep: au_name = (char_u *)"grep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4183 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4184 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4185 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4186 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4187 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4188 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4189 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4190 {
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4191 # ifdef FEAT_EVAL
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4192 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4193 return;
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4194 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4195 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4196 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4197
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4198 if (eap->cmdidx == CMD_lgrep
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4199 || eap->cmdidx == CMD_lvimgrep
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4200 || eap->cmdidx == CMD_lgrepadd
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4201 || eap->cmdidx == CMD_lvimgrepadd)
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4202 {
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4203 qi = ll_get_or_alloc_list(curwin);
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4204 if (qi == NULL)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4205 return;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4206 }
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4207
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4208 if (eap->addr_count > 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4209 tomatch = eap->line2;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4210 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4211 tomatch = MAXLNUM;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4212
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4213 /* Get the search pattern: either white-separated or enclosed in // */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4214 regmatch.regprog = NULL;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4215 title = vim_strsave(*eap->cmdlinep);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4216 p = skip_vimgrep_pat(eap->arg, &s, &flags);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4217 if (p == NULL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4218 {
282
33d9c918b8ab updated for version 7.0075
vimboss
parents: 277
diff changeset
4219 EMSG(_(e_invalpat));
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4220 goto theend;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4221 }
4197
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4222
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4223 if (s != NULL && *s == NUL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4224 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4225 /* Pattern is empty, use last search pattern. */
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4226 if (last_search_pat() == NULL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4227 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4228 EMSG(_(e_noprevre));
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4229 goto theend;
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4230 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4231 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4232 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4233 else
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4234 regmatch.regprog = vim_regcomp(s, RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4235
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4236 if (regmatch.regprog == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4237 goto theend;
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 42
diff changeset
4238 regmatch.rmm_ic = p_ic;
410
c60ba877860b updated for version 7.0107
vimboss
parents: 359
diff changeset
4239 regmatch.rmm_maxcol = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4240
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4241 p = skipwhite(p);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4242 if (*p == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4243 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4244 EMSG(_("E683: File name missing or invalid pattern"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4245 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4246 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4247
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4248 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4249 && eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4250 || qi->qf_curlist == qi->qf_listcount)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4251 /* 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
4252 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4253
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4254 /* parse the list of arguments */
3620
4f1c511e71f8 updated for version 7.3.570
Bram Moolenaar <bram@vim.org>
parents: 3555
diff changeset
4255 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4256 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4257 if (fcount == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4258 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4259 EMSG(_(e_nomatch));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4260 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4261 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4262
7558
9a4c9dccd603 commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents: 7515
diff changeset
4263 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
4264 dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4265 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
4266 {
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4267 FreeWild(fcount, fnames);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4268 goto theend;
7662
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4269 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4270
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4271 /* Remember the current directory, because a BufRead autocommand that does
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4272 * ":lcd %:p:h" changes the meaning of short path names. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4273 mch_dirname(dirname_start, MAXPATHL);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4274
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4275 #ifdef FEAT_AUTOCMD
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4197
diff changeset
4276 /* Remember the value of qf_start, so that we can check for autocommands
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4277 * changing the current quickfix list. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4278 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4279 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4280
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4281 seconds = (time_t)0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4282 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4283 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4284 fname = shorten_fname1(fnames[fi]);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4285 if (time(NULL) > seconds)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4286 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4287 /* Display the file name every second or so, show the user we are
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4288 * working on it. */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4289 seconds = time(NULL);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4290 msg_start();
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4291 p = msg_strtrunc(fname, TRUE);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4292 if (p == NULL)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4293 msg_outtrans(fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4294 else
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4295 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4296 msg_outtrans(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4297 vim_free(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4298 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4299 msg_clr_eos();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4300 msg_didout = FALSE; /* overwrite this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4301 msg_nowait = TRUE; /* don't wait for this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4302 msg_col = 0;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4303 out_flush();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4304 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4305
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4306 buf = buflist_findname_exp(fnames[fi]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4307 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4308 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4309 /* Remember that a buffer with this name already exists. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4310 duplicate_name = (buf != NULL);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4311 using_dummy = TRUE;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4312 redraw_for_dummy = TRUE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4313
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4314 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4315 /* Don't do Filetype autocommands to avoid loading syntax and
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4316 * indent scripts, a great speed improvement. */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4317 save_ei = au_event_disable(",Filetype");
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4318 #endif
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4319 /* Don't use modelines here, it's useless. */
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4320 save_mls = p_mls;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4321 p_mls = 0;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4322
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4323 /* Load file into a buffer, so that 'fileencoding' is detected,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4324 * autocommands applied, etc. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4325 buf = load_dummy_buffer(fname, dirname_start, dirname_now);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4326
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4327 p_mls = save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4328 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4329 au_event_restore(save_ei);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4330 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4331 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4332 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4333 /* Use existing, loaded buffer. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4334 using_dummy = FALSE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4335
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4336 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4337 if (cur_qf_start != qi->qf_lists[qi->qf_curlist].qf_start)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4338 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4339 int idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4340
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4341 /* Autocommands changed the quickfix list. Find the one we were
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4342 * using and restore it. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4343 for (idx = 0; idx < LISTCOUNT; ++idx)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4344 if (cur_qf_start == qi->qf_lists[idx].qf_start)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4345 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4346 qi->qf_curlist = idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4347 break;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4348 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4349 if (idx == LISTCOUNT)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4350 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4351 /* List cannot be found, create a new one. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4352 qf_new_list(qi, *eap->cmdlinep);
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4353 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4354 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4355 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4356 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4357
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4358 if (buf == NULL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4359 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4360 if (!got_int)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4361 smsg((char_u *)_("Cannot open file \"%s\""), fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4362 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4363 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4364 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4365 /* Try for a match in all lines of the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4366 * For ":1vimgrep" look for first match only. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4367 found_match = FALSE;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4368 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4369 ++lnum)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4370 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4371 col = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4372 while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11516
diff changeset
4373 col, NULL, NULL) > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4374 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4375 /* Pass the buffer number so that it gets used even for a
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4376 * dummy buffer, unless duplicate_name is set, then the
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4377 * buffer will be wiped out below. */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4378 if (qf_add_entry(qi,
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
4379 qi->qf_curlist,
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4380 NULL, /* dir */
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4381 fname,
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4382 duplicate_name ? 0 : buf->b_fnum,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4383 ml_get_buf(buf,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4384 regmatch.startpos[0].lnum + lnum, FALSE),
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4385 regmatch.startpos[0].lnum + lnum,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4386 regmatch.startpos[0].col + 1,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4387 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4388 NULL, /* search pattern */
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4389 0, /* nr */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4390 0, /* type */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4391 TRUE /* valid */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4392 ) == FAIL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4393 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4394 got_int = TRUE;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4395 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4396 }
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4397 found_match = TRUE;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4398 if (--tomatch == 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4399 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4400 if ((flags & VGR_GLOBAL) == 0
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4401 || regmatch.endpos[0].lnum > 0)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4402 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4403 col = regmatch.endpos[0].col
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4404 + (col == regmatch.endpos[0].col);
1883
c8f343a465a2 updated for version 7.2-180
vimboss
parents: 1872
diff changeset
4405 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE)))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4406 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4407 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4408 line_breakcheck();
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4409 if (got_int)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4410 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4411 }
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4412 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4413 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4414 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4415
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4416 if (using_dummy)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4417 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4418 if (found_match && first_match_buf == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4419 first_match_buf = buf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4420 if (duplicate_name)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4421 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4422 /* Never keep a dummy buffer if there is another buffer
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4423 * with the same name. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4424 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4425 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4426 }
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4427 else if (!cmdmod.hide
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4428 || buf->b_p_bh[0] == 'u' /* "unload" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4429 || buf->b_p_bh[0] == 'w' /* "wipe" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4430 || buf->b_p_bh[0] == 'd') /* "delete" */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4431 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4432 /* When no match was found we don't need to remember the
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4433 * buffer, wipe it out. If there was a match and it
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4434 * wasn't the first one or we won't jump there: only
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4435 * unload the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4436 * Ignore 'hidden' here, because it may lead to having too
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4437 * many swap files. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4438 if (!found_match)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4439 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4440 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4441 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4442 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4443 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4444 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4445 unload_dummy_buffer(buf, dirname_start);
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4446 /* Keeping the buffer, remove the dummy flag. */
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4447 buf->b_flags &= ~BF_DUMMY;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4448 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4449 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4450 }
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4451
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4452 if (buf != NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4453 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4454 /* Keeping the buffer, remove the dummy flag. */
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4455 buf->b_flags &= ~BF_DUMMY;
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4456
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4457 /* If the buffer is still loaded we need to use the
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4458 * directory we jumped to below. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4459 if (buf == first_match_buf
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4460 && target_dir == NULL
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4461 && STRCMP(dirname_start, dirname_now) != 0)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4462 target_dir = vim_strsave(dirname_now);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4463
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4464 /* The buffer is still loaded, the Filetype autocommands
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4465 * need to be done now, in that buffer. And the modelines
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4466 * need to be done (again). But not the window-local
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4467 * options! */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4468 aucmd_prepbuf(&aco, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4469 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4470 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4471 buf->b_fname, TRUE, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4472 #endif
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4473 do_modelines(OPT_NOWIN);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4474 aucmd_restbuf(&aco);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4475 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4476 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4477 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4478 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4479
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4480 FreeWild(fcount, fnames);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4481
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4482 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4483 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4484 qi->qf_lists[qi->qf_curlist].qf_index = 1;
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4485 qf_list_changed(qi, qi->qf_curlist);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4486
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4487 qf_update_buffer(qi, NULL);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4488
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4489 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4490 if (au_name != NULL)
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4491 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4492 curbuf->b_fname, TRUE, curbuf);
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4493 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4494
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4495 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4496 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4497 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4498 if ((flags & VGR_NOJUMP) == 0)
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4499 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4500 buf = curbuf;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4501 qf_jump(qi, 0, 0, eap->forceit);
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4502 if (buf != curbuf)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4503 /* If we jumped to another buffer redrawing will already be
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4504 * taken care of. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4505 redraw_for_dummy = FALSE;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4506
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4507 /* Jump to the directory used after loading the buffer. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4508 if (curbuf == first_match_buf && target_dir != NULL)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4509 {
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4510 exarg_T ea;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4511
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4512 ea.arg = target_dir;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4513 ea.cmdidx = CMD_lcd;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4514 ex_cd(&ea);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4515 }
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4516 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4517 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4518 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4519 EMSG2(_(e_nomatch2), s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4520
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4521 /* If we loaded a dummy buffer into the current window, the autocommands
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4522 * may have messed up things, need to redraw and recompute folds. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4523 if (redraw_for_dummy)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4524 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4525 #ifdef FEAT_FOLDING
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4526 foldUpdateAll(curwin);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4527 #else
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4528 redraw_later(NOT_VALID);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4529 #endif
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4530 }
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4531
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4532 theend:
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4533 vim_free(title);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4534 vim_free(dirname_now);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4535 vim_free(dirname_start);
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4536 vim_free(target_dir);
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
4537 vim_regfree(regmatch.regprog);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4538 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4539
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4540 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4541 * Restore current working directory to "dirname_start" if they differ, taking
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4542 * into account whether it is set locally or globally.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4543 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4544 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4545 restore_start_dir(char_u *dirname_start)
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4546 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4547 char_u *dirname_now = alloc(MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4548
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4549 if (NULL != dirname_now)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4550 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4551 mch_dirname(dirname_now, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4552 if (STRCMP(dirname_start, dirname_now) != 0)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4553 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4554 /* If the directory has changed, change it back by building up an
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4555 * appropriate ex command and executing it. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4556 exarg_T ea;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4557
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4558 ea.arg = dirname_start;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4559 ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4560 ex_cd(&ea);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4561 }
3974
4d1753f3e85c updated for version 7.3.742
Bram Moolenaar <bram@vim.org>
parents: 3965
diff changeset
4562 vim_free(dirname_now);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4563 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4564 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4565
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4566 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4567 * Load file "fname" into a dummy buffer and return the buffer pointer,
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4568 * placing the directory resulting from the buffer load into the
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4569 * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4570 * prior to calling this function. Restores directory to "dirname_start" prior
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4571 * to returning, if autocmds or the 'autochdir' option have changed it.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4572 *
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4573 * If creating the dummy buffer does not fail, must call unload_dummy_buffer()
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4574 * or wipe_dummy_buffer() later!
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4575 *
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4576 * Returns NULL if it fails.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4577 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4578 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4579 load_dummy_buffer(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4580 char_u *fname,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4581 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
4582 char_u *resulting_dir) /* out: new directory */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4583 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4584 buf_T *newbuf;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4585 bufref_T newbufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4586 bufref_T newbuf_to_wipe;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4587 int failed = TRUE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4588 aco_save_T aco;
13056
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4589 int readfile_result;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4590
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4591 /* Allocate a buffer without putting it in the buffer list. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4592 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4593 if (newbuf == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4594 return NULL;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4595 set_bufref(&newbufref, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4596
177
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4597 /* Init the options. */
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4598 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4599
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4600 /* need to open the memfile before putting the buffer in a window */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4601 if (ml_open(newbuf) == OK)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4602 {
13056
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4603 /* Make sure this buffer isn't wiped out by auto commands. */
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4604 ++newbuf->b_locked;
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4605
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4606 /* set curwin/curbuf to buf and save a few things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4607 aucmd_prepbuf(&aco, newbuf);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4608
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4609 /* Need to set the filename for autocommands. */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4610 (void)setfname(curbuf, fname, NULL, FALSE);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4611
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4612 /* Create swap file now to avoid the ATTENTION message. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4613 check_need_swap(TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4614
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4615 /* Remove the "dummy" flag, otherwise autocommands may not
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4616 * work. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4617 curbuf->b_flags &= ~BF_DUMMY;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4618
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4619 newbuf_to_wipe.br_buf = NULL;
13056
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4620 readfile_result = readfile(fname, NULL,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4621 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
13056
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4622 NULL, READ_NEW | READ_DUMMY);
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4623 --newbuf->b_locked;
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4624 if (readfile_result == OK
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4625 && !got_int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4626 && !(curbuf->b_flags & BF_NEW))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4627 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4628 failed = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4629 if (curbuf != newbuf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4630 {
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4631 /* Bloody autocommands changed the buffer! Can happen when
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4632 * using netrw and editing a remote file. Use the current
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4633 * buffer instead, delete the dummy one after restoring the
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4634 * window stuff. */
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4635 set_bufref(&newbuf_to_wipe, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4636 newbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4637 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4638 }
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4639
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4640 /* restore curwin/curbuf and a few other things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4641 aucmd_restbuf(&aco);
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4642 if (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe))
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4643 wipe_buffer(newbuf_to_wipe.br_buf, FALSE);
9485
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4644
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4645 /* Add back the "dummy" flag, otherwise buflist_findname_stat() won't
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4646 * skip it. */
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4647 newbuf->b_flags |= BF_DUMMY;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4648 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4649
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4650 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4651 * When autocommands/'autochdir' option changed directory: go back.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4652 * Let the caller know what the resulting dir was first, in case it is
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4653 * important.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4654 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4655 mch_dirname(resulting_dir, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4656 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4657
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4658 if (!bufref_valid(&newbufref))
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4659 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4660 if (failed)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4661 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4662 wipe_dummy_buffer(newbuf, dirname_start);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4663 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4664 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4665 return newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4666 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4667
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4668 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4669 * Wipe out the dummy buffer that load_dummy_buffer() created. Restores
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4670 * directory to "dirname_start" prior to returning, if autocmds or the
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4671 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4672 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4673 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4674 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4675 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4676 if (curbuf != buf) /* safety check */
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4677 {
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4678 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4679 cleanup_T cs;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4680
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4681 /* Reset the error/interrupt/exception state here so that aborting()
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4682 * returns FALSE when wiping out the buffer. Otherwise it doesn't
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4683 * work when got_int is set. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4684 enter_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4685 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4686
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4687 wipe_buffer(buf, FALSE);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4688
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4689 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4690 /* Restore the error/interrupt/exception state if not discarded by a
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4691 * new aborting error, interrupt, or uncaught exception. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4692 leave_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4693 #endif
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4694 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4695 restore_start_dir(dirname_start);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4696 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4697 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4698
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4699 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4700 * Unload the dummy buffer that load_dummy_buffer() created. Restores
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4701 * directory to "dirname_start" prior to returning, if autocmds or the
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4702 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4703 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4704 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4705 unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4706 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4707 if (curbuf != buf) /* safety check */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4708 {
3365
9ccdc4a69d8f updated for version 7.3.449
Bram Moolenaar <bram@vim.org>
parents: 3269
diff changeset
4709 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4710
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4711 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4712 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4713 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4714 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4715
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4716 #if defined(FEAT_EVAL) || defined(PROTO)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4717 /*
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4718 * Add each quickfix error to list "list" as a dictionary.
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4719 * If qf_idx is -1, use the current list. Otherwise, use the specified list.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4720 */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4721 int
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4722 get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4723 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4724 qf_info_T *qi = qi_arg;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4725 dict_T *dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4726 char_u buf[2];
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4727 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4728 int i;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4729 int bufnum;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4730
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4731 if (qi == NULL)
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4732 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4733 qi = &ql_info;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4734 if (wp != NULL)
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4735 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4736 qi = GET_LOC_LIST(wp);
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4737 if (qi == NULL)
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4738 return FAIL;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4739 }
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4740 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4741
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4742 if (qf_idx == -1)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4743 qf_idx = qi->qf_curlist;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4744
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4745 if (qf_idx >= qi->qf_listcount
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4746 || qi->qf_lists[qf_idx].qf_count == 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4747 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4748
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4749 qfp = qi->qf_lists[qf_idx].qf_start;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4750 for (i = 1; !got_int && i <= qi->qf_lists[qf_idx].qf_count; ++i)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4751 {
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4752 /* Handle entries with a non-existing buffer number. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4753 bufnum = qfp->qf_fnum;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4754 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4755 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4756
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4757 if ((dict = dict_alloc()) == NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4758 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4759 if (list_append_dict(list, dict) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4760 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4761
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4762 buf[0] = qfp->qf_type;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4763 buf[1] = NUL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4764 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4765 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4766 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4767 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4768 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
960
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4769 || dict_add_nr_str(dict, "pattern", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4770 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4771 || dict_add_nr_str(dict, "text", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4772 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4773 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4774 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4775 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4776
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4777 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4778 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4779 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4780 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4781 return OK;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4782 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4783
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4784 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4785 * Flags used by getqflist()/getloclist() to determine which fields to return.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4786 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4787 enum {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4788 QF_GETLIST_NONE = 0x0,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4789 QF_GETLIST_TITLE = 0x1,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4790 QF_GETLIST_ITEMS = 0x2,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4791 QF_GETLIST_NR = 0x4,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4792 QF_GETLIST_WINID = 0x8,
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4793 QF_GETLIST_CONTEXT = 0x10,
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4794 QF_GETLIST_ID = 0x20,
12465
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4795 QF_GETLIST_IDX = 0x40,
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4796 QF_GETLIST_SIZE = 0x80,
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4797 QF_GETLIST_TICK = 0x100,
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4798 QF_GETLIST_ALL = 0x1FF
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4799 };
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4800
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4801 /*
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4802 * Parse text from 'di' and return the quickfix list items
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4803 */
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4804 static int
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4805 qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4806 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4807 int status = FAIL;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4808 qf_info_T *qi;
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4809 char_u *errorformat = p_efm;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4810 dictitem_T *efm_di;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4811 list_T *l;
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4812
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
4813 /* Only a List value is supported */
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
4814 if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4815 {
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4816 /* If errorformat is supplied then use it, otherwise use the 'efm'
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4817 * option setting
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4818 */
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4819 if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL)
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4820 {
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4821 if (efm_di->di_tv.v_type != VAR_STRING ||
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4822 efm_di->di_tv.vval.v_string == NULL)
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4823 return FAIL;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4824 errorformat = efm_di->di_tv.vval.v_string;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4825 }
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4826
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4827 l = list_alloc();
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4828 if (l == NULL)
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4829 return FAIL;
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4830
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4831 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4832 if (qi != NULL)
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4833 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4834 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4835 qi->qf_refcount++;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4836
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4837 if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4838 TRUE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4839 {
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4840 (void)get_errorlist(qi, NULL, 0, l);
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4841 qf_free(qi, 0);
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4842 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4843 free(qi);
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4844 }
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4845 dict_add_list(retdict, "items", l);
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4846 status = OK;
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4847 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4848
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4849 return status;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4850 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4851
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4852 /*
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4853 * Return the quickfix/location list number with the given identifier.
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4854 * Returns -1 if list is not found.
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4855 */
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4856 static int
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4857 qf_id2nr(qf_info_T *qi, int_u qfid)
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4858 {
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4859 int qf_idx;
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4860
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4861 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4862 if (qi->qf_lists[qf_idx].qf_id == qfid)
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4863 return qf_idx;
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4864 return -1;
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4865 }
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4866
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4867 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4868 * Return quickfix/location list details (title) as a
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4869 * dictionary. 'what' contains the details to return. If 'list_idx' is -1,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4870 * then current list is used. Otherwise the specified list is used.
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4871 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4872 int
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4873 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4874 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4875 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4876 int status = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4877 int qf_idx;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4878 dictitem_T *di;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4879 int flags = QF_GETLIST_NONE;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4880
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
4881 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL)
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4882 return qf_get_list_from_lines(what, di, retdict);
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4883
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4884 if (wp != NULL)
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4885 qi = GET_LOC_LIST(wp);
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4886
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4887 if (dict_find(what, (char_u *)"all", -1) != NULL)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4888 flags |= QF_GETLIST_ALL;
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4889
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4890 if (dict_find(what, (char_u *)"title", -1) != NULL)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4891 flags |= QF_GETLIST_TITLE;
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4892
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4893 if (dict_find(what, (char_u *)"nr", -1) != NULL)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4894 flags |= QF_GETLIST_NR;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4895
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4896 if (dict_find(what, (char_u *)"winid", -1) != NULL)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4897 flags |= QF_GETLIST_WINID;
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4898
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4899 if (dict_find(what, (char_u *)"context", -1) != NULL)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4900 flags |= QF_GETLIST_CONTEXT;
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4901
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4902 if (dict_find(what, (char_u *)"id", -1) != NULL)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4903 flags |= QF_GETLIST_ID;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4904
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4905 if (dict_find(what, (char_u *)"items", -1) != NULL)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4906 flags |= QF_GETLIST_ITEMS;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4907
12465
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4908 if (dict_find(what, (char_u *)"idx", -1) != NULL)
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4909 flags |= QF_GETLIST_IDX;
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4910
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4911 if (dict_find(what, (char_u *)"size", -1) != NULL)
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4912 flags |= QF_GETLIST_SIZE;
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
4913
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4914 if (dict_find(what, (char_u *)"changedtick", -1) != NULL)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4915 flags |= QF_GETLIST_TICK;
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4916
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4917 if (qi != NULL && qi->qf_listcount != 0)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4918 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4919 qf_idx = qi->qf_curlist; /* default is the current list */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4920 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4921 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4922 /* Use the specified quickfix/location list */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4923 if (di->di_tv.v_type == VAR_NUMBER)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4924 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4925 /* for zero use the current list */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4926 if (di->di_tv.vval.v_number != 0)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4927 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4928 qf_idx = di->di_tv.vval.v_number - 1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4929 if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4930 qf_idx = -1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4931 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4932 }
13066
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
4933 else if (di->di_tv.v_type == VAR_STRING
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
4934 && di->di_tv.vval.v_string != NULL
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
4935 && STRCMP(di->di_tv.vval.v_string, "$") == 0)
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4936 /* Get the last quickfix list number */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4937 qf_idx = qi->qf_listcount - 1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4938 else
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4939 qf_idx = -1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4940 flags |= QF_GETLIST_NR;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4941 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4942
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4943 if ((di = dict_find(what, (char_u *)"id", -1)) != NULL)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4944 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4945 /* Look for a list with the specified id */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4946 if (di->di_tv.v_type == VAR_NUMBER)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4947 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4948 /*
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4949 * For zero, use the current list or the list specifed by 'nr'
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4950 */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4951 if (di->di_tv.vval.v_number != 0)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4952 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4953 flags |= QF_GETLIST_ID;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4954 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4955 else
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4956 qf_idx = -1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4957 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4958 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4959
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4960 /* List is not present or is empty */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4961 if (qi == NULL || qi->qf_listcount == 0 || qf_idx == -1)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4962 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4963 if (flags & QF_GETLIST_TITLE)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4964 status = dict_add_nr_str(retdict, "title", 0L, (char_u *)"");
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4965 if ((status == OK) && (flags & QF_GETLIST_ITEMS))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4966 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4967 list_T *l = list_alloc();
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4968 if (l != NULL)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4969 status = dict_add_list(retdict, "items", l);
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4970 else
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4971 status = FAIL;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4972 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4973 if ((status == OK) && (flags & QF_GETLIST_NR))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4974 status = dict_add_nr_str(retdict, "nr", 0L, NULL);
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4975 if ((status == OK) && (flags & QF_GETLIST_WINID))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4976 status = dict_add_nr_str(retdict, "winid", 0L, NULL);
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4977 if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4978 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4979 if ((status == OK) && (flags & QF_GETLIST_ID))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4980 status = dict_add_nr_str(retdict, "id", 0L, NULL);
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4981 if ((status == OK) && (flags & QF_GETLIST_IDX))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4982 status = dict_add_nr_str(retdict, "idx", 0L, NULL);
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4983 if ((status == OK) && (flags & QF_GETLIST_SIZE))
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4984 status = dict_add_nr_str(retdict, "size", 0L, NULL);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4985 if ((status == OK) && (flags & QF_GETLIST_TICK))
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
4986 status = dict_add_nr_str(retdict, "changedtick", 0L, NULL);
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4987
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4988 return status;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4989 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4990
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4991 if (flags & QF_GETLIST_TITLE)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4992 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4993 char_u *t;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4994 t = qi->qf_lists[qf_idx].qf_title;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4995 if (t == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4996 t = (char_u *)"";
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4997 status = dict_add_nr_str(retdict, "title", 0L, t);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4998 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4999 if ((status == OK) && (flags & QF_GETLIST_NR))
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5000 status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5001 if ((status == OK) && (flags & QF_GETLIST_WINID))
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5002 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5003 win_T *win;
13016
e47e70300f30 patch 8.0.1384: not enough quickfix help; confusing winid
Christian Brabandt <cb@256bit.org>
parents: 12954
diff changeset
5004 int win_id = 0;
e47e70300f30 patch 8.0.1384: not enough quickfix help; confusing winid
Christian Brabandt <cb@256bit.org>
parents: 12954
diff changeset
5005
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5006 win = qf_find_win(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5007 if (win != NULL)
13016
e47e70300f30 patch 8.0.1384: not enough quickfix help; confusing winid
Christian Brabandt <cb@256bit.org>
parents: 12954
diff changeset
5008 win_id = win->w_id;
e47e70300f30 patch 8.0.1384: not enough quickfix help; confusing winid
Christian Brabandt <cb@256bit.org>
parents: 12954
diff changeset
5009 status = dict_add_nr_str(retdict, "winid", win_id, NULL);
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5010 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5011 if ((status == OK) && (flags & QF_GETLIST_ITEMS))
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5012 {
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5013 list_T *l = list_alloc();
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5014 if (l != NULL)
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5015 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5016 (void)get_errorlist(qi, NULL, qf_idx, l);
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5017 dict_add_list(retdict, "items", l);
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5018 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5019 else
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5020 status = FAIL;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5021 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5022
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5023 if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5024 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5025 if (qi->qf_lists[qf_idx].qf_ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5026 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5027 di = dictitem_alloc((char_u *)"context");
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5028 if (di != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5029 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5030 copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv);
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5031 status = dict_add(retdict, di);
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5032 if (status == FAIL)
11422
ad4b56939140 patch 8.0.0595: Coverity warning for not checking return value
Christian Brabandt <cb@256bit.org>
parents: 11412
diff changeset
5033 dictitem_free(di);
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5034 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5035 else
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5036 status = FAIL;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5037 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5038 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5039 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5040 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5041
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5042 if ((status == OK) && (flags & QF_GETLIST_ID))
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5043 status = dict_add_nr_str(retdict, "id", qi->qf_lists[qf_idx].qf_id,
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5044 NULL);
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5045
12465
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5046 if ((status == OK) && (flags & QF_GETLIST_IDX))
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5047 {
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5048 int idx = qi->qf_lists[qf_idx].qf_index;
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5049 if (qi->qf_lists[qf_idx].qf_count == 0)
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5050 /* For empty lists, qf_index is set to 1 */
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5051 idx = 0;
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5052 status = dict_add_nr_str(retdict, "idx", idx, NULL);
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5053 }
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5054
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5055 if ((status == OK) && (flags & QF_GETLIST_SIZE))
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5056 status = dict_add_nr_str(retdict, "size",
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5057 qi->qf_lists[qf_idx].qf_count, NULL);
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5058
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5059 if ((status == OK) && (flags & QF_GETLIST_TICK))
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5060 status = dict_add_nr_str(retdict, "changedtick",
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5061 qi->qf_lists[qf_idx].qf_changedtick, NULL);
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5062
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5063 return status;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5064 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5065
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5066 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5067 * Add list of entries to quickfix/location list. Each list entry is
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5068 * a dictionary with item information.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5069 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5070 static int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5071 qf_add_entries(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5072 qf_info_T *qi,
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5073 int qf_idx,
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5074 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5075 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5076 int action)
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5077 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5078 listitem_T *li;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5079 dict_T *d;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5080 char_u *filename, *pattern, *text, *type;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5081 int bufnum;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5082 long lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5083 int col, nr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5084 int vcol;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
5085 qfline_T *old_last = NULL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5086 int valid, status;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5087 int retval = OK;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5088 int did_bufnr_emsg = FALSE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5089
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5090 if (action == ' ' || qf_idx == qi->qf_listcount)
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5091 {
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
5092 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
5093 qf_new_list(qi, title);
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5094 qf_idx = qi->qf_curlist;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5095 }
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5096 else if (action == 'a' && qi->qf_lists[qf_idx].qf_count > 0)
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5097 /* Adding to existing list, use last entry. */
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5098 old_last = qi->qf_lists[qf_idx].qf_last;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
5099 else if (action == 'r')
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
5100 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5101 qf_free_items(qi, qf_idx);
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5102 qf_store_title(qi, qf_idx, title);
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
5103 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5104
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5105 for (li = list->lv_first; li != NULL; li = li->li_next)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5106 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5107 if (li->li_tv.v_type != VAR_DICT)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5108 continue; /* Skip non-dict items */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5109
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5110 d = li->li_tv.vval.v_dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5111 if (d == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5112 continue;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5113
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5114 filename = get_dict_string(d, (char_u *)"filename", TRUE);
9389
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
5115 bufnum = (int)get_dict_number(d, (char_u *)"bufnr");
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
5116 lnum = (int)get_dict_number(d, (char_u *)"lnum");
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
5117 col = (int)get_dict_number(d, (char_u *)"col");
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
5118 vcol = (int)get_dict_number(d, (char_u *)"vcol");
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
5119 nr = (int)get_dict_number(d, (char_u *)"nr");
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5120 type = get_dict_string(d, (char_u *)"type", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5121 pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5122 text = get_dict_string(d, (char_u *)"text", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5123 if (text == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5124 text = vim_strsave((char_u *)"");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5125
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5126 valid = TRUE;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5127 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5128 valid = FALSE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5129
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5130 /* Mark entries with non-existing buffer number as not valid. Give the
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5131 * error message only once. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5132 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5133 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5134 if (!did_bufnr_emsg)
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5135 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5136 did_bufnr_emsg = TRUE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5137 EMSGN(_("E92: Buffer %ld not found"), bufnum);
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5138 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5139 valid = FALSE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5140 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5141 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5142
11390
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
5143 /* If the 'valid' field is present it overrules the detected value. */
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
5144 if ((dict_find(d, (char_u *)"valid", -1)) != NULL)
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
5145 valid = (int)get_dict_number(d, (char_u *)"valid");
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
5146
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5147 status = qf_add_entry(qi,
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5148 qf_idx,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5149 NULL, /* dir */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5150 filename,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5151 bufnum,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5152 text,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5153 lnum,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5154 col,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5155 vcol, /* vis_col */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5156 pattern, /* search pattern */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5157 nr,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5158 type == NULL ? NUL : *type,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5159 valid);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5160
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5161 vim_free(filename);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5162 vim_free(pattern);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5163 vim_free(text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5164 vim_free(type);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5165
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5166 if (status == FAIL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5167 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5168 retval = FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5169 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5170 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5171 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5172
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5173 if (qi->qf_lists[qf_idx].qf_index == 0)
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
5174 /* no valid entry */
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5175 qi->qf_lists[qf_idx].qf_nonevalid = TRUE;
2146
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
5176 else
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5177 qi->qf_lists[qf_idx].qf_nonevalid = FALSE;
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5178 if (action != 'a')
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5179 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5180 qi->qf_lists[qf_idx].qf_ptr =
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5181 qi->qf_lists[qf_idx].qf_start;
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5182 if (qi->qf_lists[qf_idx].qf_count > 0)
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5183 qi->qf_lists[qf_idx].qf_index = 1;
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
5184 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5185
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
5186 /* 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
5187 qf_update_buffer(qi, old_last);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5188
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5189 return retval;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5190 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5191
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5192 static int
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5193 qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5194 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5195 dictitem_T *di;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5196 int retval = FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5197 int qf_idx;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5198 int newlist = FALSE;
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5199 char_u *errorformat = p_efm;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5200
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5201 if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5202 newlist = TRUE;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5203
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5204 qf_idx = qi->qf_curlist; /* default is the current list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5205 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5206 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5207 /* Use the specified quickfix/location list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5208 if (di->di_tv.v_type == VAR_NUMBER)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5209 {
11445
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5210 /* for zero use the current list */
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5211 if (di->di_tv.vval.v_number != 0)
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5212 qf_idx = di->di_tv.vval.v_number - 1;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5213
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5214 if ((action == ' ' || action == 'a') && qf_idx == qi->qf_listcount)
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5215 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5216 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5217 * When creating a new list, accept qf_idx pointing to the next
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5218 * non-available list and add the new list at the end of the
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5219 * stack.
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5220 */
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5221 newlist = TRUE;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5222 qf_idx = qi->qf_listcount - 1;
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5223 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5224 else if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5225 return FAIL;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5226 else if (action != ' ')
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5227 newlist = FALSE; /* use the specified list */
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5228 }
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5229 else if (di->di_tv.v_type == VAR_STRING
13066
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
5230 && di->di_tv.vval.v_string != NULL
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
5231 && STRCMP(di->di_tv.vval.v_string, "$") == 0)
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5232 {
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5233 if (qi->qf_listcount > 0)
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5234 qf_idx = qi->qf_listcount - 1;
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5235 else if (newlist)
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5236 qf_idx = 0;
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5237 else
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5238 return FAIL;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5239 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5240 else
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5241 return FAIL;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5242 }
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5243
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5244 if (!newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5245 {
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5246 /* Use the quickfix/location list with the specified id */
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5247 if (di->di_tv.v_type == VAR_NUMBER)
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5248 {
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5249 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5250 if (qf_idx == -1)
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5251 return FAIL; /* List not found */
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5252 }
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5253 else
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5254 return FAIL;
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5255 }
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5256
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5257 if (newlist)
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5258 {
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5259 qi->qf_curlist = qf_idx;
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5260 qf_new_list(qi, title);
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5261 qf_idx = qi->qf_curlist;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5262 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5263
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5264 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5265 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5266 if (di->di_tv.v_type == VAR_STRING)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5267 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5268 vim_free(qi->qf_lists[qf_idx].qf_title);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5269 qi->qf_lists[qf_idx].qf_title =
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5270 get_dict_string(what, (char_u *)"title", TRUE);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5271 if (qf_idx == qi->qf_curlist)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5272 qf_update_win_titlevar(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5273 retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5274 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5275 }
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5276
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5277 if ((di = dict_find(what, (char_u *)"items", -1)) != NULL)
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5278 {
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5279 if (di->di_tv.v_type == VAR_LIST)
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5280 {
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5281 char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title);
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5282
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5283 retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list,
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5284 title_save, action == ' ' ? 'a' : action);
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5285 if (action == 'r')
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5286 {
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5287 /*
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5288 * When replacing the quickfix list entries using
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5289 * qf_add_entries(), the title is set with a ':' prefix.
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5290 * Restore the title with the saved title.
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5291 */
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5292 vim_free(qi->qf_lists[qf_idx].qf_title);
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5293 qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save);
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5294 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5295 vim_free(title_save);
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5296 }
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5297 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5298
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5299 if ((di = dict_find(what, (char_u *)"efm", -1)) != NULL)
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5300 {
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5301 if (di->di_tv.v_type != VAR_STRING || di->di_tv.vval.v_string == NULL)
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5302 return FAIL;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5303 errorformat = di->di_tv.vval.v_string;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5304 }
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5305
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5306 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL)
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5307 {
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5308 /* Only a List value is supported */
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5309 if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5310 {
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5311 if (action == 'r')
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5312 qf_free_items(qi, qf_idx);
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5313 if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat,
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5314 FALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5315 retval = OK;
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5316 }
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5317 else
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5318 return FAIL;
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5319 }
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5320
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5321 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5322 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5323 typval_T *ctx;
11502
46bbef0ee9a6 patch 8.0.0634: cannot easily get to the last quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11449
diff changeset
5324
11445
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5325 free_tv(qi->qf_lists[qf_idx].qf_ctx);
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5326 ctx = alloc_tv();
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5327 if (ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5328 copy_tv(&di->di_tv, ctx);
11445
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5329 qi->qf_lists[qf_idx].qf_ctx = ctx;
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5330 retval = OK;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5331 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5332
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5333 if (retval == OK)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5334 qf_list_changed(qi, qf_idx);
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5335
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5336 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5337 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5338
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5339 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5340 * Find the non-location list window with the specified location list.
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5341 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5342 static win_T *
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5343 find_win_with_ll(qf_info_T *qi)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5344 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5345 win_T *wp = NULL;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5346
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5347 FOR_ALL_WINDOWS(wp)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5348 if ((wp->w_llist == qi) && !bt_quickfix(wp->w_buffer))
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5349 return wp;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5350
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5351 return NULL;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5352 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5353
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5354 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5355 * Free the entire quickfix/location list stack.
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5356 * If the quickfix/location list window is open, then clear it.
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5357 */
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5358 static void
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5359 qf_free_stack(win_T *wp, qf_info_T *qi)
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5360 {
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5361 win_T *qfwin = qf_find_win(qi);
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5362 win_T *llwin = NULL;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5363 win_T *orig_wp = wp;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5364
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5365 if (qfwin != NULL)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5366 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5367 /* If the quickfix/location list window is open, then clear it */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5368 if (qi->qf_curlist < qi->qf_listcount)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5369 qf_free(qi, qi->qf_curlist);
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5370 qf_update_buffer(qi, NULL);
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5371 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5372
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5373 if (wp != NULL && IS_LL_WINDOW(wp))
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5374 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5375 /* If in the location list window, then use the non-location list
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5376 * window with this location list (if present)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5377 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5378 llwin = find_win_with_ll(qi);
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5379 if (llwin != NULL)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5380 wp = llwin;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5381 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5382
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5383 qf_free_all(wp);
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5384 if (wp == NULL)
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5385 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5386 /* quickfix list */
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5387 qi->qf_curlist = 0;
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5388 qi->qf_listcount = 0;
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5389 }
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5390 else if (IS_LL_WINDOW(orig_wp))
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5391 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5392 /* If the location list window is open, then create a new empty
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5393 * location list */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5394 qf_info_T *new_ll = ll_new_list();
11378
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
5395
11398
30af33f4d353 patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents: 11390
diff changeset
5396 /* first free the list reference in the location list window */
30af33f4d353 patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents: 11390
diff changeset
5397 ll_free_all(&orig_wp->w_llist_ref);
30af33f4d353 patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents: 11390
diff changeset
5398
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5399 orig_wp->w_llist_ref = new_ll;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5400 if (llwin != NULL)
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5401 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5402 llwin->w_llist = new_ll;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5403 new_ll->qf_refcount++;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5404 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5405 }
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5406 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5407
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5408 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5409 * Populate the quickfix list with the items supplied in the list
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5410 * of dictionaries. "title" will be copied to w:quickfix_title.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5411 * "action" is 'a' for add, 'r' for replace. Otherwise create a new list.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5412 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5413 int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5414 set_errorlist(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5415 win_T *wp,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5416 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5417 int action,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5418 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5419 dict_T *what)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5420 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5421 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5422 int retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5423
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5424 if (wp != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5425 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5426 qi = ll_get_or_alloc_list(wp);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5427 if (qi == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5428 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5429 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5430
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5431 if (action == 'f')
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5432 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5433 /* Free the entire quickfix or location list stack */
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5434 qf_free_stack(wp, qi);
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5435 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5436 else if (what != NULL)
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5437 retval = qf_set_properties(qi, what, action, title);
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5438 else
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5439 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5440 retval = qf_add_entries(qi, qi->qf_curlist, list, title, action);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5441 if (retval == OK)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5442 qf_list_changed(qi, qi->qf_curlist);
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5443 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5444
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5445 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5446 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5447
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5448 static int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5449 mark_quickfix_ctx(qf_info_T *qi, int copyID)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5450 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5451 int i;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5452 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5453 typval_T *ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5454
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5455 for (i = 0; i < LISTCOUNT && !abort; ++i)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5456 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5457 ctx = qi->qf_lists[i].qf_ctx;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5458 if (ctx != NULL && ctx->v_type != VAR_NUMBER
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5459 && ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT)
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5460 abort = set_ref_in_item(ctx, copyID, NULL, NULL);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5461 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5462
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5463 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5464 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5465
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5466 /*
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5467 * Mark the context of the quickfix list and the location lists (if present) as
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5468 * "in use". So that garabage collection doesn't free the context.
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5469 */
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5470 int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5471 set_ref_in_quickfix(int copyID)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5472 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5473 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5474 tabpage_T *tp;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5475 win_T *win;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5476
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5477 abort = mark_quickfix_ctx(&ql_info, copyID);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5478 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5479 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5480
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5481 FOR_ALL_TAB_WINDOWS(tp, win)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5482 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5483 if (win->w_llist != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5484 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5485 abort = mark_quickfix_ctx(win->w_llist, copyID);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5486 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5487 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5488 }
13074
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5489 if (IS_LL_WINDOW(win) && (win->w_llist_ref->qf_refcount == 1))
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5490 {
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5491 /* In a location list window and none of the other windows is
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5492 * referring to this location list. Mark the location list
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5493 * context as still in use.
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5494 */
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5495 abort = mark_quickfix_ctx(win->w_llist_ref, copyID);
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5496 if (abort)
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5497 return abort;
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5498 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5499 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5500
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5501 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5502 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5503 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5504
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5505 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5506 * ":[range]cbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
5507 * ":[range]caddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5508 * ":[range]cgetbuffer [bufnr]" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5509 * ":[range]lbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
5510 * ":[range]laddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5511 * ":[range]lgetbuffer [bufnr]" command.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5512 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5513 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5514 ex_cbuffer(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5515 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5516 buf_T *buf = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5517 qf_info_T *qi = &ql_info;
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5518 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5519 char_u *au_name = NULL;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5520 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5521 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5522
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5523 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5524 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5525 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5526 case CMD_cbuffer: au_name = (char_u *)"cbuffer"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5527 case CMD_cgetbuffer: au_name = (char_u *)"cgetbuffer"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5528 case CMD_caddbuffer: au_name = (char_u *)"caddbuffer"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5529 case CMD_lbuffer: au_name = (char_u *)"lbuffer"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5530 case CMD_lgetbuffer: au_name = (char_u *)"lgetbuffer"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5531 case CMD_laddbuffer: au_name = (char_u *)"laddbuffer"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5532 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5533 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5534 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5535 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5536 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5537 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5538 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5539 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5540 # endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5541 }
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5542 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5543
13076
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5544 /* Must come after autocommands. */
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5545 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5546 || eap->cmdidx == CMD_laddbuffer)
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5547 {
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5548 qi = ll_get_or_alloc_list(curwin);
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5549 if (qi == NULL)
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5550 return;
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5551 }
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5552
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5553 if (*eap->arg == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5554 buf = curbuf;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5555 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5556 buf = buflist_findnr(atoi((char *)eap->arg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5557 if (buf == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5558 EMSG(_(e_invarg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5559 else if (buf->b_ml.ml_mfp == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5560 EMSG(_("E681: Buffer is not loaded"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5561 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5562 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5563 if (eap->addr_count == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5564 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5565 eap->line1 = 1;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5566 eap->line2 = buf->b_ml.ml_line_count;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5567 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5568 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5569 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5570 EMSG(_(e_invrange));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5571 else
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5572 {
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5573 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
5574
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5575 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
5576 {
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5577 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
5578 (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
5579 qf_title = IObuff;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5580 }
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5581
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5582 res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5583 (eap->cmdidx != CMD_caddbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5584 && 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
5585 eap->line1, eap->line2,
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5586 qf_title, NULL);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5587 if (res >= 0)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5588 qf_list_changed(qi, qi->qf_curlist);
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5589 #ifdef FEAT_AUTOCMD
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5590 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5591 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5592 curbuf->b_fname, TRUE, curbuf);
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5593 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5594 if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5595 eap->cmdidx == CMD_lbuffer))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5596 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5597 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5598 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5599 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5600
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
5601 #if defined(FEAT_EVAL) || defined(PROTO)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5602 /*
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5603 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command.
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5604 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command.
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5605 */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5606 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5607 ex_cexpr(exarg_T *eap)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5608 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5609 typval_T *tv;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5610 qf_info_T *qi = &ql_info;
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5611 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5612 char_u *au_name = NULL;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5613 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5614 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5615
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5616 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5617 || eap->cmdidx == CMD_laddexpr)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5618 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5619 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5620 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5621 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5622 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5623
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5624 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5625 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5626 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5627 case CMD_cexpr: au_name = (char_u *)"cexpr"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5628 case CMD_cgetexpr: au_name = (char_u *)"cgetexpr"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5629 case CMD_caddexpr: au_name = (char_u *)"caddexpr"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5630 case CMD_lexpr: au_name = (char_u *)"lexpr"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5631 case CMD_lgetexpr: au_name = (char_u *)"lgetexpr"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5632 case CMD_laddexpr: au_name = (char_u *)"laddexpr"; break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5633 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5634 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5635 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5636 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5637 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5638 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5639 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5640 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5641 # endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5642 }
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5643 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5644
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5645 /* Evaluate the expression. When the result is a string or a list we can
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5646 * use it to fill the errorlist. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5647 tv = eval_expr(eap->arg, NULL);
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5648 if (tv != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5649 {
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5650 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5651 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5652 {
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5653 res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm,
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5654 (eap->cmdidx != CMD_caddexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5655 && eap->cmdidx != CMD_laddexpr),
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
5656 (linenr_T)0, (linenr_T)0, *eap->cmdlinep,
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5657 NULL);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5658 if (res >= 0)
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5659 qf_list_changed(qi, qi->qf_curlist);
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5660 #ifdef FEAT_AUTOCMD
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5661 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5662 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5663 curbuf->b_fname, TRUE, curbuf);
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5664 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5665 if (res > 0 && (eap->cmdidx == CMD_cexpr ||
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5666 eap->cmdidx == CMD_lexpr))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5667 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5668 }
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5669 else
626
732c7ae5743e updated for version 7.0180
vimboss
parents: 625
diff changeset
5670 EMSG(_("E777: String or List expected"));
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5671 free_tv(tv);
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5672 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5673 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
5674 #endif
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5675
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5676 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677 * ":helpgrep {pattern}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5679 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5680 ex_helpgrep(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5681 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683 char_u *save_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 int fcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 int fi;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 long lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5690 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5691 char_u *lang;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5692 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5693 qf_info_T *qi = &ql_info;
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5694 qf_info_T *save_qi;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5695 int new_qi = FALSE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5696 win_T *wp;
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5697 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5698 char_u *au_name = NULL;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5699 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5701 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5702 /* Check for a specified language */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5703 lang = check_help_lang(eap->arg);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5704 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5705
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5706 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5707 switch (eap->cmdidx)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5708 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5709 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5710 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5711 default: break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5712 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5713 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5714 curbuf->b_fname, TRUE, curbuf))
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5715 {
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5716 # ifdef FEAT_EVAL
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5717 if (aborting())
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5718 return;
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5719 # endif
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5720 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5721 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5722
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5723 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5724 save_cpo = p_cpo;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5725 p_cpo = empty_option;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5726
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5727 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5728 {
11800
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5729 /* If the current window is a help window, then use it */
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5730 if (bt_help(curwin->w_buffer))
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5731 wp = curwin;
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5732 else
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5733 /* Find an existing help window */
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5734 FOR_ALL_WINDOWS(wp)
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5735 if (bt_help(wp->w_buffer))
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5736 break;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5737
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5738 if (wp == NULL) /* Help window not found */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5739 qi = NULL;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5740 else
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5741 qi = wp->w_llist;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5742
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5743 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5744 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5745 /* Allocate a new location list for help text matches */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5746 if ((qi = ll_new_list()) == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5747 return;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5748 new_qi = TRUE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5749 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5750 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5751
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5752 /* Autocommands may change the list. Save it for later comparison */
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5753 save_qi = qi;
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5754
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5756 regmatch.rm_ic = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5757 if (regmatch.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5759 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5760 vimconv_T vc;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5761
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5762 /* Help files are in utf-8 or latin1, convert lines when 'encoding'
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5763 * differs. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5764 vc.vc_type = CONV_NONE;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5765 if (!enc_utf8)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5766 convert_setup(&vc, (char_u *)"utf-8", p_enc);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5767 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5768
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 /* create a new quickfix list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
5770 qf_new_list(qi, *eap->cmdlinep);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 /* Go through all directories in 'runtimepath' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 p = p_rtp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 while (*p != NUL && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 copy_option_part(&p, NameBuff, MAXPATHL, ",");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 add_pathsep(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 if (gen_expand_wildcards(1, &NameBuff, &fcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 &fnames, EW_FILE|EW_SILENT) == OK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 && fcount > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 for (fi = 0; fi < fcount && !got_int; ++fi)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5787 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5788 /* Skip files for a different language. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5789 if (lang != NULL
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5790 && STRNICMP(lang, fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5791 + STRLEN(fnames[fi]) - 3, 2) != 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5792 && !(STRNICMP(lang, "en", 2) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5793 && STRNICMP("txt", fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5794 + STRLEN(fnames[fi]) - 3, 3) == 0))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5795 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5796 #endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 514
diff changeset
5797 fd = mch_fopen((char *)fnames[fi], "r");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5798 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5800 lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5803 char_u *line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5804 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5805 /* Convert a line if 'encoding' is not utf-8 and
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5806 * the line contains a non-ASCII character. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5807 if (vc.vc_type != CONV_NONE
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5808 && has_non_ascii(IObuff))
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5809 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5810 line = string_convert(&vc, IObuff, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5811 if (line == NULL)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5812 line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5813 }
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5814 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5815
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5816 if (vim_regexec(&regmatch, line, (colnr_T)0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5818 int l = (int)STRLEN(line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820 /* remove trailing CR, LF, spaces, etc. */
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5821 while (l > 0 && line[l - 1] <= ' ')
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5822 line[--l] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5824 if (qf_add_entry(qi,
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5825 qi->qf_curlist,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5826 NULL, /* dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 fnames[fi],
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5828 0,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5829 line,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 lnum,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5831 (int)(regmatch.startp[0] - line)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5832 + 1, /* col */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5833 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5834 NULL, /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 0, /* nr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 1, /* type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 TRUE /* valid */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 ) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 got_int = TRUE;
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5841 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5842 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5843 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5844 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5848 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5849 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5850 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5851 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5852 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5853 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5855 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5856 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5857 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 FreeWild(fcount, fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5860 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5861
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
5862 vim_regfree(regmatch.regprog);
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5863 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5864 if (vc.vc_type != CONV_NONE)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5865 convert_setup(&vc, NULL, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5866 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5868 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5869 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5870 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5871 qi->qf_lists[qi->qf_curlist].qf_index = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873
1672
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5874 if (p_cpo == empty_option)
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5875 p_cpo = save_cpo;
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5876 else
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5877 /* Darn, some plugin changed the value. */
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5878 free_string_option(save_cpo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5880 qf_list_changed(qi, qi->qf_curlist);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
5881 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5883 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5884 if (au_name != NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5885 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5886 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5887 curbuf->b_fname, TRUE, curbuf);
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5888 if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL)
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5889 /* autocommands made "qi" invalid */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5890 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5891 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5892 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5893
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5895 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5896 qf_jump(qi, 0, 0, FALSE);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5897 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5898 EMSG2(_(e_nomatch2), eap->arg);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5899
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5900 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5901 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5902 /* If the help window is not opened or if it already points to the
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5903 * correct location list, then free the new location list. */
11800
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5904 if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5905 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5906 if (new_qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5907 ll_free_all(&qi);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5908 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5909 else if (curwin->w_llist == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5910 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5911 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914 #endif /* FEAT_QUICKFIX */