annotate src/quickfix.c @ 13115:9812a9ca3ab2 v8.0.1432

patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window commit https://github.com/vim/vim/commit/2ec364e94dbc080ccdf6c5dfc6f1653b5b7ded64 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 27 11:52:13 2018 +0100 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window Problem: After ":copen" can't get the window-ID of the quickfix window. (FalacerSelene) Solution: Make it work without a quickfix list. Add a test. (Yegappan Lakshmanan, closes #2541)
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Jan 2018 12:00:06 +0100
parents bfa7f5b23c53
children ac42c4b11dbc
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 *);
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
147 static int qflist_valid(win_T *wp, int_u qf_id);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 static qf_info_T *ll_get_or_alloc_list(win_T *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
164 /* Quickfix window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
165 #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
166 /* Location list window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
167 #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
168 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
169 * Return location list for window 'wp'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
170 * For location list window, return the referenced location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
171 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
172 #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
173
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 /*
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
175 * 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
176 * 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
177 */
11447
698ee9d4fe9f patch 8.0.0607: after :bwipe + :new bufref might still be valid
Christian Brabandt <cb@256bit.org>
parents: 11445
diff changeset
178 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
179 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
180
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
181 static char *e_loc_list_changed =
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
182 N_("E926: Current location list was changed");
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
183
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
184 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
185 * 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
186 * list. Set the error list's title to qf_title.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 * Return -1 for error, number of errors for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 int
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
190 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
191 char_u *efile,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
192 char_u *errorformat,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
193 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
194 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
195 char_u *enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
197 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
198
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
199 if (wp != NULL)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
200 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
201 qi = ll_get_or_alloc_list(wp);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
202 if (qi == NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
203 return FAIL;
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
204 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
205
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
206 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
207 newlist, (linenr_T)0, (linenr_T)0, qf_title, enc);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
208 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
209
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
210 /*
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
211 * 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
212 */
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
213 #define LINE_MAXLEN 4096
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
214
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
215 static struct fmtpattern
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
216 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
217 char_u convchar;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
218 char *pattern;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
219 } fmt_pat[FMT_PATTERNS] =
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
220 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
221 {'f', ".\\+"}, /* only used when at end */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
222 {'n', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
223 {'l', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
224 {'c', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
225 {'t', "."},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
226 {'m', ".\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
227 {'r', ".*"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
228 {'p', "[- .]*"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
229 {'v', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
230 {'s', ".\\+"}
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
231 };
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
232
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
233 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
234 * Converts a 'errorformat' string to regular expression pattern
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
235 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
236 static int
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
237 efm_to_regpat(
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
238 char_u *efm,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
239 int len,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
240 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
241 char_u *regpat,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
242 char_u *errmsg)
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
243 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
244 char_u *ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
245 char_u *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
246 char_u *srcptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
247 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
248 int idx = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
249
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
250 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
251 * Build regexp pattern from current 'errorformat' option
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
252 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
253 ptr = regpat;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
254 *ptr++ = '^';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
255 round = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
256 for (efmp = efm; efmp < efm + len; ++efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
257 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
258 if (*efmp == '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
259 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
260 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
261 for (idx = 0; idx < FMT_PATTERNS; ++idx)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
262 if (fmt_pat[idx].convchar == *efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
263 break;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
264 if (idx < FMT_PATTERNS)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
265 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
266 if (fmt_ptr->addr[idx])
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
267 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
268 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
269 _("E372: Too many %%%c in format string"), *efmp);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
270 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
271 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
272 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
273 if ((idx
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
274 && idx < 6
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
275 && vim_strchr((char_u *)"DXOPQ",
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
276 fmt_ptr->prefix) != NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
277 || (idx == 6
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
278 && vim_strchr((char_u *)"OPQ",
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
279 fmt_ptr->prefix) == NULL))
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
280 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
281 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
282 _("E373: Unexpected %%%c in format string"), *efmp);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
283 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
284 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
285 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
286 fmt_ptr->addr[idx] = (char_u)++round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
287 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
288 *ptr++ = '(';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
289 #ifdef BACKSLASH_IN_FILENAME
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
290 if (*efmp == 'f')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
291 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
292 /* Also match "c:" in the file name, even when
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
293 * checking for a colon next: "%f:".
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
294 * "\%(\a:\)\=" */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
295 STRCPY(ptr, "\\%(\\a:\\)\\=");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
296 ptr += 10;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
297 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
298 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
299 if (*efmp == 'f' && efmp[1] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
300 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
301 if (efmp[1] != '\\' && efmp[1] != '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
302 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
303 /* A file name may contain spaces, but this isn't
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
304 * in "\f". For "%f:%l:%m" there may be a ":" in
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
305 * the file name. Use ".\{-1,}x" instead (x is
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
306 * the next character), the requirement that :999:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
307 * follows should work. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
308 STRCPY(ptr, ".\\{-1,}");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
309 ptr += 7;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
310 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
311 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
312 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
313 /* File name followed by '\\' or '%': include as
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
314 * many file name chars as possible. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
315 STRCPY(ptr, "\\f\\+");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
316 ptr += 4;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
317 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
318 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
319 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
320 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
321 srcptr = (char_u *)fmt_pat[idx].pattern;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
322 while ((*ptr = *srcptr++) != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
323 ++ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
324 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
325 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
326 *ptr++ = ')';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
327 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
328 else if (*efmp == '*')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
329 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
330 if (*++efmp == '[' || *efmp == '\\')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
331 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
332 if ((*ptr++ = *efmp) == '[') /* %*[^a-z0-9] etc. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
333 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
334 if (efmp[1] == '^')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
335 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
336 if (efmp < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
337 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
338 *ptr++ = *++efmp; /* could be ']' */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
339 while (efmp < efm + len
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
340 && (*ptr++ = *++efmp) != ']')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
341 /* skip */;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
342 if (efmp == efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
343 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
344 EMSG(_("E374: Missing ] in format string"));
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
345 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
346 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
347 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
348 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
349 else if (efmp < efm + len) /* %*\D, %*\s etc. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
350 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
351 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
352 *ptr++ = '+';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
353 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
354 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
355 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
356 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
357 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
358 _("E375: Unsupported %%%c in format string"), *efmp);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
359 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
360 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
361 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
362 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
363 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
364 *ptr++ = *efmp; /* regexp magic characters */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
365 else if (*efmp == '#')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
366 *ptr++ = '*';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
367 else if (*efmp == '>')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
368 fmt_ptr->conthere = TRUE;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
369 else if (efmp == efm + 1) /* analyse prefix */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
370 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
371 if (vim_strchr((char_u *)"+-", *efmp) != NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
372 fmt_ptr->flags = *efmp++;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
373 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
374 fmt_ptr->prefix = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
375 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
376 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
377 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
378 _("E376: Invalid %%%c in format string prefix"), *efmp);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
379 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
380 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
381 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
382 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
383 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
384 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
385 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
386 _("E377: Invalid %%%c in format string"), *efmp);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
387 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
388 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
389 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
390 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
391 else /* copy normal character */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
392 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
393 if (*efmp == '\\' && efmp + 1 < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
394 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
395 else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
396 *ptr++ = '\\'; /* escape regexp atoms */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
397 if (*efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
398 *ptr++ = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
399 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
400 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
401 *ptr++ = '$';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
402 *ptr = NUL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
403
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
404 return 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
405 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
406
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
407 static void
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
408 free_efm_list(efm_T **efm_first)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
409 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
410 efm_T *efm_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
411
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
412 for (efm_ptr = *efm_first; efm_ptr != NULL; efm_ptr = *efm_first)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
413 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
414 *efm_first = efm_ptr->next;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
415 vim_regfree(efm_ptr->prog);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
416 vim_free(efm_ptr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
417 }
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
418 fmt_start = NULL;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
419 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
420
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
421 /* Parse 'errorformat' option */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
422 static efm_T *
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
423 parse_efm_option(char_u *efm)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
424 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
425 char_u *errmsg = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
426 int errmsglen;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
427 efm_T *fmt_ptr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
428 efm_T *fmt_first = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
429 efm_T *fmt_last = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
430 char_u *fmtstr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
431 int len;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
432 int i;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
433 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
434
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
435 errmsglen = CMDBUFFSIZE + 1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
436 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
437 if (errmsg == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
438 goto parse_efm_end;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
439
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
440 /*
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
441 * 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
442 * 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
443 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
444
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
445 /*
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
446 * 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
447 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
448 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
449 for (round = FMT_PATTERNS; round > 0; )
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
450 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
451 #ifdef BACKSLASH_IN_FILENAME
c7164578e508 patch 8.0.1144: using wrong #ifdef for computing length
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
452 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
453 #else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
454 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
455 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
456 if ((fmtstr = alloc(i)) == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
457 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
458
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
459 while (efm[0] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
460 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
461 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
462 * 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
463 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
464 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
465 if (fmt_ptr == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
466 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
467 if (fmt_first == NULL) /* first one */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
468 fmt_first = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
469 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
470 fmt_last->next = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
471 fmt_last = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
472
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
473 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
474 * 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
475 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
476 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
477 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
478 ++len;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
479
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
480 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
481 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
482 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
483 goto parse_efm_error;
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 * Advance to next part
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
486 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
487 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
488 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
489
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
490 if (fmt_first == NULL) /* nothing found */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
491 EMSG(_("E378: 'errorformat' contains no pattern"));
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
492
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
493 goto parse_efm_end;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
494
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
495 parse_efm_error:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
496 free_efm_list(&fmt_first);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
497
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
498 parse_efm_end:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
499 vim_free(fmtstr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
500 vim_free(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
501
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
502 return fmt_first;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
503 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
504
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
505 enum {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
506 QF_FAIL = 0,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
507 QF_OK = 1,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
508 QF_END_OF_INPUT = 2,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
509 QF_NOMEM = 3,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
510 QF_IGNORE_LINE = 4
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
511 };
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
512
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
513 typedef struct {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
514 char_u *linebuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
515 int linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
516 char_u *growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
517 int growbufsiz;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
518 FILE *fd;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
519 typval_T *tv;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
520 char_u *p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
521 listitem_T *p_li;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
522 buf_T *buf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
523 linenr_T buflnum;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
524 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
525 vimconv_T vc;
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
526 } qfstate_T;
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 static char_u *
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
529 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
530 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
531 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
532 * 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
533 * 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
534 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
535 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
536 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
537 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
538 state->growbuf = alloc(state->linelen + 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
539 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
540 return NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
541 state->growbufsiz = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
542 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
543 else if (state->linelen > state->growbufsiz)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
544 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
545 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
546 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
547 return NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
548 state->growbufsiz = state->linelen;
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 return state->growbuf;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
553 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
554 * 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
555 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
556 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
557 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
558 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
559 /* 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
560 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
561 char_u *p;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
562 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
563
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
564 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
565 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
566
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
567 p = vim_strchr(p_str, '\n');
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
568 if (p != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
569 len = (int)(p - p_str) + 1;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
570 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
571 len = (int)STRLEN(p_str);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
572
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
573 if (len > IOSIZE - 2)
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 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
576 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
577 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
578 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
579 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
580 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
581 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
582 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
583 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
584 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
585
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
586 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
587 * 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
588 * line if it exceeds LINE_MAXLEN.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
589 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
590 p_str += len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
591 state->p_str = p_str;
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 return QF_OK;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
596 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
597 * 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
598 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
599 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
600 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
601 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
602 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
603 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
604
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
605 while (p_li != NULL
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
606 && (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
607 || 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
608 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
609
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
610 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
611 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
612 state->p_li = NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
613 return QF_END_OF_INPUT;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
616 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
617 if (len > IOSIZE - 2)
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 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
620 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
621 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
622 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
623 else
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 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
626 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
627 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
628
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
629 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
630
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
631 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
632 return QF_OK;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
635 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
636 * 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
637 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
638 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
639 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
640 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
641 char_u *p_buf = NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
642 int len;
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 /* 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
645 if (state->buflnum > state->lnumlast)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
646 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
647
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
648 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
649 state->buflnum += 1;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
650
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
651 len = (int)STRLEN(p_buf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
652 if (len > IOSIZE - 2)
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 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
655 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
656 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
657 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
658 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
659 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
660 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
661 state->linelen = len;
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 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
664
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
665 return QF_OK;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
668 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
669 * 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
670 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
671 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
672 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
673 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
674 int discard;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
675 int growbuflen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
676
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
677 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
678 return QF_END_OF_INPUT;
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 discard = FALSE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
681 state->linelen = (int)STRLEN(IObuff);
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
682 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
683 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
684 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
685 * 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
686 * 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
687 */
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 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
690 state->growbufsiz = 2 * (IOSIZE - 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
691 state->growbuf = alloc(state->growbufsiz);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
692 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
693 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
694 }
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 /* 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
697 memcpy(state->growbuf, IObuff, IOSIZE - 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
698 growbuflen = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
699
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
700 for (;;)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
701 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
702 if (fgets((char *)state->growbuf + growbuflen,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
703 state->growbufsiz - growbuflen, state->fd) == NULL)
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 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
706 growbuflen += state->linelen;
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
707 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
708 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
709 if (state->growbufsiz == LINE_MAXLEN)
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 discard = TRUE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
712 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
713 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
714
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
715 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
716 ? 2 * state->growbufsiz : LINE_MAXLEN;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
717 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
718 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
719 return QF_NOMEM;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
722 while (discard)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
723 {
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 * 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
726 * 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
727 * reached.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
728 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
729 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
730 || (int)STRLEN(IObuff) < IOSIZE - 1
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
731 || IObuff[IOSIZE - 1] == '\n')
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
732 break;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
735 state->linebuf = state->growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
736 state->linelen = growbuflen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
737 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
738 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
739 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
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 #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
742 /* 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
743 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
744 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
745 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
746
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
747 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
748 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
749 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
750 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
751 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
752 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
753 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
754 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
755 else
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
756 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
757 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
758 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
759 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
760 ? 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
761 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
762 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
763 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
764 #endif
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
765
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
766 return QF_OK;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
769 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
770 * 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
771 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
772 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
773 qf_get_nextline(qfstate_T *state)
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 int status = QF_FAIL;
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->fd == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
778 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
779 if (state->tv != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
780 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
781 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
782 /* 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
783 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
784 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
785 /* 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
786 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
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 buffer */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
790 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
791 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
792 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
793 /* 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
794 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
795
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
796 if (status != QF_OK)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
797 return status;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
798
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
799 /* remove newline/CR from the line */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
800 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
801 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
802 state->linebuf[state->linelen - 1] = NUL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
803 #ifdef USE_CRNL
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
804 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
805 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
806 #endif
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
807 }
9531
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 #ifdef FEAT_MBYTE
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
810 remove_bom(state->linebuf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
811 #endif
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
812
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
813 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
814 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
815
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
816 typedef struct {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
817 char_u *namebuf;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
818 char_u *errmsg;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
819 int errmsglen;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
820 long lnum;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
821 int col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
822 char_u use_viscol;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
823 char_u *pattern;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
824 int enr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
825 int type;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
826 int valid;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
827 } qffields_T;
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 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
830 * 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
831 * Return the QF_ status.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
832 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
833 static int
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
834 qf_parse_line(
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
835 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
836 int qf_idx,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
837 char_u *linebuf,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
838 int linelen,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
839 efm_T *fmt_first,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
840 qffields_T *fields)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
841 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
842 efm_T *fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
843 char_u *ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
844 int len;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
845 int i;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
846 int idx = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
847 char_u *tail = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
848 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
849 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
850
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
851 /* 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
852 regmatch.rm_ic = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
853
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
854 /* 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
855 if (fmt_start == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
856 fmt_ptr = fmt_first;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
857 else
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 fmt_ptr = fmt_start;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
860 fmt_start = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
861 }
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 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
864 * 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
865 * match or no match.
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 fields->valid = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
868 restofline:
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
869 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
870 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
871 int r;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
872
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
873 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
874 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
875 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
876 fields->namebuf[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
877 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
878 if (!qfl->qf_multiscan)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
879 fields->errmsg[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
880 fields->lnum = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
881 fields->col = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
882 fields->use_viscol = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
883 fields->enr = -1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
884 fields->type = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
885 tail = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
886
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
887 regmatch.regprog = fmt_ptr->prog;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
888 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
889 fmt_ptr->prog = regmatch.regprog;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
890 if (r)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
891 {
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
892 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
893 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
894 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
895 fields->type = idx;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
896 else
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
897 fields->type = 0;
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 * 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
900 * 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
901 * 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
902 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
903 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
904 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
905 int c;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
906
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
907 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
908 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
909
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
910 /* 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
911 c = *regmatch.endp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
912 *regmatch.endp[i] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
913 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
914 *regmatch.endp[i] = c;
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 (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
917 && mch_getperm(fields->namebuf) == -1)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
918 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
919 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
920 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
921 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
922 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
923 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
924 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
925 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
926 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
927 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
928 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
929 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
930 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
931 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
932 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
933 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
934 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
935 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
936 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
937 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
938 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
939 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
940 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
941 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
942 fields->type = *regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
943 }
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
944 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
945 {
11426
3270f080bf0a patch 8.0.0597: off-by-one error in size computation
Christian Brabandt <cb@256bit.org>
parents: 11422
diff changeset
946 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
947 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
948 /* linelen + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
949 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
950 linelen + 1)) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
951 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
952 fields->errmsglen = linelen + 1;
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 vim_strncpy(fields->errmsg, linebuf, linelen);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
955 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
956 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
957 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
958 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
959 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
960 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
961 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
962 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
963 /* len + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
964 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
965 == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
966 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
967 fields->errmsglen = len + 1;
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 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
970 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
971 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
972 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
973 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
974 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
975 tail = regmatch.startp[i];
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 ((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
978 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
979 char_u *match_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
980
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
981 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
982 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
983 fields->col = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
984 for (match_ptr = regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
985 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
986 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
987 ++fields->col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
988 if (*match_ptr == TAB)
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 += 7;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
991 fields->col -= fields->col % 8;
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 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
994 ++fields->col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
995 fields->use_viscol = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
996 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
997 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
998 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
999 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1000 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1001 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
1002 fields->use_viscol = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1003 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1004 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
1005 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1006 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
1007 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1008 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
1009 if (len > CMDBUFFSIZE - 5)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1010 len = CMDBUFFSIZE - 5;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1011 STRCPY(fields->pattern, "^\\V");
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1012 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
1013 fields->pattern[len + 3] = '\\';
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1014 fields->pattern[len + 4] = '$';
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1015 fields->pattern[len + 5] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1016 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1017 break;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1018 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1019 }
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
1020 qfl->qf_multiscan = FALSE;
9568
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 (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
1023 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1024 if (fmt_ptr != NULL)
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 if (idx == 'D') /* enter directory */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1027 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1028 if (*fields->namebuf == NUL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1029 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1030 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
1031 return QF_FAIL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1032 }
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
1033 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
1034 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
1035 if (qfl->qf_directory == NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1036 return QF_FAIL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1037 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1038 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
1039 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
1040 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1041 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
1042 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
1043 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
1044 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
1045 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1046 /* linelen + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1047 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
1048 linelen + 1)) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1049 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1050 fields->errmsglen = linelen + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1051 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1052 /* copy whole line to error message */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1053 vim_strncpy(fields->errmsg, linebuf, linelen);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1054 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
1055 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
1056 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1057 else if (fmt_ptr != NULL)
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 /* honor %> item */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1060 if (fmt_ptr->conthere)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1061 fmt_start = fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1062
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1063 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
1064 {
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
1065 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
1066 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
1067 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1068 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
1069 { /* 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
1070 if (!qfl->qf_multiignore)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1071 {
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 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
1073
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1074 if (qfprev == NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1075 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
1076 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
1077 {
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1078 len = (int)STRLEN(qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1079 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
1080 == NULL)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1081 return QF_FAIL;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1082 STRCPY(ptr, qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1083 vim_free(qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1084 qfprev->qf_text = ptr;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1085 *(ptr += len) = '\n';
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1086 STRCPY(++ptr, fields->errmsg);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1087 }
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1088 if (qfprev->qf_nr == -1)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1089 qfprev->qf_nr = fields->enr;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1090 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
1091 /* only printable chars allowed */
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1092 qfprev->qf_type = fields->type;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1093
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1094 if (!qfprev->qf_lnum)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1095 qfprev->qf_lnum = fields->lnum;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1096 if (!qfprev->qf_col)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1097 qfprev->qf_col = fields->col;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1098 qfprev->qf_viscol = fields->use_viscol;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1099 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
1100 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
1101 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
1102 *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
1103 ? 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
1104 : 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
1105 ? qfl->qf_currfile : 0);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1106 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1107 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
1108 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
1109 line_breakcheck();
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1110 return QF_IGNORE_LINE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1111 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1112 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
1113 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1114 /* global file names */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1115 fields->valid = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1116 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
1117 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1118 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
1119 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
1120 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
1121 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
1122 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
1123 *fields->namebuf = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1124 if (tail && *tail)
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 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
1127 qfl->qf_multiscan = TRUE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1128 goto restofline;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1129 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1130 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1131 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1132 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
1133 {
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
1134 if (qfl->qf_multiline)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1135 /* 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
1136 qfl->qf_multiignore = TRUE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1137 return QF_IGNORE_LINE;
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 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1140
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1141 return QF_OK;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1142 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1143
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
1144 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1145 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1146 * list.
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1147 * 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
1148 * 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
1149 * 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
1150 * 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
1151 * Set the title of the list to "qf_title".
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1152 * Return -1 for error, number of errors for success.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1153 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1154 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1155 qf_init_ext(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1156 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
1157 int qf_idx,
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1158 char_u *efile,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1159 buf_T *buf,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1160 typval_T *tv,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1161 char_u *errorformat,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1162 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
1163 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
1164 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
1165 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
1166 char_u *enc)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1167 {
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
1168 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
1169 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
1170 qffields_T fields;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1171 qfline_T *old_last = NULL;
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1172 int adding = FALSE;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1173 static efm_T *fmt_first = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 char_u *efm;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1175 static char_u *last_efm = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 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
1177 int status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1178
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1179 /* 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
1180 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
1181 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
1182
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1183 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
1184 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
1185 #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
1186 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
1187 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
1188 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
1189 #endif
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1190 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
1191 fields.errmsglen = CMDBUFFSIZE + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1192 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
1193 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
1194 if (fields.namebuf == NULL || fields.errmsg == NULL || fields.pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1197 if (efile != NULL && (state.fd = mch_fopen((char *)efile, "r")) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 EMSG2(_(e_openerrf), efile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
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 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
1204 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
1206 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
1207 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
1208 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
1209 else
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1210 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1211 /* 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
1212 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
1213 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
1214 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
1215 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216
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
1217 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
1218
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 /* Use the local value of 'errorformat' if it's set. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1220 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1221 efm = buf->b_p_efm;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 efm = errorformat;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1224
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1225 /*
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1226 * 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
1227 * previously parsed values.
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1228 */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1229 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
1230 {
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1231 /* free the previously parsed data */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1232 vim_free(last_efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1233 last_efm = NULL;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1234 free_efm_list(&fmt_first);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1235
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1236 /* parse the current 'efm' */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1237 fmt_first = parse_efm_option(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1238 if (fmt_first != NULL)
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1239 last_efm = vim_strsave(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1240 }
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1241
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1242 if (fmt_first == NULL) /* nothing found */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 * got_int is reset here, because it was probably set when killing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 * ":make" command, but we still want to read the errorfile then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1251 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1252 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1253 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
1254 state.p_str = tv->vval.v_string;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1255 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
1256 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
1257 state.tv = tv;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1258 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1259 state.buf = buf;
9534
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1260 state.buflnum = lnumfirst;
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1261 state.lnumlast = lnumlast;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1262
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 * Read the lines in the error file one by one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 * Try to recognize one of the error formats in each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1267 while (!got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1269 /* 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
1270 status = qf_get_nextline(&state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1271 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
1272 goto qf_init_end;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1273 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
1274 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275
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
1276 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
1277 fmt_first, &fields);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1278 if (status == QF_FAIL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1279 goto error2;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1280 if (status == QF_NOMEM)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1281 goto qf_init_end;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1282 if (status == QF_IGNORE_LINE)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1283 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1285 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
1286 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
1287 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
1288 (*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
1289 ? 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
1290 : ((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
1291 ? qfl->qf_currfile : (char_u *)NULL),
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1292 0,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1293 fields.errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1294 fields.lnum,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1295 fields.col,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1296 fields.use_viscol,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1297 fields.pattern,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1298 fields.enr,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1299 fields.type,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1300 fields.valid) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1304 if (state.fd == NULL || !ferror(state.fd))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 {
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
1306 if (qfl->qf_index == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1308 /* 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
1309 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
1310 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
1311 qfl->qf_nonevalid = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 {
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
1315 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
1316 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
1317 qfl->qf_ptr = qfl->qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1319 /* 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
1320 retval = qfl->qf_count;
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1321 goto qf_init_end;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 EMSG(_(e_readerrf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 error2:
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1325 if (!adding)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1326 {
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
1327 /* 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
1328 qf_free(qi, qi->qf_curlist);
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1329 qi->qf_listcount--;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1330 if (qi->qf_curlist > 0)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1331 --qi->qf_curlist;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1332 }
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1333 qf_init_end:
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1334 if (state.fd != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1335 fclose(state.fd);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1336 vim_free(fields.namebuf);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1337 vim_free(fields.errmsg);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1338 vim_free(fields.pattern);
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1339 vim_free(state.growbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340
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
1341 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
1342 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
1343 #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
1344 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
1345 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
1346 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1351 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
1352 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
1353 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1354 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
1355 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
1356
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1357 if (title != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1358 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1359 char_u *p = alloc((int)STRLEN(title) + 2);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1360
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1361 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
1362 if (p != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1363 sprintf((char *)p, ":%s", (char *)title);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1364 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1365 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1366
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 /*
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
1368 * 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
1369 * 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
1370 * the new list is added.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1373 qf_new_list(qf_info_T *qi, char_u *qf_title)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 /*
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1378 * If the current entry is not the last entry, delete entries beyond
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 * the current entry. This makes it possible to browse in a tree-like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 * way with ":grep'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1382 while (qi->qf_listcount > qi->qf_curlist + 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1383 qf_free(qi, --qi->qf_listcount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 * When the stack is full, remove to oldest entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 * Otherwise, add a new entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1389 if (qi->qf_listcount == LISTCOUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1391 qf_free(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 for (i = 1; i < LISTCOUNT; ++i)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1393 qi->qf_lists[i - 1] = qi->qf_lists[i];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1394 qi->qf_curlist = LISTCOUNT - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 else
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1397 qi->qf_curlist = qi->qf_listcount++;
3259
9eb7fdfb5e63 updated for version 7.3.398
Bram Moolenaar <bram@vim.org>
parents: 3257
diff changeset
1398 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
1399 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
1400 qi->qf_lists[qi->qf_curlist].qf_id = ++last_qf_id;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1403 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1404 * Free a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1405 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1406 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1407 ll_free_all(qf_info_T **pqi)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1408 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1409 int i;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1410 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1411
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1412 qi = *pqi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1413 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1414 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1415 *pqi = NULL; /* Remove reference to this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1416
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1417 qi->qf_refcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1418 if (qi->qf_refcount < 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1419 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1420 /* No references to this location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1421 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1422 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1423 vim_free(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1424 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1425 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1426
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1427 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1428 qf_free_all(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1429 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1430 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1431 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1432
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1433 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1434 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1435 /* location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1436 ll_free_all(&wp->w_llist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1437 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1438 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1439 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1440 /* quickfix list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1441 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1442 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1443 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1444
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 * Add an entry to the end of the list of errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1450 qf_add_entry(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1451 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
1452 int qf_idx, /* list index */
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1453 char_u *dir, /* optional directory name */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1454 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
1455 int bufnum, /* buffer number or zero */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1456 char_u *mesg, /* message */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1457 long lnum, /* line number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1458 int col, /* column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1459 int vis_col, /* using visual column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1460 char_u *pattern, /* search pattern */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1461 int nr, /* error number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1462 int type, /* type character */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1463 int valid) /* valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1465 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1466 qfline_T **lastp; /* pointer to qf_last or NULL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1468 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 return FAIL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1470 if (bufnum != 0)
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1471 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1472 buf_T *buf = buflist_findnr(bufnum);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1473
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1474 qfp->qf_fnum = bufnum;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1475 if (buf != NULL)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1476 buf->b_has_qf_entry |=
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1477 (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
1478 }
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1479 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
1480 qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 vim_free(qfp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 qfp->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 qfp->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
1488 qfp->qf_viscol = vis_col;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1489 if (pattern == NULL || *pattern == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1490 qfp->qf_pattern = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1491 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1492 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1493 vim_free(qfp->qf_text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1494 vim_free(qfp);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1495 return FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1496 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 qfp->qf_nr = nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 qfp->qf_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 qfp->qf_valid = valid;
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 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
1504 if (qi->qf_lists[qf_idx].qf_count == 0)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1505 /* first element in the list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1507 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
1508 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
1509 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
1510 qfp->qf_prev = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1514 qfp->qf_prev = *lastp;
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1515 (*lastp)->qf_next = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 }
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1517 qfp->qf_next = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 qfp->qf_cleared = FALSE;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1519 *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
1520 ++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
1521 if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1522 /* first valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1524 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
1525 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
1526 qi->qf_lists[qf_idx].qf_ptr = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 /*
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1533 * Allocate a new location list
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1534 */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1535 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1536 ll_new_list(void)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1537 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1538 qf_info_T *qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1539
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1540 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1541 if (qi != NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1542 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1543 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1544 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1545 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1546
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1547 return qi;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1548 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1549
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1550 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1551 * Return the location list for window 'wp'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1552 * If not present, allocate a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1553 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1554 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1555 ll_get_or_alloc_list(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1556 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1557 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1558 /* For a location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1559 return wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1560
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1561 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1562 * 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
1563 * location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1564 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1565 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1566
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1567 if (wp->w_llist == NULL)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1568 wp->w_llist = ll_new_list(); /* new location list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1569 return wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1570 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1571
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1572 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1573 * Copy the location list from window "from" to window "to".
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1574 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1575 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1576 copy_loclist(win_T *from, win_T *to)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1577 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1578 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1579 int idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1580 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1581
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1582 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1583 * When copying from a location list window, copy the referenced
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1584 * location list. For other windows, copy the location list for
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1585 * that window.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1586 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1587 if (IS_LL_WINDOW(from))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1588 qi = from->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1589 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1590 qi = from->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1591
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1592 if (qi == NULL) /* no location list to copy */
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
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1595 /* allocate a new location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1596 if ((to->w_llist = ll_new_list()) == NULL)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1597 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1598
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1599 to->w_llist->qf_listcount = qi->qf_listcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1600
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1601 /* Copy the location lists one at a time */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1602 for (idx = 0; idx < qi->qf_listcount; idx++)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1603 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1604 qf_list_T *from_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1605 qf_list_T *to_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1606
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1607 to->w_llist->qf_curlist = idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1608
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1609 from_qfl = &qi->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1610 to_qfl = &to->w_llist->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1611
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1612 /* Some of the fields are populated by qf_add_entry() */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1613 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1614 to_qfl->qf_count = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1615 to_qfl->qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1616 to_qfl->qf_start = NULL;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1617 to_qfl->qf_last = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1618 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
1619 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
1620 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
1621 else
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1622 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
1623 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
1624 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1625 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
1626 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
1627 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
1628 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1629 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1630 to_qfl->qf_ctx = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1631
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1632 if (from_qfl->qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1633 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1634 qfline_T *from_qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1635 qfline_T *prevp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1636
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1637 /* 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
1638 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
1639 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
1640 ++i, from_qfp = from_qfp->qf_next)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1641 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1642 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
1643 to->w_llist->qf_curlist,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1644 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1645 NULL,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1646 0,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1647 from_qfp->qf_text,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1648 from_qfp->qf_lnum,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1649 from_qfp->qf_col,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1650 from_qfp->qf_viscol,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1651 from_qfp->qf_pattern,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1652 from_qfp->qf_nr,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1653 0,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1654 from_qfp->qf_valid) == FAIL)
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_free_all(to);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1657 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1658 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1659 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1660 * qf_add_entry() will not set the qf_num field, as the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1661 * directory and file names are not supplied. So the qf_fnum
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1662 * field is copied here.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1663 */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1664 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
1665 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1666 prevp->qf_type = from_qfp->qf_type; /* error type */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1667 if (from_qfl->qf_ptr == from_qfp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1668 to_qfl->qf_ptr = prevp; /* current location */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1669 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1670 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1671
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1672 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1673
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
1674 /* 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
1675 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
1676 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
1677
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1678 /* When no valid entries are present in the list, qf_ptr points to
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1679 * the first item in the list */
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
1680 if (to_qfl->qf_nonevalid)
5060
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1681 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1682 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
1683 to_qfl->qf_index = 1;
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1684 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1685 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1686
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1687 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1688 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1689
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1690 /*
10379
73e2a7abe2a3 commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents: 10369
diff changeset
1691 * 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
1692 * Also sets the b_has_qf_entry flag.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 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
1695 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
1696 {
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1697 char_u *ptr = NULL;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1698 buf_T *buf;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1699 char_u *bufname;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1700
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 if (fname == NULL || *fname == NUL) /* no file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1704 #ifdef VMS
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1705 vms_remove_version(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1706 #endif
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1707 #ifdef BACKSLASH_IN_FILENAME
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1708 if (directory != NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1709 slash_adjust(directory);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1710 slash_adjust(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1711 #endif
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1712 if (directory != NULL && !vim_isAbsName(fname)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1713 && (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
1714 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1715 /*
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1716 * 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
1717 * 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
1718 * "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
1719 * directory change.
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1720 */
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1721 if (mch_getperm(ptr) < 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 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
1724 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
1725 if (directory)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1726 ptr = concat_fnames(directory, fname, TRUE);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1727 else
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1728 ptr = vim_strsave(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1730 /* 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
1731 bufname = ptr;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1732 }
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1733 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1734 bufname = fname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1735
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1736 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
1737 && bufref_valid(&qf_last_bufref))
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1738 {
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1739 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
1740 vim_free(ptr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1742 else
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1743 {
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1744 vim_free(qf_last_bufname);
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1745 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
1746 if (bufname == ptr)
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1747 qf_last_bufname = bufname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1748 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1749 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
1750 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
1751 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1752 if (buf == NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1753 return 0;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1754
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1755 buf->b_has_qf_entry =
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1756 (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
1757 return buf->b_fnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 /*
9334
674f9e3ccd1a commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents: 9201
diff changeset
1761 * 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
1762 * NULL on error.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 static char_u *
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1765 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
1766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 struct dir_stack_T *ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 /* allocate new stack element and hook it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 ds_new->next = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 *stackptr = ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 /* store directory on the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 if (vim_isAbsName(dirbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 || (*stackptr)->next == NULL
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1781 || (*stackptr && is_file_stack))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 /* Okay we don't have an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 * dirbuf must be a subdir of one of the directories on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 * Let's search...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 ds_new = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 (*stackptr)->dirname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 while (ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 if (mch_isdir((*stackptr)->dirname) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 ds_new = ds_new->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 while ((*stackptr)->next != ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 ds_ptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 (*stackptr)->next = (*stackptr)->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 /* Nothing found -> it must be on top level */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 if ((*stackptr)->dirname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 return (*stackptr)->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 * pop dirbuf from the directory stack and return previous directory or NULL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 * stack is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1836 qf_pop_dir(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 /* TODO: Should we check if dirbuf is the directory on top of the stack?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 * What to do if it isn't? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 /* pop top element and free it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 if (*stackptr != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 vim_free(ds_ptr);
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 /* return NEW top element as current dir or NULL if stack is empty*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 return *stackptr ? (*stackptr)->dirname : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 * clean up directory stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1860 qf_clean_dir_stack(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 while ((ds_ptr = *stackptr) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 * Check in which directory of the directory stack the given file can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 * found.
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
1875 * Returns a pointer to the directory name or NULL if not found.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 * Cleans up intermediate directory entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 * TODO: How to solve the following problem?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 * If we have the this directory tree:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 * ./
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 * ./aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 * ./aa/bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 * ./bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 * ./bb/x.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 * and make says:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 * making all in aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 * making all in bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 * x.c:9: Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 * 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
1890 * qf_guess_filepath will return NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 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
1893 qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *filename)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 struct dir_stack_T *ds_tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 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
1898 qf_list_T *qfl = &qi->qf_lists[qf_idx];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 /* 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
1901 if (qfl->qf_dir_stack == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903
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
1904 ds_ptr = qfl->qf_dir_stack->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 fullname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 while (ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 /* If concat_fnames failed, just go on. The worst thing that can happen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 * is that we delete the entire stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 if ((fullname != NULL) && (mch_getperm(fullname) >= 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 ds_ptr = ds_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 /* 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
1923 while (qfl->qf_dir_stack->next != ds_ptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 {
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
1925 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
1926 qfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 vim_free(ds_tmp->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 vim_free(ds_tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 return ds_ptr==NULL? NULL: ds_ptr->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 /*
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1935 * Returns TRUE if a quickfix/location list with the given identifier exists.
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1936 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1937 static int
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1938 qflist_valid (win_T *wp, int_u qf_id)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1939 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1940 qf_info_T *qi = &ql_info;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1941 int i;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1942
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1943 if (wp != NULL)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1944 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1945 qi = GET_LOC_LIST(wp); /* Location list */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1946 if (qi == NULL)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1947 return FALSE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1948 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1949
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1950 for (i = 0; i < qi->qf_listcount; ++i)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1951 if (qi->qf_lists[i].qf_id == qf_id)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1952 return TRUE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1953
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1954 return FALSE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1955 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1956
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
1957 /*
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1958 * 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
1959 * 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
1960 * 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
1961 * Similar to location list.
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1962 */
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1963 static int
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1964 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
1965 {
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1966 qf_list_T *qfl;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1967 qfline_T *qfp;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1968 int i;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1969
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1970 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
1971
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1972 /* 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
1973 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
1974 ++i, qfp = qfp->qf_next)
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1975 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
1976 break;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1977
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1978 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
1979 return FALSE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1980
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1981 return TRUE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1982 }
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1983
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1984 /*
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1985 * 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
1986 * 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
1987 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1988 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1989 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
1990 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
1991 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
1992 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1993 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1994 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1995 int idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1996 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
1997
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1998 idx = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
1999 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
2000
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2001 do
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 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
2004 || 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
2005 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2006 ++idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2007 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
2008 } 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
2009 && !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
2010 || (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
2011
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2012 *qf_index = idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2013 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2014 }
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 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2017 * 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
2018 * 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
2019 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2020 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2021 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
2022 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
2023 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
2024 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2025 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2026 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2027 int idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2028 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
2029
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2030 idx = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2031 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
2032
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2033 do
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2034 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2035 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
2036 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2037 --idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2038 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
2039 } 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
2040 && !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
2041 || (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
2042
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2043 *qf_index = idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2044 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2045 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2046
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2047 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2048 * 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
2049 * the quickfix list.
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2050 * 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
2051 * 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
2052 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2053 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2054 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
2055 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
2056 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2057 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
2058 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2059 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2060 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2061 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
2062 int prev_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2063 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
2064 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
2065
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2066 while (errornr--)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2067 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2068 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
2069 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
2070
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2071 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
2072 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
2073 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2074 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
2075 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
2076 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2077 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
2078 *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
2079 if (err != 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 EMSG(_(err));
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2082 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2083 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2084 break;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2085 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2086
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2087 err = 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
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2090 return qf_ptr;
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
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2093 /*
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2094 * 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
2095 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2096 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2097 get_nth_entry(
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2098 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
2099 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2100 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
2101 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
2102 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2103 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
2104
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2105 /* 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
2106 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
2107 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2108 --qf_idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2109 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
2110 }
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2111 /* 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
2112 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
2113 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
2114 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
2115 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2116 ++qf_idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2117 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
2118 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2119
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2120 *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
2121 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2122 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2123
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2124 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2125 * 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
2126 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2127 static int
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2128 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
2129 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2130 win_T *wp;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2131 int flags;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2132
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2133 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
2134 wp = NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2135 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2136 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
2137 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
2138 break;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2139 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
2140 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
2141 else
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 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2144 * 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
2145 * 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
2146 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2147 flags = WSP_HELP;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2148 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
2149 && 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
2150 flags |= WSP_TOP;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2151 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
2152 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
2153
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2154 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
2155 return FAIL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2156
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2157 *opened_window = TRUE;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2158
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2159 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
2160 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
2161
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2162 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
2163 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2164 /* 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
2165 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
2166 qi->qf_refcount++;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2167 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2168 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2169
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2170 if (!p_im)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2171 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
2172
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2173 return OK;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2174 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2175
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2176 /*
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2177 * 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
2178 * 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
2179 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2180 static int
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2181 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
2182 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2183 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
2184 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
2185 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
2186 int flags;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2187 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
2188 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
2189
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2190 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
2191
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2192 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
2193 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
2194 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2195 /* 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
2196 * quickfix window. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2197 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
2198 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
2199 && !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
2200 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2201 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
2202 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2203 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2204 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2205
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2206 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
2207 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2208 /* 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
2209 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
2210 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
2211 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2212 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
2213 break;
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 }
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 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2218 * 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
2219 * 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
2220 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2221 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
2222 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2223 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
2224 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
2225
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2226 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
2227 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2228 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
2229 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2230 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
2231 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
2232 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
2233 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2234 }
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 win_found:
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 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2239 * 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
2240 * 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
2241 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2242 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
2243 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2244 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
2245 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
2246 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
2247 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
2248 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
2249 *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
2250 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
2251 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
2252 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
2253 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
2254 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2255 /* 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
2256 * 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
2257 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
2258 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
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 else
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 (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
2264 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2265 /* 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
2266 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
2267 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
2268 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2269 /* 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
2270 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
2271 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
2272 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2273 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
2274 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2275 /* 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
2276 win = curwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2277 do
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2278 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2279 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
2280 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2281 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
2282 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
2283 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2284 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
2285 } 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
2286 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2287 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2288 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
2289
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2290 /* 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
2291 * 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
2292 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
2293 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2294 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
2295 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
2296 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2297 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2298 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2299 {
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 * 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
2303 * 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
2304 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2305 win = curwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2306 altwin = NULL;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2307 for (;;)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2308 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2309 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
2310 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2311 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
2312 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
2313 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2314 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
2315
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2316 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
2317 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2318 /* 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
2319 * window. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2320 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
2321 win = altwin;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2322 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
2323 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
2324 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2325 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
2326 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2327 }
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 /* 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
2330 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
2331 && 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
2332 altwin = win;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2333 }
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 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
2336 }
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
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2339 return OK;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2340 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2341
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 * 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
2344 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2345 static int
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2346 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
2347 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
2348 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
2349 int forceit,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2350 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
2351 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
2352 int *abort)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2353 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2354 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
2355
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2356 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
2357 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2358 /* 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
2359 * 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
2360 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
2361 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2362 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
2363 retval = FALSE;
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 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2366 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
2367 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
2368 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
2369 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2370 else
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 int old_qf_curlist = qi->qf_curlist;
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2373 int save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2374
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2375 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
2376 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2377
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2378 if (qi != &ql_info)
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2379 {
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2380 /*
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2381 * Location list. Check whether the associated window is still
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2382 * present and the list is still valid.
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2383 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2384 if (!win_valid_any_tab(oldwin))
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2385 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2386 EMSG(_("E924: Current window was closed"));
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2387 *abort = TRUE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2388 *opened_window = FALSE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2389 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2390 else if (!qflist_valid(oldwin, save_qfid))
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2391 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2392 EMSG(_(e_loc_list_changed));
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2393 *abort = TRUE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2394 }
12503
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 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
2397 || !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
2398 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2399 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
2400 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
2401 else
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2402 EMSG(_(e_loc_list_changed));
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2403 *abort = TRUE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2404 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2405
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2406 if (*abort)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2407 retval = FALSE;
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
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2410 return retval;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2411 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2412
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 * 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
2415 * search pattern.
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2416 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2417 static void
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2418 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
2419 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
2420 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
2421 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
2422 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
2423 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2424 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
2425 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
2426 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
2427 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
2428
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2429 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
2430 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2431 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2432 * 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
2433 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2434 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
2435 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
2436 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2437 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
2438 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
2439 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
2440 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2441 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
2442 {
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.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
2444 #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
2445 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
2446 #endif
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2447 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
2448 {
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 * 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
2451 * 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
2452 * 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
2453 * 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
2454 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2455 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
2456 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
2457 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
2458 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2459 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
2460 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2461 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
2462 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2463 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
2464 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
2465 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2466 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2467 ++screen_col;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2468 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2469 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2470 check_cursor();
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2471 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2472 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2473 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
2474 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2475 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2476 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2477 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
2478
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2479 /* 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
2480 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
2481 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
2482 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
2483 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
2484 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
2485 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2486 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2487
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2488 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2489 * 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
2490 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2491 static void
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2492 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
2493 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
2494 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
2495 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
2496 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
2497 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
2498 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2499 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
2500 int len;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2501
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2502 /* 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
2503 * scrolled up. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2504 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
2505 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
2506 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
2507 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
2508 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
2509 (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
2510 /* 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
2511 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
2512 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
2513
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2514 /* 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
2515 * 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
2516 * whole message. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2517 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
2518 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
2519 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
2520 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
2521 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
2522 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
2523 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
2524 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2525
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2526 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 * jump to a quickfix line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 * if dir == FORWARD go "errornr" valid entries forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 * if dir == BACKWARD go "errornr" valid entries backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 * if dir == FORWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 * else if "errornr" is zero, redisplay the same line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 * else go to entry "errornr"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 void
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2536 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
2537 int dir,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2538 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2539 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2541 qfline_T *qf_ptr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2542 qfline_T *old_qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 int qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 int old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 buf_T *old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 linenr_T old_lnum;
639
c79d4df4686e updated for version 7.0185
vimboss
parents: 634
diff changeset
2547 char_u *old_swb = p_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2548 unsigned old_swb_flags = swb_flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 int opened_window = FALSE;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2550 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 int print_message = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 int old_KeyTyped = KeyTyped; /* getting file may reset it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 #endif
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2555 int retval = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2556
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2557 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2558 qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2559
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2560 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2561 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2567 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 old_qf_ptr = qf_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2569 qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 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
2571 if (dir != 0) /* next/prev valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572 {
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2573 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
2574 if (qf_ptr == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 {
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2576 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
2577 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
2578 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 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
2582 qf_ptr = get_nth_entry(qi, errornr, qf_ptr, &qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2584 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2585 if (qf_win_pos_update(qi, old_qf_index))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 /* No need to print the error message if it's visible in the error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 * window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 print_message = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 /*
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2591 * For ":helpgrep" find a help window or open one.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2592 */
11800
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
2593 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
2594 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
2595 goto theend;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2596
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2597 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 * If currently in the quickfix window, find another window to show the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 * file in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
2601 if (bt_quickfix(curbuf) && !opened_window)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 * If there is no file specified, we don't know where to go.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 * But do advance, otherwise ":cn" gets stuck.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 if (qf_ptr->qf_fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2610 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
2611 goto failed;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 * If there is a file name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 * read the wanted file if needed, and check autowrite etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 old_lnum = curwin->w_cursor.lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2620
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2621 if (qf_ptr->qf_fnum != 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2622 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2623 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
2624
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2625 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
2626 &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
2627 if (abort)
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2628 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2629 qi = NULL;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2630 qf_ptr = NULL;
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2631 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2632 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2633
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2634 if (retval == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 /* When not switched to another buffer, still need to set pc mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637 if (curbuf == old_curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2640 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
2641 qf_ptr->qf_pattern);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 foldOpenCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 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
2648 qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 if (opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 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
2654 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 * Couldn't open file, so put index back where it was. This could
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 * happen if the file was readonly and we changed something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 failed:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 qf_index = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 theend:
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2666 if (qi != NULL)
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2667 {
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2668 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
2669 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
2670 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 if (p_swb != old_swb && opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 /* Restore old 'switchbuf' value, but not when an autocommand or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 * modeline has changed the value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 if (p_swb == empty_option)
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2676 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 p_swb = old_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2678 swb_flags = old_swb_flags;
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2679 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 free_string_option(old_swb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 * ":clist": list all errors
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2687 * ":llist": list all locations
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2690 qf_list(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2692 buf_T *buf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2693 char_u *fname;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2694 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2695 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2696 int idx1 = 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2697 int idx2 = -1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2698 char_u *arg = eap->arg;
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2699 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
2700 int qfFileAttr;
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2701 int qfSepAttr;
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2702 int qfLineAttr;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2703 int all = eap->forceit; /* if not :cl!, only show
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 recognised errors */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2705 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2706
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2707 if (eap->cmdidx == CMD_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2708 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2709 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2710 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2711 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2712 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2713 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2714 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2715 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2716
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2717 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2718 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2723 if (*arg == '+')
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2724 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2725 ++arg;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2726 plus = TRUE;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2727 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2733 if (plus)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2734 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2735 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
2736 idx2 = i + idx1;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2737 idx1 = i;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2738 }
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2739 else
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2740 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2741 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
2742 if (idx1 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2743 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
2744 if (idx2 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2745 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
2746 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2748 /*
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2749 * 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
2750 * 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
2751 */
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2752 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
2753 if (qfFileAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2754 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
2755 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
2756 if (qfSepAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2757 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
2758 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
2759 if (qfLineAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2760 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
2761
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2762 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 all = TRUE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2764 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2765 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
2766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 {
2047
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2769 msg_putchar('\n');
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2770 if (got_int)
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2771 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2772
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2773 fname = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2774 if (qfp->qf_fnum != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2776 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2777 fname = buf->b_fname;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2778 if (qfp->qf_type == 1) /* :helpgrep */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2779 fname = gettail(fname);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2780 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2781 if (fname == NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2782 sprintf((char *)IObuff, "%2d", i);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2783 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2784 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 236
diff changeset
2785 i, (char *)fname);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2786 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
2787 ? 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
2788
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2789 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
2790 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2791 if (qfp->qf_lnum == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2792 IObuff[0] = NUL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2793 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
2794 sprintf((char *)IObuff, "%ld", qfp->qf_lnum);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2795 else
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2796 sprintf((char *)IObuff, "%ld col %d",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 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
2798 sprintf((char *)IObuff + STRLEN(IObuff), "%s",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 (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
2800 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
2801 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2802 if (qfp->qf_pattern != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2803 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2804 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2805 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
2806 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2807 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2808 msg_puts((char_u *)" ");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2809
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2810 /* Remove newlines and leading whitespace from the text. For an
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2811 * unrecognized line keep the indent, the compiler may mark a word
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2812 * with ^^^^. */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2813 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815 IObuff, IOSIZE);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2816 msg_prt_line(IObuff, FALSE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2817 out_flush(); /* show one line at a time */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2819
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2820 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2821 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2822 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2823 ++i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 * Remove newlines and leading whitespace from an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 * Put the result in "buf[bufsize]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2833 qf_fmt_text(char_u *text, char_u *buf, int bufsize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 char_u *p = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 for (i = 0; *p != NUL && i < bufsize - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 buf[i] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 while (*++p != NUL)
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11063
diff changeset
2844 if (!VIM_ISWHITE(*p) && *p != '\n')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 buf[i] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 buf[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2853 static void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2854 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
2855 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2856 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
2857 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
2858 char_u buf[IOSIZE];
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2859
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2860 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
2861 lead,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2862 which + 1,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2863 qi->qf_listcount,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2864 count);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2865
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2866 if (title != NULL)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2867 {
9579
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2868 size_t len = STRLEN(buf);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2869
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2870 if (len < 34)
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2871 {
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2872 vim_memset(buf + len, ' ', 34 - len);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2873 buf[34] = NUL;
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2874 }
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2875 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
2876 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2877 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
2878 msg(buf);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2879 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2880
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 * ":colder [count]": Up in the quickfix stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 * ":cnewer [count]": Down in the quickfix stack.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2884 * ":lolder [count]": Up in the location list stack.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2885 * ":lnewer [count]": Down in the location list stack.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2888 qf_age(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2890 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2893 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2894 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2895 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2896 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2897 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2898 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2899 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2900 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2901 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2902
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 while (count--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2909 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2911 if (qi->qf_curlist == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 EMSG(_("E380: At bottom of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2914 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2916 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2919 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2920 if (qi->qf_curlist >= qi->qf_listcount - 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 EMSG(_("E381: At top of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2923 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2925 ++qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 }
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2928 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
2929 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2932 void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2933 qf_history(exarg_T *eap)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2934 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2935 qf_info_T *qi = &ql_info;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2936 int i;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2937
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2938 if (eap->cmdidx == CMD_lhistory)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2939 qi = GET_LOC_LIST(curwin);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2940 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
2941 && 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
2942 MSG(_("No entries"));
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2943 else
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2944 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
2945 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
2946 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2947
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 /*
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2949 * 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
2950 * associated with the list like context and title are not freed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 static void
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2953 qf_free_items(qf_info_T *qi, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2955 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2956 qfline_T *qfpnext;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2957 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
2958 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
2959
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
2960 while (qfl->qf_count && qfl->qf_start != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 {
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
2962 qfp = qfl->qf_start;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2963 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
2964 if (!stop)
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2965 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2966 vim_free(qfp->qf_text);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2967 stop = (qfp == qfpnext);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2968 vim_free(qfp->qf_pattern);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2969 vim_free(qfp);
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2970 if (stop)
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2971 /* 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
2972 * to avoid crashing when it's wrong.
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2973 * 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
2974 qfl->qf_count = 1;
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2975 }
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
2976 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
2977 --qfl->qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2979
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
2980 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
2981 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
2982 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
2983 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
2984 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
2985
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
2986 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
2987 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
2988 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
2989 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
2990 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
2991 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
2992 qfl->qf_multiscan = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995 /*
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2996 * 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
2997 * 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
2998 */
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2999 static void
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3000 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
3001 {
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
3002 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
3003
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3004 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
3005
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
3006 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
3007 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
3008 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
3009 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
3010 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
3011 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
3012 }
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3013
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3014 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 * qf_mark_adjust: adjust marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3018 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
3019 win_T *wp,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3020 linenr_T line1,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3021 linenr_T line2,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3022 long amount,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3023 long amount_after)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3025 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3026 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3027 int idx;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3028 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
3029 int found_one = FALSE;
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3030 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
3031
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3032 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
3033 return;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3034 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3035 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3036 if (wp->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3037 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3038 qi = wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3039 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3040
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3041 for (idx = 0; idx < qi->qf_listcount; ++idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3042 if (qi->qf_lists[idx].qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3043 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
3044 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
3045 ++i, qfp = qfp->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046 if (qfp->qf_fnum == curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 {
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3048 found_one = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3049 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 if (amount == MAXLNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3052 qfp->qf_cleared = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3053 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3054 qfp->qf_lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3055 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056 else if (amount_after && qfp->qf_lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3057 qfp->qf_lnum += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3058 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3059
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3060 if (!found_one)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3061 curbuf->b_has_qf_entry &= ~buf_has_flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3064 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3065 * Make a nice message out of the error character and the error number:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3066 * char number message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3067 * e or E 0 " error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3068 * w or W 0 " warning"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3069 * i or I 0 " info"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3070 * 0 0 ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3071 * other 0 " c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072 * e or E n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 * w or W n " warning n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 * i or I n " info n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3075 * 0 n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 * other n " c n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 * 1 x "" :helpgrep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3080 qf_types(int c, int nr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3081 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3082 static char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 static char_u cc[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086 if (c == 'W' || c == 'w')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3087 p = (char_u *)" warning";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3088 else if (c == 'I' || c == 'i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089 p = (char_u *)" info";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3090 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3091 p = (char_u *)" error";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3092 else if (c == 0 || c == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 p = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 cc[0] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 cc[1] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 cc[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 p = cc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3102 if (nr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105 sprintf((char *)buf, "%s %3d", (char *)p, nr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 * ":cwindow": open the quickfix window if we have errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 * close it if not.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3112 * ":lwindow": open the location list window if we have locations to display,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3113 * close it if not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3115 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3116 ex_cwindow(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3117 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3118 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3121 if (eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3122 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3123 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3124 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3125 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3126 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3127
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3128 /* Look for an existing quickfix window. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3129 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3131 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 * If a quickfix window is open but we have no errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 * close the window. If a quickfix window is not open, then open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3134 * it if we have errors; otherwise, leave it closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3136 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
3137 || qi->qf_lists[qi->qf_curlist].qf_count == 0
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3138 || qi->qf_curlist >= qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3140 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 ex_cclose(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143 else if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144 ex_copen(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3147 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3148 * ":cclose": close the window showing the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3149 * ":lclose": close the window showing the location list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3150 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3151 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3152 ex_cclose(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3154 win_T *win = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3155 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3156
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3157 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3158 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3159 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3160 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3161 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3162 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3163
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3164 /* Find existing quickfix window and close it. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3165 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3166 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3167 win_close(win, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3168 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3171 * ":copen": open a window that shows the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3172 * ":lopen": open a window that shows the location list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3173 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3174 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3175 ex_copen(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3176 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3177 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3178 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3179 win_T *win;
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3180 tabpage_T *prevtab = curtab;
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3181 buf_T *qf_buf;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3182 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3184 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3185 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3186 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3187 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3188 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3189 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3190 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3191 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3192 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3193
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3194 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195 height = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3196 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3197 height = QF_WINHEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3199 reset_VIsual_and_resel(); /* stop Visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3200 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3201 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3202 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3204 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3205 * Find existing quickfix window, or open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3206 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3207 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3208
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3209 if (win != NULL && cmdmod.tab == 0)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3210 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3211 win_goto(win);
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3212 if (eap->addr_count != 0)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3213 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3214 if (cmdmod.split & WSP_VERT)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3215 {
12515
972ea22c946f patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12503
diff changeset
3216 if (height != win->w_width)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3217 win_setwidth(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3218 }
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3219 else if (height != win->w_height)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3220 win_setheight(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3221 }
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3222 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3223 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3224 {
13105
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3225 int flags = 0;
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3226
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3227 qf_buf = qf_find_buf(qi);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3228
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3229 /* The current window becomes the previous window afterwards. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3230 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3231
3939
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3232 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
3233 && cmdmod.split == 0)
13105
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3234 /* Create the new quickfix window at the very bottom, except when
3939
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3235 * :belowright or :aboveleft is used. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3236 win_goto(lastwin);
13105
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3237 /* Default is to open the window below the current window */
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3238 if (cmdmod.split == 0)
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3239 flags = WSP_BELOW;
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3240 flags |= WSP_NEWLOC;
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3241 if (win_split(height, flags) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 return; /* not enough room for window */
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
3243 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3245 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3246 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3247 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3248 * For the location list window, create a reference to the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3249 * location list from the window 'win'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3250 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3251 curwin->w_llist_ref = win->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3252 win->w_llist->qf_refcount++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3253 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3254
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3255 if (oldwin != curwin)
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3256 oldwin = NULL; /* don't store info when in another window */
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3257 if (qf_buf != NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3258 /* Use the existing quickfix buffer */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3259 (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
3260 ECMD_HIDE + ECMD_OLDBUF, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3261 else
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3262 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3263 /* Create a new quickfix buffer */
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3264 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3265 /* switch off 'swapfile' */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3266 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3267 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
729
3d0ca316efab updated for version 7.0221
vimboss
parents: 717
diff changeset
3268 OPT_LOCAL);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3269 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
3270 RESET_BINDING(curwin);
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3271 #ifdef FEAT_DIFF
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3272 curwin->w_p_diff = FALSE;
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3273 #endif
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3274 #ifdef FEAT_FOLDING
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3275 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3276 OPT_LOCAL);
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3277 #endif
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3278 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3279
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3280 /* 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
3281 * window to the side. */
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3282 if (curtab == prevtab && curwin->w_width == Columns)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283 win_setheight(height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3284 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3285 if (win_valid(win))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3286 prevwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3287 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3288
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3289 qf_set_title_var(qi);
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3290
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3291 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3292 * Fill the buffer with the quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3293 */
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3294 qf_fill_buffer(qi, curbuf, NULL);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3295
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3296 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3298 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3299 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3300 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3302 /*
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3303 * 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
3304 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3305 static void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3306 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
3307 {
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3308 win_T *old_curwin = curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3309
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3310 curwin = win;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3311 curbuf = win->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3312 curwin->w_cursor.lnum = lnum;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3313 curwin->w_cursor.col = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3314 #ifdef FEAT_VIRTUALEDIT
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3315 curwin->w_cursor.coladd = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3316 #endif
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3317 curwin->w_curswant = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3318 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
3319 redraw_later(VALID);
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3320 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
3321 curwin = old_curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3322 curbuf = curwin->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3323 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3324
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3325 /*
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3326 * :cbottom/:lbottom commands.
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3327 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3328 void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3329 ex_cbottom(exarg_T *eap UNUSED)
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3330 {
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3331 qf_info_T *qi = &ql_info;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3332 win_T *win;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3333
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3334 if (eap->cmdidx == CMD_lbottom)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3335 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3336 qi = GET_LOC_LIST(curwin);
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3337 if (qi == NULL)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3338 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3339 EMSG(_(e_loclist));
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3340 return;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3341 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3342 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3343
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3344 win = qf_find_win(qi);
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3345 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
3346 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
3347 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3348
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3349 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 * Return the number of the current entry (line number in the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 * window).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 linenr_T
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3354 qf_current_entry(win_T *wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3355 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3356 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3357
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3358 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3359 /* In the location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3360 qi = wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3361
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3362 return qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3363 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366 * Update the cursor position in the quickfix window to the current error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3367 * Return TRUE if there is a quickfix window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3368 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3369 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3370 qf_win_pos_update(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3371 qf_info_T *qi,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3372 int old_qf_index) /* previous qf_index or zero */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3374 win_T *win;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3375 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3377 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3378 * Put the cursor on the current error in the quickfix window, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3379 * it's viewable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3380 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3381 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3382 if (win != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383 && qf_index <= win->w_buffer->b_ml.ml_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3384 && old_qf_index != qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3386 if (qf_index > old_qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3387 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3388 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
3389 win->w_redraw_bot = qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3390 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3391 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3392 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3393 win->w_redraw_top = qf_index;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3394 win->w_redraw_bot = old_qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3395 }
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3396 qf_win_goto(win, qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3398 return win != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3399 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3401 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3402 * Check whether the given window is displaying the specified quickfix/location
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3403 * list 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 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3406 is_qf_win(win_T *win, qf_info_T *qi)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3407 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3408 /*
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3409 * A window displaying the quickfix buffer will have the w_llist_ref field
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3410 * set to NULL.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3411 * A window displaying a location list buffer will have the w_llist_ref
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3412 * pointing to the location list.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3413 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3414 if (bt_quickfix(win->w_buffer))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3415 if ((qi == &ql_info && win->w_llist_ref == NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3416 || (qi != &ql_info && win->w_llist_ref == qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3417 return TRUE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3418
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3419 return FALSE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3420 }
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3421
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3422 /*
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3423 * Find a window displaying the quickfix/location list 'qi'
13115
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
3424 * Only searches in the current tabpage.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3425 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3426 static win_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3427 qf_find_win(qf_info_T *qi)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3428 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3429 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3430
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3431 FOR_ALL_WINDOWS(win)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3432 if (is_qf_win(win, qi))
13115
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
3433 return win;
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
3434 return NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3435 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3436
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3437 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3438 * Find a quickfix buffer.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3439 * Searches in windows opened in all the tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3440 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3441 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3442 qf_find_buf(qf_info_T *qi)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3443 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3444 tabpage_T *tp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3445 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3446
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3447 FOR_ALL_TAB_WINDOWS(tp, win)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3448 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3449 return win->w_buffer;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3450
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3451 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3454 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3455 * 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
3456 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3457 static void
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3458 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
3459 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3460 win_T *win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3461 win_T *curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3462
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3463 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
3464 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3465 curwin_save = curwin;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3466 curwin = win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3467 qf_set_title_var(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3468 curwin = curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3469 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3470 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3471
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3472 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3473 * Find the quickfix buffer. If it exists, update the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3474 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3475 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3476 qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3477 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3478 buf_T *buf;
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3479 win_T *win;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3480 aco_save_T aco;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3482 /* Check if a buffer for the quickfix list exists. Update it. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3483 buf = qf_find_buf(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3484 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3485 {
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3486 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
3487
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3488 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3489 /* 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
3490 aucmd_prepbuf(&aco, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3491
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3492 qf_update_win_titlevar(qi);
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3493
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3494 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
3495 ++CHANGEDTICK(buf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3496
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3497 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3498 {
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
3499 (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
3500
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3501 /* 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
3502 aucmd_restbuf(&aco);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3503 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3504
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3505 /* 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
3506 * 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
3507 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
3508 redraw_buf_later(buf, NOT_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3510 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3511
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3512 /*
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3513 * Set "w:quickfix_title" if "qi" has a title.
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3514 */
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3515 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3516 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
3517 {
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3518 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL)
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3519 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
3520 qi->qf_lists[qi->qf_curlist].qf_title);
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3521 }
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3522
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3524 * Fill current buffer with quickfix errors, replacing any previous contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3525 * 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
3526 * 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
3527 * 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
3528 * ml_delete() is used and autocommands will be triggered.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3529 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3531 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
3532 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3533 linenr_T lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3534 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3535 buf_T *errbuf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3536 int len;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3537 int old_KeyTyped = KeyTyped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3539 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3540 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3541 if (buf != curbuf)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3542 {
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
3543 internal_error("qf_fill_buffer()");
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3544 return;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3545 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3546
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3547 /* delete all existing lines */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3548 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
3549 (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
3550 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 /* Check if there is anything to display */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3553 if (qi->qf_curlist < qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3555 /* 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
3556 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3557 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3558 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
3559 lnum = 0;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3560 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3561 else
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3562 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3563 qfp = old_last->qf_next;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3564 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
3565 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3566 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3568 if (qfp->qf_fnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3569 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3570 && errbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3571 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3572 if (qfp->qf_type == 1) /* :helpgrep */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3573 STRCPY(IObuff, gettail(errbuf->b_fname));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3574 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3575 STRCPY(IObuff, errbuf->b_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3576 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3577 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3578 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3579 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3580 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3582 if (qfp->qf_lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3583 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3584 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3585 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3586
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3587 if (qfp->qf_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3588 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3589 sprintf((char *)IObuff + len, " col %d", qfp->qf_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3590 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3593 sprintf((char *)IObuff + len, "%s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3594 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3595 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3596 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3597 else if (qfp->qf_pattern != NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3598 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3599 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3600 len += (int)STRLEN(IObuff + len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3601 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3602 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3603 IObuff[len++] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3605 /* Remove newlines and leading whitespace from the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3606 * For an unrecognized line keep the indent, the compiler may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3607 * mark a word with ^^^^. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3609 IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3610
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3611 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
3612 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3613 break;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3614 ++lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3615 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3616 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3617 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3618 }
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3619
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3620 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3621 /* 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
3622 (void)ml_delete(lnum + 1, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3625 /* correct cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3626 check_lnums(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3627
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3628 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3629 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3630 /* 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
3631 * 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
3632 * using autocommands. */
11589
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3633 #ifdef FEAT_AUTOCMD
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3634 ++curbuf_lock;
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3635 #endif
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3636 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
3637 curbuf->b_p_ma = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 #ifdef FEAT_AUTOCMD
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3640 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
3641 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3643 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3644 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3645 keep_filetype = FALSE;
11589
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3646 --curbuf_lock;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 #endif
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3648 /* make sure it will be redrawn */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3649 redraw_curbuf_later(NOT_VALID);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3650 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3651
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3652 /* Restore KeyTyped, setting 'filetype' may reset it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3653 KeyTyped = old_KeyTyped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3655
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3656 static void
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3657 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
3658 {
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3659 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
3660 }
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3661
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3662 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3663 * Return TRUE when using ":vimgrep" for ":grep".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3664 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3665 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3666 grep_internal(cmdidx_T cmdidx)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3667 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3668 return ((cmdidx == CMD_grep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3669 || cmdidx == CMD_lgrep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3670 || cmdidx == CMD_grepadd
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3671 || cmdidx == CMD_lgrepadd)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3672 && STRCMP("internal",
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3673 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3674 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3675
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3676 /*
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3677 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3678 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3679 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3680 ex_make(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3681 {
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3682 char_u *fname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3683 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
3684 char_u *enc = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3685 unsigned len;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3686 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3687 qf_info_T *qi = &ql_info;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3688 int res;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3689 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3690 char_u *au_name = NULL;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3691
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3692 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3693 if (grep_internal(eap->cmdidx))
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3694 {
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3695 ex_vimgrep(eap);
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3696 return;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3697 }
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3698
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3699 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3700 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3701 case CMD_make: au_name = (char_u *)"make"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3702 case CMD_lmake: au_name = (char_u *)"lmake"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3703 case CMD_grep: au_name = (char_u *)"grep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3704 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3705 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3706 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3707 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3708 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3709 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
3710 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3711 {
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3712 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3713 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3714 return;
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3715 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3716 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3717 #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
3718 #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
3719 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
3720 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3721
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3722 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3723 || eap->cmdidx == CMD_lgrepadd)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3724 wp = curwin;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3725
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3726 autowrite_all();
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3727 fname = get_mef_name();
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3728 if (fname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3729 return;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3730 mch_remove(fname); /* in case it's not unique */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3732 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3733 * If 'shellpipe' empty: don't redirect to 'errorfile'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3734 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3736 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3737 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3738 cmd = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3739 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3741 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3742 (char *)p_shq);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3743 if (*p_sp != NUL)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1864
diff changeset
3744 append_redir(cmd, len, p_sp, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3745 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3746 * Output a newline if there's something else than the :make command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3747 * was typed (in which case the cursor is in column 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3748 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3749 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3750 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3751 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3752 MSG_PUTS(":!");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3753 msg_outtrans(cmd); /* show what we are doing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3755 /* let the shell know if we are redirecting output or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3756 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3757
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3758 #ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3759 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3760 /* read window status report and redraw before message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3761 (void)char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3762 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3763
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3764 res = qf_init(wp, fname, (eap->cmdidx != CMD_make
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3765 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3766 (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
3767 && 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
3768 *eap->cmdlinep, enc);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3769 if (wp != NULL)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3770 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
3771 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
3772 qf_list_changed(qi, qi->qf_curlist);
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3773 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3774 if (au_name != NULL)
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3775 {
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3776 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3777 curbuf->b_fname, TRUE, curbuf);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3778 if (qi->qf_curlist < qi->qf_listcount)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3779 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
3780 else
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3781 res = 0;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3782 }
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3783 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3784 if (res > 0 && !eap->forceit)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3785 qf_jump(qi, 0, 0, FALSE); /* display first error */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3786
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3787 mch_remove(fname);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3788 vim_free(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3789 vim_free(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3790 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3792 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3793 * Return the name for the errorfile, in allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3794 * Find a new unique name when 'makeef' contains "##".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3795 * Returns NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3798 get_mef_name(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3800 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802 static int start = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 static int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3804 #ifdef HAVE_LSTAT
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents: 9379
diff changeset
3805 stat_T sb;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3806 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3808 if (*p_mef == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3809 {
6721
7347229a646a updated for version 7.4.684
Bram Moolenaar <bram@vim.org>
parents: 6450
diff changeset
3810 name = vim_tempname('e', FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3811 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3812 EMSG(_(e_notmp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3813 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3814 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3815
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3816 for (p = p_mef; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3817 if (p[0] == '#' && p[1] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3818 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3820 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3821 return vim_strsave(p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3823 /* Keep trying until the name doesn't exist yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3824 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3826 if (start == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3827 start = mch_get_pid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3828 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3829 off += 19;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3831 name = alloc((unsigned)STRLEN(p_mef) + 30);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3832 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3833 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3834 STRCPY(name, p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3835 sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3836 STRCAT(name, p + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3837 if (mch_getperm(name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3838 #ifdef HAVE_LSTAT
10226
7a4fb555c83a commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents: 10056
diff changeset
3839 /* Don't accept a symbolic link, it's a security risk. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3840 && mch_lstat((char *)name, &sb) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3841 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3842 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3843 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3844 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3845 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3846 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3847 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3849 /*
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3850 * 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
3851 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3852 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3853 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
3854 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3855 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3856 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3857 int i, sz = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3858 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3859
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3860 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
3861 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3862 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3863 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3864 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3865 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3866 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3867
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3868 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
3869 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
3870 ++i, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3871 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3872 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3873 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3874 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
3875 sz++; /* Count all valid entries */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3876 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
3877 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3878 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3879 sz++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3880 prev_fnum = qfp->qf_fnum;
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 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3884
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3885 return sz;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3886 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3887
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3888 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3889 * 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
3890 * 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
3891 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3892 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3893 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
3894 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3895 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3896
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3897 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
3898 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3899 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3900 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3901 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3902 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3903 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3904
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3905 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
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 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3909 * 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
3910 * 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
3911 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3912 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3913 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
3914 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3915 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3916 qf_list_T *qfl;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3917 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3918 int i, eidx = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3919 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3920
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3921 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
3922 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3923 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3924 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3925 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3926 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3927 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3928
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3929 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
3930 qfp = qfl->qf_start;
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 /* 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
3933 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
3934 return 1;
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 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
3937 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3938 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3939 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3940 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
3941 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3942 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
3943 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3944 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3945 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3946 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3947 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3948 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3949 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3950 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3951 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3952 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3953
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3954 return eidx ? eidx : 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 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3958 * 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
3959 * 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
3960 * 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
3961 * 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
3962 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3963 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3964 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
3965 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3966 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
3967 qfline_T *qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3968 int i, eidx;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3969 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3970
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3971 /* 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
3972 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
3973 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3974
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3975 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
3976 i++, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3977 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3978 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3979 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3980 if (fdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3981 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3982 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
3983 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3984 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3985 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3986 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3987 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3988 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3989 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3990 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3991 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3992
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3993 if (eidx == n)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3994 break;
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
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3997 if (i <= qfl->qf_count)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3998 return i;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3999 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4000 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4001 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4002
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4003 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4004 * ":cc", ":crewind", ":cfirst" and ":clast".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4005 * ":ll", ":lrewind", ":lfirst" and ":llast".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4006 * ":cdo", ":ldo", ":cfdo" and ":lfdo"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4009 ex_cc(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4010 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4011 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
4012 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4013
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4014 if (eap->cmdidx == CMD_ll
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4015 || eap->cmdidx == CMD_lrewind
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4016 || eap->cmdidx == CMD_lfirst
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4017 || eap->cmdidx == CMD_llast
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4018 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4019 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4020 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4021 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4022 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4023 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4024 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4025 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4026 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4027 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4028
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4029 if (eap->addr_count > 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4030 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4031 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4032 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4033 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
4034 errornr = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4035 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
4036 || 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
4037 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4038 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4039 errornr = 32767;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4040 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4041
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4042 /* 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
4043 * 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
4044 */
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4045 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
4046 || 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
4047 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
4048 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
4049 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
4050
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4051 qf_jump(qi, 0, errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4053
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4054 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4055 * ":cnext", ":cnfile", ":cNext" and ":cprevious".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4056 * ":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
4057 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4058 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4059 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4060 ex_cnext(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4061 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4062 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
4063 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4064
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4065 if (eap->cmdidx == CMD_lnext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4066 || eap->cmdidx == CMD_lNext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4067 || eap->cmdidx == CMD_lprevious
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4068 || eap->cmdidx == CMD_lnfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4069 || eap->cmdidx == CMD_lNfile
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4070 || eap->cmdidx == CMD_lpfile
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4071 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4072 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4073 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4074 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4075 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4076 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4077 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4078 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4079 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4080 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4081
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4082 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
4083 && (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
4084 && 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
4085 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4086 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4087 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4088
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4089 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
4090 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4091 ? FORWARD
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4092 : (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
4093 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4094 ? FORWARD_FILE
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4095 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4096 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4097 ? BACKWARD_FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4098 : BACKWARD,
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4099 errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4102 /*
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4103 * ":cfile"/":cgetfile"/":caddfile" commands.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4104 * ":lfile"/":lgetfile"/":laddfile" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4107 ex_cfile(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4108 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4109 char_u *enc = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4110 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4111 qf_info_T *qi = &ql_info;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4112 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4113 char_u *au_name = NULL;
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4114 int save_qfid;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4115 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4116 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4117
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4118 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4119 switch (eap->cmdidx)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4120 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4121 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
4122 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
4123 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
4124 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
4125 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
4126 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
4127 default: break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4128 }
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4129 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4130 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
4131 #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
4132 #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
4133 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
4134 #endif
2296
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4135 #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
4136 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
4137 {
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4138 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
4139 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
4140 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
4141 return;
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4142 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
4143 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
4144 }
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4145 else
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4146 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4147 if (*eap->arg != NUL)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 682
diff changeset
4148 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
4149
13078
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4150 if (eap->cmdidx == CMD_lfile
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4151 || eap->cmdidx == CMD_lgetfile
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4152 || eap->cmdidx == CMD_laddfile)
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4153 wp = curwin;
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4154
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4155 /*
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4156 * This function is used by the :cfile, :cgetfile and :caddfile
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4157 * commands.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4158 * :cfile always creates a new quickfix list and jumps to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4159 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4160 * :cgetfile creates a new quickfix list but doesn't jump to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4161 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4162 * :caddfile adds to an existing quickfix list. If there is no
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4163 * quickfix list then a new list is created.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4164 */
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4165 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
4166 && 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
4167 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
4168 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
4169 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
4170 qf_list_changed(qi, qi->qf_curlist);
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4171 #ifdef FEAT_AUTOCMD
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4172 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4173 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4174 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4175 /*
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4176 * Autocmd might have freed the quickfix/location list. Check whether it is
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4177 * still valid
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4178 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4179 if (!qflist_valid(wp, save_qfid))
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4180 return;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4181 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4182 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
4183 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4184 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
4185 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4188 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4189 * ":vimgrep {pattern} file(s)"
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4190 * ":vimgrepadd {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4191 * ":lvimgrep {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4192 * ":lvimgrepadd {pattern} file(s)"
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4193 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4194 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4195 ex_vimgrep(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4196 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4197 regmmatch_T regmatch;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4198 int fcount;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4199 char_u **fnames;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4200 char_u *fname;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4201 char_u *title;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4202 char_u *s;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4203 char_u *p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4204 int fi;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4205 qf_info_T *qi = &ql_info;
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4206 int loclist_cmd = FALSE;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4207 #ifdef FEAT_AUTOCMD
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4208 int_u save_qfid;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4209 qfline_T *cur_qf_start;
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4210 win_T *wp;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4211 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4212 long lnum;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4213 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4214 int duplicate_name = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4215 int using_dummy;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4216 int redraw_for_dummy = FALSE;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4217 int found_match;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4218 buf_T *first_match_buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4219 time_t seconds = 0;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4220 int save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4221 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4222 char_u *save_ei = NULL;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4223 #endif
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4224 aco_save_T aco;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4225 int flags = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4226 colnr_T col;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4227 long tomatch;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4228 char_u *dirname_start = NULL;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4229 char_u *dirname_now = NULL;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4230 char_u *target_dir = NULL;
1683
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4231 #ifdef FEAT_AUTOCMD
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4232 char_u *au_name = NULL;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4233
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4234 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4235 {
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4236 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
4237 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
4238 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4239 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
4240 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
4241 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
4242 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
4243 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4244 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4245 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4246 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
4247 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4248 {
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4249 # ifdef FEAT_EVAL
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4250 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4251 return;
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4252 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4253 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4254 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4255
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4256 if (eap->cmdidx == CMD_lgrep
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4257 || eap->cmdidx == CMD_lvimgrep
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4258 || eap->cmdidx == CMD_lgrepadd
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4259 || eap->cmdidx == CMD_lvimgrepadd)
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4260 {
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4261 qi = ll_get_or_alloc_list(curwin);
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4262 if (qi == NULL)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4263 return;
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4264 loclist_cmd = TRUE;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4265 }
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4266
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4267 if (eap->addr_count > 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4268 tomatch = eap->line2;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4269 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4270 tomatch = MAXLNUM;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4271
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4272 /* Get the search pattern: either white-separated or enclosed in // */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4273 regmatch.regprog = NULL;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4274 title = vim_strsave(*eap->cmdlinep);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4275 p = skip_vimgrep_pat(eap->arg, &s, &flags);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4276 if (p == NULL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4277 {
282
33d9c918b8ab updated for version 7.0075
vimboss
parents: 277
diff changeset
4278 EMSG(_(e_invalpat));
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4279 goto theend;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4280 }
4197
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4281
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4282 if (s != NULL && *s == NUL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4283 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4284 /* Pattern is empty, use last search pattern. */
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4285 if (last_search_pat() == NULL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4286 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4287 EMSG(_(e_noprevre));
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4288 goto theend;
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4289 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4290 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
4291 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4292 else
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4293 regmatch.regprog = vim_regcomp(s, RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4294
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4295 if (regmatch.regprog == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4296 goto theend;
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 42
diff changeset
4297 regmatch.rmm_ic = p_ic;
410
c60ba877860b updated for version 7.0107
vimboss
parents: 359
diff changeset
4298 regmatch.rmm_maxcol = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4299
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4300 p = skipwhite(p);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4301 if (*p == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4302 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4303 EMSG(_("E683: File name missing or invalid pattern"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4304 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4305 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4306
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4307 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
4308 && eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4309 || qi->qf_curlist == qi->qf_listcount)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4310 /* 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
4311 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4312
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4313 /* parse the list of arguments */
3620
4f1c511e71f8 updated for version 7.3.570
Bram Moolenaar <bram@vim.org>
parents: 3555
diff changeset
4314 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4315 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4316 if (fcount == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4317 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4318 EMSG(_(e_nomatch));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4319 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4320 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4321
7558
9a4c9dccd603 commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents: 7515
diff changeset
4322 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
4323 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
4324 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
4325 {
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4326 FreeWild(fcount, fnames);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4327 goto theend;
7662
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4328 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4329
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4330 /* Remember the current directory, because a BufRead autocommand that does
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4331 * ":lcd %:p:h" changes the meaning of short path names. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4332 mch_dirname(dirname_start, MAXPATHL);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4333
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4334 #ifdef FEAT_AUTOCMD
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4335 /* Remember the current values of the quickfix list and qf_start, so that
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4336 * we can check for autocommands changing the current quickfix list. */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4337 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4338 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
4339 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4340
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4341 seconds = (time_t)0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4342 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4343 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4344 fname = shorten_fname1(fnames[fi]);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4345 if (time(NULL) > seconds)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4346 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4347 /* 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
4348 * working on it. */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4349 seconds = time(NULL);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4350 msg_start();
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4351 p = msg_strtrunc(fname, TRUE);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4352 if (p == NULL)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4353 msg_outtrans(fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4354 else
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4355 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4356 msg_outtrans(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4357 vim_free(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4358 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4359 msg_clr_eos();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4360 msg_didout = FALSE; /* overwrite this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4361 msg_nowait = TRUE; /* don't wait for this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4362 msg_col = 0;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4363 out_flush();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4364 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4365
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4366 buf = buflist_findname_exp(fnames[fi]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4367 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4368 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4369 /* Remember that a buffer with this name already exists. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4370 duplicate_name = (buf != NULL);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4371 using_dummy = TRUE;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4372 redraw_for_dummy = TRUE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4373
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4374 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4375 /* Don't do Filetype autocommands to avoid loading syntax and
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4376 * indent scripts, a great speed improvement. */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4377 save_ei = au_event_disable(",Filetype");
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4378 #endif
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4379 /* Don't use modelines here, it's useless. */
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4380 save_mls = p_mls;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4381 p_mls = 0;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4382
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4383 /* Load file into a buffer, so that 'fileencoding' is detected,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4384 * autocommands applied, etc. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4385 buf = load_dummy_buffer(fname, dirname_start, dirname_now);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4386
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4387 p_mls = save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4388 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4389 au_event_restore(save_ei);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4390 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4391 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4392 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4393 /* Use existing, loaded buffer. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4394 using_dummy = FALSE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4395
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4396 #ifdef FEAT_AUTOCMD
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4397 if (loclist_cmd)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4398 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4399 /*
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4400 * Verify that the location list is still valid. An autocmd might
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4401 * have freed the location list.
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4402 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4403 if (!qflist_valid(curwin, save_qfid))
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4404 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4405 EMSG(_(e_loc_list_changed));
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4406 goto theend;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4407 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4408 }
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4409 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
4410 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4411 int idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4412
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4413 /* 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
4414 * using and restore it. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4415 for (idx = 0; idx < LISTCOUNT; ++idx)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4416 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
4417 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4418 qi->qf_curlist = idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4419 break;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4420 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4421 if (idx == LISTCOUNT)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4422 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4423 /* List cannot be found, create a new one. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4424 qf_new_list(qi, *eap->cmdlinep);
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4425 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
4426 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4427 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4428 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4429
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4430 if (buf == NULL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4431 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4432 if (!got_int)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4433 smsg((char_u *)_("Cannot open file \"%s\""), fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4434 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4435 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4436 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4437 /* Try for a match in all lines of the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4438 * For ":1vimgrep" look for first match only. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4439 found_match = FALSE;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4440 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4441 ++lnum)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4442 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4443 col = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4444 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
4445 col, NULL, NULL) > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4446 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4447 /* 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
4448 * 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
4449 * 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
4450 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
4451 qi->qf_curlist,
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4452 NULL, /* dir */
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4453 fname,
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4454 duplicate_name ? 0 : buf->b_fnum,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4455 ml_get_buf(buf,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4456 regmatch.startpos[0].lnum + lnum, FALSE),
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4457 regmatch.startpos[0].lnum + lnum,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4458 regmatch.startpos[0].col + 1,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4459 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4460 NULL, /* search pattern */
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4461 0, /* nr */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4462 0, /* type */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4463 TRUE /* valid */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4464 ) == FAIL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4465 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4466 got_int = TRUE;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4467 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4468 }
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4469 found_match = TRUE;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4470 if (--tomatch == 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4471 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4472 if ((flags & VGR_GLOBAL) == 0
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4473 || regmatch.endpos[0].lnum > 0)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4474 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4475 col = regmatch.endpos[0].col
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4476 + (col == regmatch.endpos[0].col);
1883
c8f343a465a2 updated for version 7.2-180
vimboss
parents: 1872
diff changeset
4477 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE)))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4478 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4479 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4480 line_breakcheck();
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4481 if (got_int)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4482 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4483 }
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4484 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4485 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
4486 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4487
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4488 if (using_dummy)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4489 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4490 if (found_match && first_match_buf == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4491 first_match_buf = buf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4492 if (duplicate_name)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4493 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4494 /* Never keep a dummy buffer if there is another buffer
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4495 * with the same name. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4496 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4497 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4498 }
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4499 else if (!cmdmod.hide
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4500 || buf->b_p_bh[0] == 'u' /* "unload" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4501 || buf->b_p_bh[0] == 'w' /* "wipe" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4502 || buf->b_p_bh[0] == 'd') /* "delete" */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4503 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4504 /* When no match was found we don't need to remember the
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4505 * buffer, wipe it out. If there was a match and it
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4506 * wasn't the first one or we won't jump there: only
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4507 * unload the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4508 * Ignore 'hidden' here, because it may lead to having too
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4509 * many swap files. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4510 if (!found_match)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4511 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4512 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4513 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4514 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4515 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4516 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4517 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
4518 /* 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
4519 buf->b_flags &= ~BF_DUMMY;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4520 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4521 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4522 }
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4523
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4524 if (buf != NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4525 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4526 /* 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
4527 buf->b_flags &= ~BF_DUMMY;
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4528
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4529 /* If the buffer is still loaded we need to use the
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4530 * directory we jumped to below. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4531 if (buf == first_match_buf
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4532 && target_dir == NULL
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4533 && STRCMP(dirname_start, dirname_now) != 0)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4534 target_dir = vim_strsave(dirname_now);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4535
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4536 /* The buffer is still loaded, the Filetype autocommands
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4537 * need to be done now, in that buffer. And the modelines
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4538 * need to be done (again). But not the window-local
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4539 * options! */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4540 aucmd_prepbuf(&aco, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4541 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4542 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4543 buf->b_fname, TRUE, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4544 #endif
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4545 do_modelines(OPT_NOWIN);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4546 aucmd_restbuf(&aco);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4547 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4548 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4549 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4550 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4551
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4552 FreeWild(fcount, fnames);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4553
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4554 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4555 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
4556 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
4557 qf_list_changed(qi, qi->qf_curlist);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4558
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4559 qf_update_buffer(qi, NULL);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4560
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4561 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4562 if (au_name != NULL)
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4563 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4564 curbuf->b_fname, TRUE, curbuf);
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4565 /*
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4566 * The QuickFixCmdPost autocmd may free the quickfix list. Check the list
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4567 * is still valid.
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4568 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4569 wp = loclist_cmd ? curwin : NULL;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4570 if (!qflist_valid(wp, save_qfid))
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4571 goto theend;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4572 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4573
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4574 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4575 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4576 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4577 if ((flags & VGR_NOJUMP) == 0)
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4578 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4579 buf = curbuf;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4580 qf_jump(qi, 0, 0, eap->forceit);
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4581 if (buf != curbuf)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4582 /* If we jumped to another buffer redrawing will already be
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4583 * taken care of. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4584 redraw_for_dummy = FALSE;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4585
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4586 /* Jump to the directory used after loading the buffer. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4587 if (curbuf == first_match_buf && target_dir != NULL)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4588 {
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4589 exarg_T ea;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4590
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4591 ea.arg = target_dir;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4592 ea.cmdidx = CMD_lcd;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4593 ex_cd(&ea);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4594 }
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4595 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4596 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4597 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4598 EMSG2(_(e_nomatch2), s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4599
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4600 /* If we loaded a dummy buffer into the current window, the autocommands
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4601 * may have messed up things, need to redraw and recompute folds. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4602 if (redraw_for_dummy)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4603 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4604 #ifdef FEAT_FOLDING
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4605 foldUpdateAll(curwin);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4606 #else
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4607 redraw_later(NOT_VALID);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4608 #endif
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4609 }
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4610
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4611 theend:
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4612 vim_free(title);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4613 vim_free(dirname_now);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4614 vim_free(dirname_start);
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4615 vim_free(target_dir);
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
4616 vim_regfree(regmatch.regprog);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4617 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4618
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4619 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4620 * 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
4621 * 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
4622 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4623 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4624 restore_start_dir(char_u *dirname_start)
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4625 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4626 char_u *dirname_now = alloc(MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4627
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4628 if (NULL != dirname_now)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4629 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4630 mch_dirname(dirname_now, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4631 if (STRCMP(dirname_start, dirname_now) != 0)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4632 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4633 /* 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
4634 * appropriate ex command and executing it. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4635 exarg_T ea;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4636
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4637 ea.arg = dirname_start;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4638 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
4639 ex_cd(&ea);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4640 }
3974
4d1753f3e85c updated for version 7.3.742
Bram Moolenaar <bram@vim.org>
parents: 3965
diff changeset
4641 vim_free(dirname_now);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4642 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4643 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4644
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4645 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4646 * 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
4647 * 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
4648 * "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
4649 * 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
4650 * 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
4651 *
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4652 * 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
4653 * or wipe_dummy_buffer() later!
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4654 *
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4655 * Returns NULL if it fails.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4656 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4657 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4658 load_dummy_buffer(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4659 char_u *fname,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4660 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
4661 char_u *resulting_dir) /* out: new directory */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4662 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4663 buf_T *newbuf;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4664 bufref_T newbufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4665 bufref_T newbuf_to_wipe;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4666 int failed = TRUE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4667 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
4668 int readfile_result;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4669
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4670 /* Allocate a buffer without putting it in the buffer list. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4671 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4672 if (newbuf == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4673 return NULL;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4674 set_bufref(&newbufref, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4675
177
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4676 /* Init the options. */
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4677 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4678
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4679 /* need to open the memfile before putting the buffer in a window */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4680 if (ml_open(newbuf) == OK)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4681 {
13056
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4682 /* 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
4683 ++newbuf->b_locked;
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4684
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4685 /* set curwin/curbuf to buf and save a few things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4686 aucmd_prepbuf(&aco, newbuf);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4687
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4688 /* Need to set the filename for autocommands. */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4689 (void)setfname(curbuf, fname, NULL, FALSE);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4690
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4691 /* Create swap file now to avoid the ATTENTION message. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4692 check_need_swap(TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4693
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4694 /* Remove the "dummy" flag, otherwise autocommands may not
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4695 * work. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4696 curbuf->b_flags &= ~BF_DUMMY;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4697
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4698 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
4699 readfile_result = readfile(fname, NULL,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4700 (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
4701 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
4702 --newbuf->b_locked;
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
4703 if (readfile_result == OK
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4704 && !got_int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4705 && !(curbuf->b_flags & BF_NEW))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4706 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4707 failed = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4708 if (curbuf != newbuf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4709 {
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4710 /* Bloody autocommands changed the buffer! Can happen when
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4711 * 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
4712 * 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
4713 * window stuff. */
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4714 set_bufref(&newbuf_to_wipe, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4715 newbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4716 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4717 }
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4718
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4719 /* restore curwin/curbuf and a few other things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4720 aucmd_restbuf(&aco);
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4721 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
4722 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
4723
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4724 /* 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
4725 * skip it. */
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4726 newbuf->b_flags |= BF_DUMMY;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4727 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4728
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4729 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4730 * When autocommands/'autochdir' option changed directory: go back.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4731 * 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
4732 * important.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4733 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4734 mch_dirname(resulting_dir, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4735 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4736
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4737 if (!bufref_valid(&newbufref))
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4738 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4739 if (failed)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4740 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4741 wipe_dummy_buffer(newbuf, dirname_start);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4742 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4743 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4744 return newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4745 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4746
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4747 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4748 * 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
4749 * 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
4750 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4751 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4752 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4753 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4754 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4755 if (curbuf != buf) /* safety check */
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4756 {
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4757 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4758 cleanup_T cs;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4759
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4760 /* Reset the error/interrupt/exception state here so that aborting()
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4761 * returns FALSE when wiping out the buffer. Otherwise it doesn't
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4762 * work when got_int is set. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4763 enter_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4764 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4765
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4766 wipe_buffer(buf, FALSE);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4767
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4768 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4769 /* Restore the error/interrupt/exception state if not discarded by a
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4770 * new aborting error, interrupt, or uncaught exception. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4771 leave_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4772 #endif
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4773 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4774 restore_start_dir(dirname_start);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4775 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4776 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4777
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4778 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4779 * 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
4780 * 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
4781 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4782 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4783 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4784 unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4785 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4786 if (curbuf != buf) /* safety check */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4787 {
3365
9ccdc4a69d8f updated for version 7.3.449
Bram Moolenaar <bram@vim.org>
parents: 3269
diff changeset
4788 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4789
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4790 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4791 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4792 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4793 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4794
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4795 #if defined(FEAT_EVAL) || defined(PROTO)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4796 /*
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4797 * 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
4798 * 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
4799 */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4800 int
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4801 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
4802 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4803 qf_info_T *qi = qi_arg;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4804 dict_T *dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4805 char_u buf[2];
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4806 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4807 int i;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4808 int bufnum;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4809
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4810 if (qi == NULL)
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4811 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4812 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
4813 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
4814 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4815 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
4816 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
4817 return FAIL;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4818 }
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4819 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4820
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4821 if (qf_idx == -1)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4822 qf_idx = qi->qf_curlist;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4823
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4824 if (qf_idx >= qi->qf_listcount
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4825 || qi->qf_lists[qf_idx].qf_count == 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4826 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4827
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4828 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
4829 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
4830 {
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4831 /* Handle entries with a non-existing buffer number. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4832 bufnum = qfp->qf_fnum;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4833 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4834 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4835
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4836 if ((dict = dict_alloc()) == NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4837 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4838 if (list_append_dict(list, dict) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4839 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4840
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4841 buf[0] = qfp->qf_type;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4842 buf[1] = NUL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4843 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4844 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4845 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4846 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4847 || 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
4848 || dict_add_nr_str(dict, "pattern", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4849 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4850 || dict_add_nr_str(dict, "text", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4851 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4852 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4853 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4854 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4855
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4856 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4857 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4858 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4859 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4860 return OK;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4861 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4862
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4863 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4864 * 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
4865 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4866 enum {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4867 QF_GETLIST_NONE = 0x0,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4868 QF_GETLIST_TITLE = 0x1,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4869 QF_GETLIST_ITEMS = 0x2,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4870 QF_GETLIST_NR = 0x4,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4871 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
4872 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
4873 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
4874 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
4875 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
4876 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
4877 QF_GETLIST_ALL = 0x1FF
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4878 };
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4879
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4880 /*
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4881 * 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
4882 */
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4883 static int
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4884 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
4885 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4886 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
4887 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
4888 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
4889 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
4890 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
4891
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
4892 /* 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
4893 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
4894 {
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4895 /* 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
4896 * option setting
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4897 */
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4898 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
4899 {
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4900 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
4901 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
4902 return FAIL;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4903 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
4904 }
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4905
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4906 l = list_alloc();
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4907 if (l == NULL)
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4908 return FAIL;
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4909
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4910 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
4911 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
4912 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4913 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
4914 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
4915
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
4916 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
4917 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
4918 {
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4919 (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
4920 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
4921 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4922 free(qi);
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4923 }
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
4924 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
4925 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
4926 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4927
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4928 return status;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4929 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4930
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
4931 /*
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4932 * 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
4933 * 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
4934 */
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4935 static int
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4936 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
4937 {
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4938 int qf_idx;
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4939
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4940 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
4941 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
4942 return qf_idx;
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4943 return -1;
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4944 }
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4945
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4946 /*
13115
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4947 * Return the quickfix/location list window identifier in the current tabpage.
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4948 */
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4949 static int
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4950 qf_winid(qf_info_T *qi)
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4951 {
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4952 win_T *win;
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4953
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4954 /* The quickfix window can be opened even if the quickfix list is not set
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4955 * using ":copen". This is not true for location lists. */
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4956 if (qi == NULL)
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4957 return 0;
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4958 win = qf_find_win(qi);
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4959 if (win != NULL)
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4960 return win->w_id;
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4961 return 0;
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4962 }
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4963
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
4964 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4965 * 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
4966 * 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
4967 * then current list is used. Otherwise the specified list is used.
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4968 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4969 int
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
4970 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
4971 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4972 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4973 int status = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4974 int qf_idx;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4975 dictitem_T *di;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4976 int flags = QF_GETLIST_NONE;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4977
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
4978 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
4979 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
4980
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4981 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
4982 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
4983
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4984 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
4985 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
4986
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4987 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
4988 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
4989
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4990 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
4991 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
4992
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4993 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
4994 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
4995
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
4996 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
4997 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
4998
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
4999 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
5000 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
5001
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5002 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
5003 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
5004
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
5005 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
5006 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
5007
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5008 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
5009 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
5010
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5011 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
5012 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
5013
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5014 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
5015 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5016 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
5017 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
5018 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5019 /* 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
5020 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
5021 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5022 /* 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
5023 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
5024 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5025 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
5026 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
5027 qf_idx = -1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5028 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5029 }
13066
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
5030 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
5031 && di->di_tv.vval.v_string != NULL
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
5032 && 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
5033 /* 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
5034 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
5035 else
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5036 qf_idx = -1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5037 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
5038 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5039
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5040 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
5041 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5042 /* 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
5043 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
5044 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5045 /*
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5046 * 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
5047 */
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5048 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
5049 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
5050 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
5051 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5052 else
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5053 qf_idx = -1;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5054 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5055 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5056
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5057 /* 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
5058 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
5059 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5060 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
5061 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
5062 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
5063 {
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5064 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
5065 if (l != NULL)
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5066 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
5067 else
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5068 status = FAIL;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5069 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5070 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
5071 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
5072 if ((status == OK) && (flags & QF_GETLIST_WINID))
13115
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
5073 status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5074 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
5075 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
5076 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
5077 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
5078 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
5079 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
5080 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
5081 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
5082 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
5083 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
5084
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5085 return status;
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5086 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5087
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5088 if (flags & QF_GETLIST_TITLE)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5089 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5090 char_u *t;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5091 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
5092 if (t == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5093 t = (char_u *)"";
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5094 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
5095 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5096 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
5097 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
5098 if ((status == OK) && (flags & QF_GETLIST_WINID))
13115
9812a9ca3ab2 patch 8.0.1432: after ":copen" can't get the window-ID of the quickfix window
Christian Brabandt <cb@256bit.org>
parents: 13105
diff changeset
5099 status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5100 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
5101 {
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5102 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
5103 if (l != NULL)
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5104 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5105 (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
5106 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
5107 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5108 else
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5109 status = FAIL;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5110 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5111
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5112 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
5113 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5114 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
5115 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5116 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
5117 if (di != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5118 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5119 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
5120 status = dict_add(retdict, di);
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5121 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
5122 dictitem_free(di);
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5123 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5124 else
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
5125 status = FAIL;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5126 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5127 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5128 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
5129 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5130
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5131 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
5132 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
5133 NULL);
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5134
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
5135 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
5136 {
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5137 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
5138 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
5139 /* 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
5140 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
5141 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
5142 }
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5143
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5144 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
5145 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
5146 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
5147
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5148 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
5149 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
5150 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
5151
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5152 return status;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5153 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5154
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5155 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5156 * 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
5157 * a dictionary with item information.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5158 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5159 static int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5160 qf_add_entries(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5161 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
5162 int qf_idx,
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5163 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5164 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5165 int action)
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5166 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5167 listitem_T *li;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5168 dict_T *d;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5169 char_u *filename, *pattern, *text, *type;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5170 int bufnum;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5171 long lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5172 int col, nr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5173 int vcol;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
5174 qfline_T *old_last = NULL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5175 int valid, status;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5176 int retval = OK;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5177 int did_bufnr_emsg = FALSE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5178
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5179 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
5180 {
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
5181 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
5182 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
5183 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
5184 }
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5185 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
5186 /* 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
5187 old_last = qi->qf_lists[qf_idx].qf_last;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
5188 else if (action == 'r')
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
5189 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5190 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
5191 qf_store_title(qi, qf_idx, title);
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
5192 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5193
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5194 for (li = list->lv_first; li != NULL; li = li->li_next)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5195 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5196 if (li->li_tv.v_type != VAR_DICT)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5197 continue; /* Skip non-dict items */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5198
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5199 d = li->li_tv.vval.v_dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5200 if (d == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5201 continue;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5202
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5203 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
5204 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
5205 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
5206 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
5207 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
5208 nr = (int)get_dict_number(d, (char_u *)"nr");
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5209 type = get_dict_string(d, (char_u *)"type", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5210 pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5211 text = get_dict_string(d, (char_u *)"text", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5212 if (text == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5213 text = vim_strsave((char_u *)"");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5214
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5215 valid = TRUE;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5216 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5217 valid = FALSE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5218
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5219 /* Mark entries with non-existing buffer number as not valid. Give the
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5220 * error message only once. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5221 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5222 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5223 if (!did_bufnr_emsg)
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5224 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5225 did_bufnr_emsg = TRUE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5226 EMSGN(_("E92: Buffer %ld not found"), bufnum);
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5227 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5228 valid = FALSE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5229 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5230 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5231
11390
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
5232 /* 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
5233 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
5234 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
5235
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5236 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
5237 qf_idx,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5238 NULL, /* dir */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5239 filename,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5240 bufnum,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5241 text,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5242 lnum,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5243 col,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5244 vcol, /* vis_col */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5245 pattern, /* search pattern */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5246 nr,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5247 type == NULL ? NUL : *type,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5248 valid);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5249
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5250 vim_free(filename);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5251 vim_free(pattern);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5252 vim_free(text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5253 vim_free(type);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5254
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5255 if (status == FAIL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5256 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5257 retval = FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5258 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5259 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5260 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5261
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5262 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
5263 /* 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
5264 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
5265 else
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5266 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
5267 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
5268 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5269 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
5270 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
5271 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
5272 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
5273 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5274
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
5275 /* 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
5276 qf_update_buffer(qi, old_last);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5277
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5278 return retval;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5279 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5280
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5281 static int
12048
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5282 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
5283 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5284 dictitem_T *di;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5285 int retval = FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5286 int qf_idx;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5287 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
5288 char_u *errorformat = p_efm;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5289
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5290 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
5291 newlist = TRUE;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5292
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5293 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
5294 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
5295 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5296 /* Use the specified quickfix/location list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5297 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
5298 {
11445
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5299 /* 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
5300 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
5301 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
5302
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5303 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
5304 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5305 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5306 * 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
5307 * 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
5308 * stack.
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5309 */
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5310 newlist = TRUE;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5311 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
5312 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5313 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
5314 return FAIL;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5315 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
5316 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
5317 }
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5318 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
5319 && di->di_tv.vval.v_string != NULL
617112037564 patch 8.0.1408: crash in setqflist()
Christian Brabandt <cb@256bit.org>
parents: 13062
diff changeset
5320 && 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
5321 {
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5322 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
5323 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
5324 else if (newlist)
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5325 qf_idx = 0;
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5326 else
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5327 return FAIL;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5328 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5329 else
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5330 return FAIL;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5331 }
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5332
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5333 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
5334 {
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5335 /* 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
5336 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
5337 {
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5338 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
5339 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
5340 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
5341 }
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5342 else
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5343 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
5344 }
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5345
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5346 if (newlist)
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5347 {
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5348 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
5349 qf_new_list(qi, title);
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5350 qf_idx = qi->qf_curlist;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5351 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5352
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5353 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
5354 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5355 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
5356 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5357 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
5358 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
5359 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
5360 if (qf_idx == qi->qf_curlist)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5361 qf_update_win_titlevar(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5362 retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5363 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5364 }
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5365
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5366 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
5367 {
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5368 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
5369 {
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5370 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
5371
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5372 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
5373 title_save, action == ' ' ? 'a' : action);
12427
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5374 if (action == 'r')
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5375 {
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5376 /*
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5377 * 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
5378 * 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
5379 * 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
5380 */
fc3e2d5614dd patch 8.0.1093: various small quickfix issues
Christian Brabandt <cb@256bit.org>
parents: 12321
diff changeset
5381 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
5382 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
5383 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5384 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
5385 }
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5386 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5387
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5388 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
5389 {
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5390 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
5391 return FAIL;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5392 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
5393 }
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5394
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5395 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
5396 {
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5397 /* 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
5398 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
5399 {
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5400 if (action == 'r')
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5401 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
5402 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
5403 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
5404 retval = OK;
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5405 }
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5406 else
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5407 return FAIL;
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5408 }
ebd313aa5a6c patch 8.0.0904: cannot set a location list from text
Christian Brabandt <cb@256bit.org>
parents: 11800
diff changeset
5409
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5410 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
5411 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5412 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
5413
11445
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5414 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
5415 ctx = alloc_tv();
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5416 if (ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5417 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
5418 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
5419 retval = OK;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5420 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5421
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5422 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
5423 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
5424
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5425 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5426 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5427
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5428 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5429 * 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
5430 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5431 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
5432 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
5433 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5434 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
5435
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5436 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
5437 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
5438 return wp;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5439
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5440 return NULL;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5441 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5442
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5443 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5444 * 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
5445 * 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
5446 */
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5447 static void
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5448 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
5449 {
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5450 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
5451 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
5452 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
5453
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5454 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
5455 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5456 /* 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
5457 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
5458 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
5459 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
5460 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5461
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5462 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
5463 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5464 /* 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
5465 * 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
5466 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5467 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
5468 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
5469 wp = llwin;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5470 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5471
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5472 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
5473 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
5474 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5475 /* quickfix list */
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5476 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
5477 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
5478 }
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5479 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
5480 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5481 /* 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
5482 * location list */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5483 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
5484
11398
30af33f4d353 patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents: 11390
diff changeset
5485 /* 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
5486 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
5487
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5488 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
5489 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
5490 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5491 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
5492 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
5493 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5494 }
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5495 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5496
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5497 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5498 * 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
5499 * 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
5500 * "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
5501 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5502 int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5503 set_errorlist(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5504 win_T *wp,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5505 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5506 int action,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5507 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5508 dict_T *what)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5509 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5510 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5511 int retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5512
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5513 if (wp != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5514 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5515 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
5516 if (qi == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5517 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5518 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5519
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5520 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
5521 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5522 /* 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
5523 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
5524 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5525 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
5526 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
5527 else
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5528 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5529 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
5530 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
5531 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
5532 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5533
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5534 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5535 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5536
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5537 static int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5538 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
5539 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5540 int i;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5541 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5542 typval_T *ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5543
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5544 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
5545 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5546 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
5547 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
5548 && 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
5549 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
5550 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5551
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5552 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5553 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5554
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5555 /*
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5556 * 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
5557 * "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
5558 */
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5559 int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5560 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
5561 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5562 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5563 tabpage_T *tp;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5564 win_T *win;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5565
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5566 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
5567 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5568 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5569
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5570 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
5571 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5572 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
5573 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5574 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
5575 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5576 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5577 }
13074
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5578 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
5579 {
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5580 /* 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
5581 * 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
5582 * context as still in use.
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5583 */
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5584 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
5585 if (abort)
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5586 return abort;
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
5587 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5588 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5589
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5590 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5591 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5592 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5593
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5594 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5595 * ":[range]cbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
5596 * ":[range]caddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5597 * ":[range]cgetbuffer [bufnr]" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5598 * ":[range]lbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
5599 * ":[range]laddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5600 * ":[range]lgetbuffer [bufnr]" command.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5601 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5602 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5603 ex_cbuffer(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5604 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5605 buf_T *buf = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5606 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
5607 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5608 char_u *au_name = NULL;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5609 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5610 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5611
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5612 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5613 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5614 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5615 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
5616 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
5617 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
5618 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
5619 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
5620 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
5621 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5622 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5623 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
5624 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5625 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5626 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5627 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5628 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5629 # endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5630 }
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5631 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5632
13076
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5633 /* Must come after autocommands. */
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5634 if (eap->cmdidx == CMD_lbuffer
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5635 || eap->cmdidx == CMD_lgetbuffer
13076
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5636 || eap->cmdidx == CMD_laddbuffer)
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5637 {
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5638 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
5639 if (qi == NULL)
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5640 return;
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5641 }
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
5642
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5643 if (*eap->arg == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5644 buf = curbuf;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5645 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5646 buf = buflist_findnr(atoi((char *)eap->arg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5647 if (buf == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5648 EMSG(_(e_invarg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5649 else if (buf->b_ml.ml_mfp == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5650 EMSG(_("E681: Buffer is not loaded"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5651 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5652 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5653 if (eap->addr_count == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5654 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5655 eap->line1 = 1;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5656 eap->line2 = buf->b_ml.ml_line_count;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5657 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5658 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5659 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5660 EMSG(_(e_invrange));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5661 else
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5662 {
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5663 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
5664
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5665 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
5666 {
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5667 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
5668 (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
5669 qf_title = IObuff;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5670 }
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5671
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5672 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
5673 (eap->cmdidx != CMD_caddbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5674 && 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
5675 eap->line1, eap->line2,
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5676 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
5677 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
5678 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
5679 #ifdef FEAT_AUTOCMD
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5680 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5681 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
5682 curbuf->b_fname, TRUE, curbuf);
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5683 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5684 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
5685 eap->cmdidx == CMD_lbuffer))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5686 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5687 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5688 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5689 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5690
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
5691 #if defined(FEAT_EVAL) || defined(PROTO)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5692 /*
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5693 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command.
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5694 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command.
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5695 */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5696 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5697 ex_cexpr(exarg_T *eap)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5698 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5699 typval_T *tv;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5700 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
5701 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5702 char_u *au_name = NULL;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5703 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5704 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5705
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5706 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5707 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5708 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5709 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
5710 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
5711 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
5712 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
5713 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
5714 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
5715 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5716 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5717 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
5718 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5719 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5720 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5721 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5722 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5723 # endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5724 }
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5725 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5726
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5727 if (eap->cmdidx == CMD_lexpr
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5728 || eap->cmdidx == CMD_lgetexpr
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5729 || eap->cmdidx == CMD_laddexpr)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5730 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5731 qi = ll_get_or_alloc_list(curwin);
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5732 if (qi == NULL)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5733 return;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5734 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
5735
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5736 /* 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
5737 * use it to fill the errorlist. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5738 tv = eval_expr(eap->arg, NULL);
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5739 if (tv != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5740 {
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5741 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5742 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5743 {
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5744 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
5745 (eap->cmdidx != CMD_caddexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5746 && 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
5747 (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
5748 NULL);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5749 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
5750 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
5751 #ifdef FEAT_AUTOCMD
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5752 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5753 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
5754 curbuf->b_fname, TRUE, curbuf);
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5755 #endif
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5756 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
5757 eap->cmdidx == CMD_lexpr))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
5758 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5759 }
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5760 else
626
732c7ae5743e updated for version 7.0180
vimboss
parents: 625
diff changeset
5761 EMSG(_("E777: String or List expected"));
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5762 free_tv(tv);
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5763 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5764 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
5765 #endif
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5766
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5767 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 * ":helpgrep {pattern}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5771 ex_helpgrep(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 char_u *save_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 int fcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 int fi;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 long lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5781 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5782 char_u *lang;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5783 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5784 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
5785 qf_info_T *save_qi;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5786 int new_qi = FALSE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5787 win_T *wp;
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5788 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5789 char_u *au_name = NULL;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5790 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5792 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5793 /* Check for a specified language */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5794 lang = check_help_lang(eap->arg);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5795 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5796
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5797 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5798 switch (eap->cmdidx)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5799 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5800 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
5801 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
5802 default: break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5803 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5804 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
5805 curbuf->b_fname, TRUE, curbuf))
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5806 {
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5807 # ifdef FEAT_EVAL
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5808 if (aborting())
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5809 return;
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5810 # endif
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5811 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5812 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5813
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5814 /* 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
5815 save_cpo = p_cpo;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5816 p_cpo = empty_option;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5817
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5818 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5819 {
11800
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5820 /* 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
5821 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
5822 wp = curwin;
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5823 else
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5824 /* 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
5825 FOR_ALL_WINDOWS(wp)
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
5826 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
5827 break;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5828
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5829 if (wp == NULL) /* Help window not found */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5830 qi = NULL;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5831 else
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5832 qi = wp->w_llist;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5833
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5834 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5835 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5836 /* Allocate a new location list for help text matches */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5837 if ((qi = ll_new_list()) == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5838 return;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5839 new_qi = TRUE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5840 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5841 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5842
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5843 /* 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
5844 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
5845
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 regmatch.rm_ic = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 if (regmatch.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5850 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5851 vimconv_T vc;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5852
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5853 /* 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
5854 * differs. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5855 vc.vc_type = CONV_NONE;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5856 if (!enc_utf8)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5857 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
5858 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5859
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5860 /* create a new quickfix list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
5861 qf_new_list(qi, *eap->cmdlinep);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5863 /* Go through all directories in 'runtimepath' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864 p = p_rtp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 while (*p != NUL && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5866 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867 copy_option_part(&p, NameBuff, MAXPATHL, ",");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5870 add_pathsep(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 if (gen_expand_wildcards(1, &NameBuff, &fcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 &fnames, EW_FILE|EW_SILENT) == OK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874 && fcount > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876 for (fi = 0; fi < fcount && !got_int; ++fi)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5878 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5879 /* Skip files for a different language. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5880 if (lang != NULL
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5881 && STRNICMP(lang, fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5882 + STRLEN(fnames[fi]) - 3, 2) != 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5883 && !(STRNICMP(lang, "en", 2) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5884 && STRNICMP("txt", fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5885 + STRLEN(fnames[fi]) - 3, 3) == 0))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5886 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5887 #endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 514
diff changeset
5888 fd = mch_fopen((char *)fnames[fi], "r");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5891 lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5893 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5894 char_u *line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5895 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5896 /* 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
5897 * the line contains a non-ASCII character. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5898 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
5899 && 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
5900 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5901 line = string_convert(&vc, IObuff, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5902 if (line == NULL)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5903 line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5904 }
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5905 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5906
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5907 if (vim_regexec(&regmatch, line, (colnr_T)0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5909 int l = (int)STRLEN(line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5911 /* remove trailing CR, LF, spaces, etc. */
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5912 while (l > 0 && line[l - 1] <= ' ')
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5913 line[--l] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5915 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
5916 qi->qf_curlist,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 NULL, /* dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5918 fnames[fi],
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5919 0,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5920 line,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 lnum,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5922 (int)(regmatch.startp[0] - line)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5923 + 1, /* col */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5924 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5925 NULL, /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 0, /* nr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 1, /* type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5928 TRUE /* valid */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929 ) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5930 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5931 got_int = TRUE;
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5932 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5933 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5934 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5935 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5938 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5939 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5940 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5941 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5942 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5946 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949 FreeWild(fcount, fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5952
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
5953 vim_regfree(regmatch.regprog);
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5954 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5955 if (vc.vc_type != CONV_NONE)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5956 convert_setup(&vc, NULL, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5957 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5959 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5960 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5961 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5962 qi->qf_lists[qi->qf_curlist].qf_index = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5963 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5964
1672
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5965 if (p_cpo == empty_option)
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5966 p_cpo = save_cpo;
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5967 else
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5968 /* Darn, some plugin changed the value. */
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5969 free_string_option(save_cpo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5971 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
5972 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5973
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5974 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5975 if (au_name != NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5976 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5977 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5978 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
5979 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
5980 /* autocommands made "qi" invalid */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5981 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5982 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5983 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5984
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5985 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5986 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5987 qf_jump(qi, 0, 0, FALSE);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5988 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5989 EMSG2(_(e_nomatch2), eap->arg);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5990
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5991 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5992 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5993 /* 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
5994 * 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
5995 if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5996 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5997 if (new_qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5998 ll_free_all(&qi);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5999 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6000 else if (curwin->w_llist == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6001 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6002 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6005 #endif /* FEAT_QUICKFIX */