annotate src/quickfix.c @ 13921:3b6c29f8c1a2 v8.0.1831

patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':' commit https://github.com/vim/vim/commit/8b62e31003693fee4b288e7aea49170f032aeef3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 13 15:29:04 2018 +0200 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':' Problem: Sometimes the quickfix title is incorrectly prefixed with ':'. Solution: Prepend the colon in another way. (Yegappan Lakshmanan, closes #2905)
author Christian Brabandt <cb@256bit.org>
date Sun, 13 May 2018 15:30:07 +0200
parents f48fcaa196a9
children 2ed1585c6467
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 */
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
36 char_u *qf_module; /* module name for this error */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
37 char_u *qf_pattern; /* search pattern for the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
38 char_u *qf_text; /* description of the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
39 char_u qf_viscol; /* set to TRUE if qf_col is screen column */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
40 char_u qf_cleared; /* set to TRUE if line has been deleted */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
41 char_u qf_type; /* type of the error (mostly 'E'); 1 for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 :helpgrep */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
43 char_u qf_valid; /* valid error message detected */
7
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 * There is a stack of error lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #define LISTCOUNT 10
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
50 #define INVALID_QFIDX (-1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
52 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
53 * 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
54 * 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
55 * 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
56 *
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
57 * 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
58 * 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
59 * 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
60 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
61 typedef struct qf_list_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 {
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
63 int_u qf_id; /* Unique identifier for this list */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
64 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
65 qfline_T *qf_last; /* pointer to the last error */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
66 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
67 int qf_count; /* number of errors (0 means empty list) */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
68 int qf_index; /* current index in the error list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
69 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
70 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
71 * 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
72 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
73
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_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
75 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
76 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
77 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
78 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
79 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
80 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
81 long qf_changedtick;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
82 } qf_list_T;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
83
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
84 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
85 * 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
86 * 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
87 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
88 struct qf_info_S
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
89 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
90 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
91 * Count of references to this list. Used only for location lists.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
92 * When a location list window reference this list, qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
93 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
94 * reaches 0, the list is freed.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
95 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
96 int qf_refcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
97 int qf_listcount; /* current number of lists */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
98 int qf_curlist; /* current error list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
99 qf_list_T qf_lists[LISTCOUNT];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
100 };
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
101
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
102 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
103 static int_u last_qf_id = 0; /* Last used quickfix list id */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
105 #define FMT_PATTERNS 11 /* maximum number of % recognized */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 * Structure used to hold the info of one part of 'errorformat'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
110 typedef struct efm_S efm_T;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
111 struct efm_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 regprog_T *prog; /* pre-formatted part of 'errorformat' */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
114 efm_T *next; /* pointer to next (NULL if last) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 char_u prefix; /* prefix of this format line: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 /* 'D' enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 /* 'X' leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 /* 'A' start of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 /* 'E' error message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 /* 'W' warning message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 /* 'I' informational message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 /* 'C' continuation line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 /* 'Z' end of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 /* 'G' general, unspecific message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 /* 'P' push file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 /* 'Q' pop/quit file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 /* 'O' overread (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 char_u flags; /* additional flags given in prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 /* '-' do not include this line */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
131 /* '+' include whole line in message */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
132 int conthere; /* %> used */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
135 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
136
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
137 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);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
138 static void qf_new_list(qf_info_T *qi, char_u *qf_title);
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
139 static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname, char_u *module, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
140 static qf_info_T *ll_new_list(void);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
141 static void qf_free(qf_info_T *qi, int idx);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
142 static char_u *qf_types(int, int);
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
143 static int qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *, char_u *);
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
144 static char_u *qf_push_dir(char_u *, struct dir_stack_T **, int is_file_stack);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
145 static char_u *qf_pop_dir(struct dir_stack_T **);
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
146 static char_u *qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
147 static void qf_fmt_text(char_u *text, char_u *buf, int bufsize);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
148 static 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 static qf_info_T *ll_get_or_alloc_list(win_T *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
160 /* Quickfix window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
161 #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
162 /* Location list window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
163 #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
164 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
165 * Return location list for window 'wp'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
166 * For location list window, return the referenced location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
167 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
168 #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
169
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 /*
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
171 * 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
172 * 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
173 */
11447
698ee9d4fe9f patch 8.0.0607: after :bwipe + :new bufref might still be valid
Christian Brabandt <cb@256bit.org>
parents: 11445
diff changeset
174 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
175 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
176
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
177 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
178 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
179
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
180 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
181 * Read the errorfile "efile" into memory, line by line, building the error
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
182 * list. Set the error list's title to qf_title.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 * Return -1 for error, number of errors for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 int
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
186 qf_init(win_T *wp,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
187 char_u *efile,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
188 char_u *errorformat,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
189 int newlist, /* TRUE: start a new error list */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
190 char_u *qf_title,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
191 char_u *enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
193 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
194
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
195 if (wp != NULL)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
196 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
197 qi = ll_get_or_alloc_list(wp);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
198 if (qi == NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
199 return FAIL;
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
200 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
201
11700
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
202 return qf_init_ext(qi, qi->qf_curlist, efile, curbuf, NULL, errorformat,
dd821396754e patch 8.0.0733: can only add entries to one list in the quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11609
diff changeset
203 newlist, (linenr_T)0, (linenr_T)0, qf_title, enc);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
204 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
205
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
206 /*
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
207 * Maximum number of bytes allowed per line while reading a errorfile.
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
208 */
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
209 #define LINE_MAXLEN 4096
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
210
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
211 static struct fmtpattern
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
212 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
213 char_u convchar;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
214 char *pattern;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
215 } fmt_pat[FMT_PATTERNS] =
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
216 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
217 {'f', ".\\+"}, /* only used when at end */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
218 {'n', "\\d\\+"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
219 {'l', "\\d\\+"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
220 {'c', "\\d\\+"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
221 {'t', "."},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
222 {'m', ".\\+"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
223 {'r', ".*"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
224 {'p', "[- .]*"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
225 {'v', "\\d\\+"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
226 {'s', ".\\+"},
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
227 {'o', ".\\+"}
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
228 };
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
229
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
230 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
231 * 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
232 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
233 static int
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
234 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
235 char_u *efm,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
236 int len,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
237 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
238 char_u *regpat,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
239 char_u *errmsg)
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
240 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
241 char_u *ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
242 char_u *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
243 char_u *srcptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
244 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
245 int idx = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
246
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
247 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
248 * 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
249 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
250 ptr = regpat;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
251 *ptr++ = '^';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
252 round = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
253 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
254 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
255 if (*efmp == '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
256 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
257 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
258 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
259 if (fmt_pat[idx].convchar == *efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
260 break;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
261 if (idx < FMT_PATTERNS)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
262 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
263 if (fmt_ptr->addr[idx])
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
264 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
265 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
266 _("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
267 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
268 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
269 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
270 if ((idx
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
271 && idx < 6
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
272 && vim_strchr((char_u *)"DXOPQ",
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
273 fmt_ptr->prefix) != NULL)
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 *)"OPQ",
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 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
278 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
279 _("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
280 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
281 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
282 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
283 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
284 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
285 *ptr++ = '(';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
286 #ifdef BACKSLASH_IN_FILENAME
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
287 if (*efmp == 'f')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
288 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
289 /* 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
290 * checking for a colon next: "%f:".
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
291 * "\%(\a:\)\=" */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
292 STRCPY(ptr, "\\%(\\a:\\)\\=");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
293 ptr += 10;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
294 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
295 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
296 if (*efmp == 'f' && efmp[1] != NUL)
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 if (efmp[1] != '\\' && efmp[1] != '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
299 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
300 /* 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
301 * 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
302 * 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
303 * 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
304 * follows should work. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
305 STRCPY(ptr, ".\\{-1,}");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
306 ptr += 7;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
307 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
308 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
309 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
310 /* 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
311 * many file name chars as possible. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
312 STRCPY(ptr, "\\f\\+");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
313 ptr += 4;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
314 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
315 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
316 else
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 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
319 while ((*ptr = *srcptr++) != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
320 ++ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
321 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
322 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
323 *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 else if (*efmp == '*')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
326 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
327 if (*++efmp == '[' || *efmp == '\\')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
328 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
329 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
330 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
331 if (efmp[1] == '^')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
332 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
333 if (efmp < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
334 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
335 *ptr++ = *++efmp; /* could be ']' */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
336 while (efmp < efm + len
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
337 && (*ptr++ = *++efmp) != ']')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
338 /* skip */;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
339 if (efmp == efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
340 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
341 EMSG(_("E374: Missing ] in format string"));
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
342 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
343 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
344 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
345 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
346 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
347 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
348 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
349 *ptr++ = '+';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
350 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
351 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
352 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
353 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
354 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
355 _("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
356 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
357 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
358 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
359 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
360 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
361 *ptr++ = *efmp; /* regexp magic characters */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
362 else if (*efmp == '#')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
363 *ptr++ = '*';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
364 else if (*efmp == '>')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
365 fmt_ptr->conthere = TRUE;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
366 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
367 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
368 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
369 fmt_ptr->flags = *efmp++;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
370 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
371 fmt_ptr->prefix = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
372 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
373 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
374 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
375 _("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
376 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
377 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
378 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
379 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
380 else
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 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
383 _("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
384 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
385 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
386 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
387 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
388 else /* copy normal character */
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 if (*efmp == '\\' && efmp + 1 < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
391 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
392 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
393 *ptr++ = '\\'; /* escape regexp atoms */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
394 if (*efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
395 *ptr++ = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
396 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
397 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
398 *ptr++ = '$';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
399 *ptr = NUL;
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 return 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
402 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
403
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
404 static void
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
405 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
406 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
407 efm_T *efm_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
408
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
409 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
410 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
411 *efm_first = efm_ptr->next;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
412 vim_regfree(efm_ptr->prog);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
413 vim_free(efm_ptr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
414 }
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
415 fmt_start = NULL;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
416 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
417
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
418 /* Parse 'errorformat' option */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
419 static efm_T *
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
420 parse_efm_option(char_u *efm)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
421 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
422 char_u *errmsg = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
423 int errmsglen;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
424 efm_T *fmt_ptr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
425 efm_T *fmt_first = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
426 efm_T *fmt_last = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
427 char_u *fmtstr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
428 int len;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
429 int i;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
430 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
431
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
432 errmsglen = CMDBUFFSIZE + 1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
433 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
434 if (errmsg == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
435 goto parse_efm_end;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
436
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
437 /*
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
438 * 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
439 * 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
440 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
441
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
442 /*
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
443 * 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
444 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
445 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
446 for (round = FMT_PATTERNS; round > 0; )
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
447 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
448 #ifdef BACKSLASH_IN_FILENAME
c7164578e508 patch 8.0.1144: using wrong #ifdef for computing length
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
449 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
450 #else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
451 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
452 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
453 if ((fmtstr = alloc(i)) == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
454 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
455
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
456 while (efm[0] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
457 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
458 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
459 * 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
460 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
461 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
462 if (fmt_ptr == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
463 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
464 if (fmt_first == NULL) /* first one */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
465 fmt_first = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
466 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
467 fmt_last->next = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
468 fmt_last = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
469
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
470 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
471 * 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
472 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
473 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
474 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
475 ++len;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
476
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
477 if (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
478 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
479 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
480 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
481 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
482 * Advance to next part
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
483 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
484 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
485 }
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 if (fmt_first == NULL) /* nothing found */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
488 EMSG(_("E378: 'errorformat' contains no pattern"));
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 goto parse_efm_end;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
491
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
492 parse_efm_error:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
493 free_efm_list(&fmt_first);
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_end:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
496 vim_free(fmtstr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
497 vim_free(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
498
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
499 return fmt_first;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
500 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
501
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
502 enum {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
503 QF_FAIL = 0,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
504 QF_OK = 1,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
505 QF_END_OF_INPUT = 2,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
506 QF_NOMEM = 3,
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
507 QF_IGNORE_LINE = 4,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
508 QF_MULTISCAN = 5,
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
509 };
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
510
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
511 typedef struct {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
512 char_u *linebuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
513 int linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
514 char_u *growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
515 int growbufsiz;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
516 FILE *fd;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
517 typval_T *tv;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
518 char_u *p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
519 listitem_T *p_li;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
520 buf_T *buf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
521 linenr_T buflnum;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
522 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
523 vimconv_T vc;
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
524 } qfstate_T;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
525
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
526 static char_u *
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
527 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
528 {
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
529 char_u *p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
530
9531
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 {
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
545 if ((p = vim_realloc(state->growbuf, state->linelen + 1)) == NULL)
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
546 return NULL;
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
547 state->growbuf = p;
9531
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 {
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
702 char_u *p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
703
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
704 if (fgets((char *)state->growbuf + growbuflen,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
705 state->growbufsiz - growbuflen, state->fd) == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
706 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
707 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
708 growbuflen += state->linelen;
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
709 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
710 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
711 if (state->growbufsiz == LINE_MAXLEN)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
712 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
713 discard = TRUE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
714 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
715 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
716
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
717 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
718 ? 2 * state->growbufsiz : LINE_MAXLEN;
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
719 if ((p = vim_realloc(state->growbuf, state->growbufsiz)) == NULL)
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
720 return QF_NOMEM;
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
721 state->growbuf = p;
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
722 }
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 while (discard)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
725 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
726 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
727 * 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
728 * 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
729 * reached.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
730 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
731 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
732 || (int)STRLEN(IObuff) < IOSIZE - 1
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
733 || IObuff[IOSIZE - 1] == '\n')
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
734 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
735 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
736
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
737 state->linebuf = state->growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
738 state->linelen = growbuflen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
739 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
740 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
741 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
742
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
743 #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
744 /* 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
745 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
746 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
747 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
748
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
749 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
750 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
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 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
753 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
754 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
755 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
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 else
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
758 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
759 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
760 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
761 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
762 ? 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
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 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
765 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
766 #endif
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
767
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
768 return QF_OK;
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
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 * 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
773 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
774 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
775 qf_get_nextline(qfstate_T *state)
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 int status = QF_FAIL;
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->fd == 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 != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
782 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
783 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
784 /* 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
785 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
786 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
787 /* 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
788 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
789 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
790 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
791 /* 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
792 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
793 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
794 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
795 /* 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
796 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
797
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
798 if (status != QF_OK)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
799 return status;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
800
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
801 /* remove newline/CR from the line */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
802 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
803 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
804 state->linebuf[state->linelen - 1] = NUL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
805 #ifdef USE_CRNL
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
806 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
807 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
808 #endif
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
809 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
810
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
811 #ifdef FEAT_MBYTE
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
812 remove_bom(state->linebuf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
813 #endif
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 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
816 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
817
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
818 typedef struct {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
819 char_u *namebuf;
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
820 char_u *module;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
821 char_u *errmsg;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
822 int errmsglen;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
823 long lnum;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
824 int col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
825 char_u use_viscol;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
826 char_u *pattern;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
827 int enr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
828 int type;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
829 int valid;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
830 } qffields_T;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
831
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
832 /*
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
833 * Parse the error format matches in 'regmatch' and set the values in 'fields'.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
834 * fmt_ptr contains the 'efm' format specifiers/prefixes that have a match.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
835 * Returns QF_OK if all the matches are successfully parsed. On failure,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
836 * returns QF_FAIL or QF_NOMEM.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
837 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
838 static int
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
839 qf_parse_match(
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
840 char_u *linebuf,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
841 int linelen,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
842 efm_T *fmt_ptr,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
843 regmatch_T *regmatch,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
844 qffields_T *fields,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
845 int qf_multiline,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
846 int qf_multiscan,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
847 char_u **tail)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
848 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
849 char_u *p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
850 int idx = fmt_ptr->prefix;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
851 int i;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
852 int len;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
853
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
854 if ((idx == 'C' || idx == 'Z') && !qf_multiline)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
855 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
856 if (vim_strchr((char_u *)"EWI", idx) != NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
857 fields->type = idx;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
858 else
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
859 fields->type = 0;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
860 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
861 * Extract error message data from matched line.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
862 * We check for an actual submatch, because "\[" and "\]" in
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
863 * the 'errorformat' may cause the wrong submatch to be used.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
864 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
865 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
866 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
867 int c;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
869 if (regmatch->startp[i] == NULL || regmatch->endp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
870 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
871
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
872 /* Expand ~/file and $HOME/file to full path. */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
873 c = *regmatch->endp[i];
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
874 *regmatch->endp[i] = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
875 expand_env(regmatch->startp[i], fields->namebuf, CMDBUFFSIZE);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
876 *regmatch->endp[i] = c;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
877
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
878 if (vim_strchr((char_u *)"OPQ", idx) != NULL
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
879 && mch_getperm(fields->namebuf) == -1)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
880 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
881 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
882 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
883 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
884 if (regmatch->startp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
885 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
886 fields->enr = (int)atol((char *)regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
887 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
888 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
889 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
890 if (regmatch->startp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
891 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
892 fields->lnum = atol((char *)regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
893 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
894 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
895 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
896 if (regmatch->startp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
897 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
898 fields->col = (int)atol((char *)regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
899 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
900 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
901 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
902 if (regmatch->startp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
903 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
904 fields->type = *regmatch->startp[i];
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
905 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
906 if (fmt_ptr->flags == '+' && !qf_multiscan) /* %+ */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
907 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
908 if (linelen >= fields->errmsglen)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
909 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
910 /* linelen + null terminator */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
911 if ((p = vim_realloc(fields->errmsg, linelen + 1)) == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
912 return QF_NOMEM;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
913 fields->errmsg = p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
914 fields->errmsglen = linelen + 1;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
915 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
916 vim_strncpy(fields->errmsg, linebuf, linelen);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
917 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
918 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
919 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
920 if (regmatch->startp[i] == NULL || regmatch->endp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
921 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
922 len = (int)(regmatch->endp[i] - regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
923 if (len >= fields->errmsglen)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
924 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
925 /* len + null terminator */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
926 if ((p = vim_realloc(fields->errmsg, len + 1)) == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
927 return QF_NOMEM;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
928 fields->errmsg = p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
929 fields->errmsglen = len + 1;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
930 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
931 vim_strncpy(fields->errmsg, regmatch->startp[i], len);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
932 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
933 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
934 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
935 if (regmatch->startp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
936 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
937 *tail = regmatch->startp[i];
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
938 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
939 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
940 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
941 char_u *match_ptr;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
942
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
943 if (regmatch->startp[i] == NULL || regmatch->endp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
944 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
945 fields->col = 0;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
946 for (match_ptr = regmatch->startp[i];
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
947 match_ptr != regmatch->endp[i]; ++match_ptr)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
948 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
949 ++fields->col;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
950 if (*match_ptr == TAB)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
951 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
952 fields->col += 7;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
953 fields->col -= fields->col % 8;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
954 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
955 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
956 ++fields->col;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
957 fields->use_viscol = TRUE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
958 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
959 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
960 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
961 if (regmatch->startp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
962 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
963 fields->col = (int)atol((char *)regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
964 fields->use_viscol = TRUE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
965 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
966 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
967 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
968 if (regmatch->startp[i] == NULL || regmatch->endp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
969 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
970 len = (int)(regmatch->endp[i] - regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
971 if (len > CMDBUFFSIZE - 5)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
972 len = CMDBUFFSIZE - 5;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
973 STRCPY(fields->pattern, "^\\V");
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
974 STRNCAT(fields->pattern, regmatch->startp[i], len);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
975 fields->pattern[len + 3] = '\\';
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
976 fields->pattern[len + 4] = '$';
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
977 fields->pattern[len + 5] = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
978 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
979 if ((i = (int)fmt_ptr->addr[10]) > 0) /* %o */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
980 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
981 if (regmatch->startp[i] == NULL || regmatch->endp[i] == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
982 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
983 len = (int)(regmatch->endp[i] - regmatch->startp[i]);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
984 if (len > CMDBUFFSIZE)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
985 len = CMDBUFFSIZE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
986 STRNCAT(fields->module, regmatch->startp[i], len);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
987 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
988
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
989 return QF_OK;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
990 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
991
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
992 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
993 * Parse an error line in 'linebuf' using a single error format string in
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
994 * 'fmt_ptr->prog' and return the matching values in 'fields'.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
995 * Returns QF_OK if the efm format matches completely and the fields are
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
996 * successfully copied. Otherwise returns QF_FAIL or QF_NOMEM.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
997 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
998 static int
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
999 qf_parse_get_fields(
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1000 char_u *linebuf,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1001 int linelen,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1002 efm_T *fmt_ptr,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1003 qffields_T *fields,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1004 int qf_multiline,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1005 int qf_multiscan,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1006 char_u **tail)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1007 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1008 regmatch_T regmatch;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1009 int status = QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1010 int r;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1011
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1012 if (qf_multiscan &&
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1013 vim_strchr((char_u *)"OPQ", fmt_ptr->prefix) == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1014 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1015
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1016 fields->namebuf[0] = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1017 fields->module[0] = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1018 fields->pattern[0] = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1019 if (!qf_multiscan)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1020 fields->errmsg[0] = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1021 fields->lnum = 0;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1022 fields->col = 0;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1023 fields->use_viscol = FALSE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1024 fields->enr = -1;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1025 fields->type = 0;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1026 *tail = NULL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1027
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1028 /* Always ignore case when looking for a matching error. */
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1029 regmatch.rm_ic = TRUE;
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1030 regmatch.regprog = fmt_ptr->prog;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1031 r = vim_regexec(&regmatch, linebuf, (colnr_T)0);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1032 fmt_ptr->prog = regmatch.regprog;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1033 if (r)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1034 status = qf_parse_match(linebuf, linelen, fmt_ptr, &regmatch,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1035 fields, qf_multiline, qf_multiscan, tail);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1036
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1037 return status;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1038 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1039
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1040 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1041 * Parse directory error format prefixes (%D and %X).
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1042 * Push and pop directories from the directory stack when scanning directory
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1043 * names.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1044 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1045 static int
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1046 qf_parse_dir_pfx(int idx, qffields_T *fields, qf_list_T *qfl)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1047 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1048 if (idx == 'D') /* enter directory */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1049 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1050 if (*fields->namebuf == NUL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1051 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1052 EMSG(_("E379: Missing or empty directory name"));
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1053 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1054 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1055 qfl->qf_directory =
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1056 qf_push_dir(fields->namebuf, &qfl->qf_dir_stack, FALSE);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1057 if (qfl->qf_directory == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1058 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1059 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1060 else if (idx == 'X') /* leave directory */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1061 qfl->qf_directory = qf_pop_dir(&qfl->qf_dir_stack);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1062
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1063 return QF_OK;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1064 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1065
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1066 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1067 * Parse global file name error format prefixes (%O, %P and %Q).
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1068 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1069 static int
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1070 qf_parse_file_pfx(
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1071 int idx,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1072 qffields_T *fields,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1073 qf_list_T *qfl,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1074 char_u *tail)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1075 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1076 fields->valid = FALSE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1077 if (*fields->namebuf == NUL || mch_getperm(fields->namebuf) >= 0)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1078 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1079 if (*fields->namebuf && idx == 'P')
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1080 qfl->qf_currfile =
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1081 qf_push_dir(fields->namebuf, &qfl->qf_file_stack, TRUE);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1082 else if (idx == 'Q')
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1083 qfl->qf_currfile = qf_pop_dir(&qfl->qf_file_stack);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1084 *fields->namebuf = NUL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1085 if (tail && *tail)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1086 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1087 STRMOVE(IObuff, skipwhite(tail));
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1088 qfl->qf_multiscan = TRUE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1089 return QF_MULTISCAN;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1090 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1091 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1092
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1093 return QF_OK;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1094 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1095
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1096 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1097 * Parse a non-error line (a line which doesn't match any of the error
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1098 * format in 'efm').
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1099 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1100 static int
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1101 qf_parse_line_nomatch(char_u *linebuf, int linelen, qffields_T *fields)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1102 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1103 char_u *p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1104
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1105 fields->namebuf[0] = NUL; /* no match found, remove file name */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1106 fields->lnum = 0; /* don't jump to this line */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1107 fields->valid = FALSE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1108 if (linelen >= fields->errmsglen)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1109 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1110 /* linelen + null terminator */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1111 if ((p = vim_realloc(fields->errmsg, linelen + 1)) == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1112 return QF_NOMEM;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1113 fields->errmsg = p;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1114 fields->errmsglen = linelen + 1;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1115 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1116 /* copy whole line to error message */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1117 vim_strncpy(fields->errmsg, linebuf, linelen);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1118
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1119 return QF_OK;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1120 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1121
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1122 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1123 * Parse multi-line error format prefixes (%C and %Z)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1124 */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1125 static int
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1126 qf_parse_multiline_pfx(
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1127 qf_info_T *qi,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1128 int qf_idx,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1129 int idx,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1130 qf_list_T *qfl,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1131 qffields_T *fields)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1132 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1133 char_u *ptr;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1134 int len;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1135
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1136 if (!qfl->qf_multiignore)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1137 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1138 qfline_T *qfprev = qfl->qf_last;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1139
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1140 if (qfprev == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1141 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1142 if (*fields->errmsg && !qfl->qf_multiignore)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1143 {
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1144 len = (int)STRLEN(qfprev->qf_text);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1145 if ((ptr = alloc((unsigned)(len + STRLEN(fields->errmsg) + 2)))
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1146 == NULL)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1147 return QF_FAIL;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1148 STRCPY(ptr, qfprev->qf_text);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1149 vim_free(qfprev->qf_text);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1150 qfprev->qf_text = ptr;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1151 *(ptr += len) = '\n';
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1152 STRCPY(++ptr, fields->errmsg);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1153 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1154 if (qfprev->qf_nr == -1)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1155 qfprev->qf_nr = fields->enr;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1156 if (vim_isprintc(fields->type) && !qfprev->qf_type)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1157 /* only printable chars allowed */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1158 qfprev->qf_type = fields->type;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1159
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1160 if (!qfprev->qf_lnum)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1161 qfprev->qf_lnum = fields->lnum;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1162 if (!qfprev->qf_col)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1163 qfprev->qf_col = fields->col;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1164 qfprev->qf_viscol = fields->use_viscol;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1165 if (!qfprev->qf_fnum)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1166 qfprev->qf_fnum = qf_get_fnum(qi, qf_idx,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1167 qfl->qf_directory,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1168 *fields->namebuf || qfl->qf_directory != NULL
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1169 ? fields->namebuf
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1170 : qfl->qf_currfile != NULL && fields->valid
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1171 ? qfl->qf_currfile : 0);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1172 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1173 if (idx == 'Z')
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1174 qfl->qf_multiline = qfl->qf_multiignore = FALSE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1175 line_breakcheck();
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1176
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1177 return QF_IGNORE_LINE;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1178 }
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1179
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1180 /*
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1181 * 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
1182 * Return the QF_ status.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1183 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1184 static int
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1185 qf_parse_line(
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1186 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
1187 int qf_idx,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1188 char_u *linebuf,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1189 int linelen,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1190 efm_T *fmt_first,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1191 qffields_T *fields)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1192 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1193 efm_T *fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1194 int idx = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1195 char_u *tail = 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
1196 qf_list_T *qfl = &qi->qf_lists[qf_idx];
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1197 int status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1198
13612
89223f5d5d12 patch 8.0.1678: errorformat "%r" implies "%>"
Christian Brabandt <cb@256bit.org>
parents: 13594
diff changeset
1199 restofline:
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1200 /* 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
1201 if (fmt_start == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1202 fmt_ptr = fmt_first;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1203 else
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1204 {
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1205 /* Otherwise start from the last used pattern */
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1206 fmt_ptr = fmt_start;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1207 fmt_start = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1208 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1209
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1210 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1211 * 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
1212 * match or no match.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1213 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1214 fields->valid = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1215 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
1216 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1217 idx = fmt_ptr->prefix;
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1218 status = qf_parse_get_fields(linebuf, linelen, fmt_ptr, fields,
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1219 qfl->qf_multiline, qfl->qf_multiscan, &tail);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1220 if (status == QF_NOMEM)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1221 return status;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1222 if (status == QF_OK)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1223 break;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1224 }
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
1225 qfl->qf_multiscan = FALSE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1226
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1227 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
1228 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1229 if (fmt_ptr != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1230 {
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1231 /* 'D' and 'X' directory specifiers */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1232 status = qf_parse_dir_pfx(idx, fields, qfl);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1233 if (status != QF_OK)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1234 return status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1235 }
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1236
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1237 status = qf_parse_line_nomatch(linebuf, linelen, fields);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1238 if (status != QF_OK)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1239 return status;
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1240
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1241 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
1242 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
1243 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1244 else if (fmt_ptr != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1245 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1246 /* honor %> item */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1247 if (fmt_ptr->conthere)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1248 fmt_start = fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1249
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1250 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
1251 {
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
1252 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
1253 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
1254 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1255 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
1256 { /* continuation of multi-line msg */
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1257 status = qf_parse_multiline_pfx(qi, qf_idx, idx, qfl, fields);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1258 if (status != QF_OK)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1259 return status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1260 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1261 else if (vim_strchr((char_u *)"OPQ", idx) != NULL)
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1262 { /* global file names */
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1263 status = qf_parse_file_pfx(idx, fields, qfl, tail);
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1264 if (status == QF_MULTISCAN)
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1265 goto restofline;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1266 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1267 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
1268 {
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
1269 if (qfl->qf_multiline)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1270 /* 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
1271 qfl->qf_multiignore = TRUE;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1272 return QF_IGNORE_LINE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1273 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1274 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1275
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1276 return QF_OK;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1277 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1278
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
1279 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1280 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1281 * list.
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1282 * 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
1283 * 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
1284 * 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
1285 * 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
1286 * Set the title of the list to "qf_title".
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1287 * Return -1 for error, number of errors for success.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1288 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1289 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1290 qf_init_ext(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1291 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
1292 int qf_idx,
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1293 char_u *efile,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1294 buf_T *buf,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1295 typval_T *tv,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1296 char_u *errorformat,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1297 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
1298 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
1299 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
1300 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
1301 char_u *enc)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1302 {
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
1303 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
1304 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
1305 qffields_T fields;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1306 qfline_T *old_last = NULL;
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1307 int adding = FALSE;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1308 static efm_T *fmt_first = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 char_u *efm;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1310 static char_u *last_efm = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 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
1312 int status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1313
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1314 /* Do not used the cached buffer, it may have been wiped out. */
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13115
diff changeset
1315 VIM_CLEAR(qf_last_bufname);
11443
30b3775addb2 patch 8.0.0605: the quickfix cached buffer may become invalid
Christian Brabandt <cb@256bit.org>
parents: 11426
diff changeset
1316
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1317 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
1318 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
1319 #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
1320 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
1321 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
1322 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
1323 #endif
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1324 fields.namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf);
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1325 fields.module = alloc_id(CMDBUFFSIZE + 1, aid_qf_module);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1326 fields.errmsglen = CMDBUFFSIZE + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1327 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
1328 fields.pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern);
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
1329 if (fields.namebuf == NULL || fields.errmsg == NULL
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1330 || fields.pattern == NULL || fields.module == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1333 if (efile != NULL && (state.fd = mch_fopen((char *)efile, "r")) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 EMSG2(_(e_openerrf), efile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338
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
1339 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
1340 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
1342 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
1343 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
1344 }
11609
6f11697fb92c patch 8.0.0687: minor issues related to quickfix
Christian Brabandt <cb@256bit.org>
parents: 11589
diff changeset
1345 else
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1346 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1347 /* 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
1348 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
1349 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
1350 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
1351 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352
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
1353 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
1354
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 /* Use the local value of 'errorformat' if it's set. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1356 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1357 efm = buf->b_p_efm;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 efm = errorformat;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1360
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1361 /*
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1362 * 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
1363 * previously parsed values.
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1364 */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1365 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
1366 {
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1367 /* free the previously parsed data */
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13115
diff changeset
1368 VIM_CLEAR(last_efm);
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1369 free_efm_list(&fmt_first);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1370
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1371 /* parse the current 'efm' */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1372 fmt_first = parse_efm_option(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1373 if (fmt_first != NULL)
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1374 last_efm = vim_strsave(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1375 }
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1376
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1377 if (fmt_first == NULL) /* nothing found */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 * got_int is reset here, because it was probably set when killing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 * ":make" command, but we still want to read the errorfile then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1386 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1387 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1388 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
1389 state.p_str = tv->vval.v_string;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1390 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
1391 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
1392 state.tv = tv;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1393 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1394 state.buf = buf;
9534
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1395 state.buflnum = lnumfirst;
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1396 state.lnumlast = lnumlast;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1397
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 * Read the lines in the error file one by one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 * Try to recognize one of the error formats in each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1402 while (!got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1404 /* 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
1405 status = qf_get_nextline(&state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1406 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
1407 goto qf_init_end;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1408 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
1409 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410
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
1411 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
1412 fmt_first, &fields);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1413 if (status == QF_FAIL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1414 goto error2;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1415 if (status == QF_NOMEM)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1416 goto qf_init_end;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1417 if (status == QF_IGNORE_LINE)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1418 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1420 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
1421 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
1422 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
1423 (*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
1424 ? 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
1425 : ((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
1426 ? qfl->qf_currfile : (char_u *)NULL),
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1427 fields.module,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1428 0,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1429 fields.errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1430 fields.lnum,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1431 fields.col,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1432 fields.use_viscol,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1433 fields.pattern,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1434 fields.enr,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1435 fields.type,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1436 fields.valid) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1440 if (state.fd == NULL || !ferror(state.fd))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 {
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
1442 if (qfl->qf_index == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1444 /* 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
1445 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
1446 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
1447 qfl->qf_nonevalid = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 {
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
1451 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
1452 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
1453 qfl->qf_ptr = qfl->qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1455 /* 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
1456 retval = qfl->qf_count;
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1457 goto qf_init_end;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 EMSG(_(e_readerrf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 error2:
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1461 if (!adding)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1462 {
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
1463 /* 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
1464 qf_free(qi, qi->qf_curlist);
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1465 qi->qf_listcount--;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1466 if (qi->qf_curlist > 0)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1467 --qi->qf_curlist;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1468 }
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1469 qf_init_end:
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1470 if (state.fd != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1471 fclose(state.fd);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1472 vim_free(fields.namebuf);
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1473 vim_free(fields.module);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1474 vim_free(fields.errmsg);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1475 vim_free(fields.pattern);
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1476 vim_free(state.growbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477
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
1478 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
1479 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
1480 #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
1481 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
1482 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
1483 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1488 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1489 * Set the title of the specified quickfix list. Frees the previous title.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1490 * Prepends ':' to the title.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1491 */
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1492 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
1493 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
1494 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13115
diff changeset
1495 VIM_CLEAR(qi->qf_lists[qf_idx].qf_title);
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1496
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1497 if (title != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1498 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1499 char_u *p = alloc((int)STRLEN(title) + 2);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1500
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1501 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
1502 if (p != NULL)
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1503 STRCPY(p, title);
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1504 }
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1505 }
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1506
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1507 /*
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1508 * The title of a quickfix/location list is set, by default, to the command
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1509 * that created the quickfix list with the ":" prefix.
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1510 * Create a quickfix list title string by prepending ":" to a user command.
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1511 * Returns a pointer to a static buffer with the title.
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1512 */
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1513 static char_u *
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1514 qf_cmdtitle(char_u *cmd)
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1515 {
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1516 static char_u qftitle_str[IOSIZE];
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1517
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1518 vim_snprintf((char *)qftitle_str, IOSIZE, ":%s", (char *)cmd);
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
1519 return qftitle_str;
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1520 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1521
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 /*
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
1523 * 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
1524 * 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
1525 * the new list is added.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1528 qf_new_list(qf_info_T *qi, char_u *qf_title)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 /*
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1533 * If the current entry is not the last entry, delete entries beyond
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 * the current entry. This makes it possible to browse in a tree-like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 * way with ":grep'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1537 while (qi->qf_listcount > qi->qf_curlist + 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1538 qf_free(qi, --qi->qf_listcount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 * When the stack is full, remove to oldest entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 * Otherwise, add a new entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1544 if (qi->qf_listcount == LISTCOUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1546 qf_free(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 for (i = 1; i < LISTCOUNT; ++i)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1548 qi->qf_lists[i - 1] = qi->qf_lists[i];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1549 qi->qf_curlist = LISTCOUNT - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 else
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1552 qi->qf_curlist = qi->qf_listcount++;
3259
9eb7fdfb5e63 updated for version 7.3.398
Bram Moolenaar <bram@vim.org>
parents: 3257
diff changeset
1553 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
1554 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
1555 qi->qf_lists[qi->qf_curlist].qf_id = ++last_qf_id;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1558 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1559 * Free a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1560 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1561 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1562 ll_free_all(qf_info_T **pqi)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1563 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1564 int i;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1565 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1566
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1567 qi = *pqi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1568 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1569 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1570 *pqi = NULL; /* Remove reference to this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1571
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1572 qi->qf_refcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1573 if (qi->qf_refcount < 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1574 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1575 /* No references to this location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1576 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1577 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1578 vim_free(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1579 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1580 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1581
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1582 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1583 * Free all the quickfix/location lists in the stack.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
1584 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1585 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1586 qf_free_all(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1587 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1588 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1589 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1590
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1591 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1592 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1593 /* location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1594 ll_free_all(&wp->w_llist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1595 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1596 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1597 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1598 /* quickfix list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1599 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1600 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1601 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1602
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 * Add an entry to the end of the list of errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1608 qf_add_entry(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1609 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
1610 int qf_idx, /* list index */
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1611 char_u *dir, /* optional directory name */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1612 char_u *fname, /* file name or NULL */
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1613 char_u *module, /* module name or NULL */
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1614 int bufnum, /* buffer number or zero */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1615 char_u *mesg, /* message */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1616 long lnum, /* line number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1617 int col, /* column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1618 int vis_col, /* using visual column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1619 char_u *pattern, /* search pattern */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1620 int nr, /* error number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1621 int type, /* type character */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1622 int valid) /* valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1624 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1625 qfline_T **lastp; /* pointer to qf_last or NULL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1627 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 return FAIL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1629 if (bufnum != 0)
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1630 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1631 buf_T *buf = buflist_findnr(bufnum);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1632
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1633 qfp->qf_fnum = bufnum;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1634 if (buf != NULL)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1635 buf->b_has_qf_entry |=
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1636 (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
1637 }
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1638 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
1639 qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 vim_free(qfp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 qfp->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 qfp->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
1647 qfp->qf_viscol = vis_col;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1648 if (pattern == NULL || *pattern == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1649 qfp->qf_pattern = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1650 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1651 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1652 vim_free(qfp->qf_text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1653 vim_free(qfp);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1654 return FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1655 }
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1656 if (module == NULL || *module == NUL)
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1657 qfp->qf_module = NULL;
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1658 else if ((qfp->qf_module = vim_strsave(module)) == NULL)
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1659 {
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1660 vim_free(qfp->qf_text);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1661 vim_free(qfp->qf_pattern);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1662 vim_free(qfp);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1663 return FAIL;
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1664 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 qfp->qf_nr = nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 qfp->qf_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 qfp->qf_valid = valid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1671 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
1672 if (qi->qf_lists[qf_idx].qf_count == 0)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1673 /* first element in the list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1675 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
1676 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
1677 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
1678 qfp->qf_prev = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1682 qfp->qf_prev = *lastp;
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1683 (*lastp)->qf_next = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 }
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1685 qfp->qf_next = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 qfp->qf_cleared = FALSE;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1687 *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
1688 ++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
1689 if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1690 /* first valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
1692 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
1693 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
1694 qi->qf_lists[qf_idx].qf_ptr = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 /*
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1701 * Allocate a new location list
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1702 */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1703 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1704 ll_new_list(void)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1705 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1706 qf_info_T *qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1707
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1708 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1709 if (qi != NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1710 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1711 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1712 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1713 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1714
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1715 return qi;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1716 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1717
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1718 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1719 * Return the location list for window 'wp'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1720 * If not present, allocate a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1721 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1722 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1723 ll_get_or_alloc_list(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1724 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1725 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1726 /* For a location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1727 return wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1728
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1729 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1730 * 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
1731 * location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1732 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1733 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1734
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1735 if (wp->w_llist == NULL)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1736 wp->w_llist = ll_new_list(); /* new location list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1737 return wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1738 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1739
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1740 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1741 * Copy the location list from window "from" to window "to".
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1742 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1743 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1744 copy_loclist(win_T *from, win_T *to)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1745 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1746 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1747 int idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1748 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1749
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1750 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1751 * When copying from a location list window, copy the referenced
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1752 * location list. For other windows, copy the location list for
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1753 * that window.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1754 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1755 if (IS_LL_WINDOW(from))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1756 qi = from->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1757 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1758 qi = from->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1759
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1760 if (qi == NULL) /* no location list to copy */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1761 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1762
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1763 /* allocate a new location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1764 if ((to->w_llist = ll_new_list()) == NULL)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1765 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1766
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1767 to->w_llist->qf_listcount = qi->qf_listcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1768
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1769 /* Copy the location lists one at a time */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1770 for (idx = 0; idx < qi->qf_listcount; idx++)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1771 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1772 qf_list_T *from_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1773 qf_list_T *to_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1774
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1775 to->w_llist->qf_curlist = idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1776
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1777 from_qfl = &qi->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1778 to_qfl = &to->w_llist->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1779
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1780 /* Some of the fields are populated by qf_add_entry() */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1781 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1782 to_qfl->qf_count = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1783 to_qfl->qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1784 to_qfl->qf_start = NULL;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1785 to_qfl->qf_last = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1786 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
1787 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
1788 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
1789 else
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1790 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
1791 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
1792 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1793 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
1794 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
1795 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
1796 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1797 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1798 to_qfl->qf_ctx = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1799
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1800 if (from_qfl->qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1801 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1802 qfline_T *from_qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1803 qfline_T *prevp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1804
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1805 /* 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
1806 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
1807 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
1808 ++i, from_qfp = from_qfp->qf_next)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1809 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1810 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
1811 to->w_llist->qf_curlist,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1812 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1813 NULL,
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
1814 from_qfp->qf_module,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1815 0,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1816 from_qfp->qf_text,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1817 from_qfp->qf_lnum,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1818 from_qfp->qf_col,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1819 from_qfp->qf_viscol,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1820 from_qfp->qf_pattern,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1821 from_qfp->qf_nr,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1822 0,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1823 from_qfp->qf_valid) == FAIL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1824 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1825 qf_free_all(to);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1826 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1827 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1828 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1829 * qf_add_entry() will not set the qf_num field, as the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1830 * directory and file names are not supplied. So the qf_fnum
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1831 * field is copied here.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1832 */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1833 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
1834 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1835 prevp->qf_type = from_qfp->qf_type; /* error type */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1836 if (from_qfl->qf_ptr == from_qfp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1837 to_qfl->qf_ptr = prevp; /* current location */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1838 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1839 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1840
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1841 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1842
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
1843 /* 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
1844 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
1845 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
1846
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1847 /* When no valid entries are present in the list, qf_ptr points to
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1848 * the first item in the list */
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
1849 if (to_qfl->qf_nonevalid)
5060
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1850 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1851 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
1852 to_qfl->qf_index = 1;
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1853 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1854 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1855
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1856 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1857 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1858
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1859 /*
10379
73e2a7abe2a3 commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents: 10369
diff changeset
1860 * 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
1861 * Also sets the b_has_qf_entry flag.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 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
1864 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
1865 {
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1866 char_u *ptr = NULL;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1867 buf_T *buf;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1868 char_u *bufname;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1869
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 if (fname == NULL || *fname == NUL) /* no file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1873 #ifdef VMS
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1874 vms_remove_version(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1875 #endif
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1876 #ifdef BACKSLASH_IN_FILENAME
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1877 if (directory != NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1878 slash_adjust(directory);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1879 slash_adjust(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1880 #endif
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1881 if (directory != NULL && !vim_isAbsName(fname)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1882 && (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
1883 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1884 /*
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1885 * 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
1886 * 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
1887 * "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
1888 * directory change.
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1889 */
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1890 if (mch_getperm(ptr) < 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 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
1893 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
1894 if (directory)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1895 ptr = concat_fnames(directory, fname, TRUE);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1896 else
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1897 ptr = vim_strsave(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1899 /* 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
1900 bufname = ptr;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1901 }
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1902 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1903 bufname = fname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1904
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1905 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
1906 && bufref_valid(&qf_last_bufref))
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1907 {
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1908 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
1909 vim_free(ptr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1911 else
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1912 {
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1913 vim_free(qf_last_bufname);
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1914 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
1915 if (bufname == ptr)
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1916 qf_last_bufname = bufname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1917 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1918 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
1919 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
1920 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1921 if (buf == NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1922 return 0;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1923
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1924 buf->b_has_qf_entry =
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1925 (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
1926 return buf->b_fnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 /*
9334
674f9e3ccd1a commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents: 9201
diff changeset
1930 * 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
1931 * NULL on error.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 static char_u *
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1934 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
1935 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 struct dir_stack_T *ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 /* allocate new stack element and hook it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 ds_new->next = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 *stackptr = ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 /* store directory on the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 if (vim_isAbsName(dirbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 || (*stackptr)->next == NULL
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1950 || (*stackptr && is_file_stack))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 /* Okay we don't have an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 * dirbuf must be a subdir of one of the directories on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 * Let's search...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 ds_new = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 (*stackptr)->dirname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 while (ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 if (mch_isdir((*stackptr)->dirname) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 ds_new = ds_new->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 while ((*stackptr)->next != ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 ds_ptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 (*stackptr)->next = (*stackptr)->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 /* Nothing found -> it must be on top level */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 if ((*stackptr)->dirname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 return (*stackptr)->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 * pop dirbuf from the directory stack and return previous directory or NULL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 * stack is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2004 qf_pop_dir(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 /* TODO: Should we check if dirbuf is the directory on top of the stack?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 * What to do if it isn't? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 /* pop top element and free it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 if (*stackptr != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 /* return NEW top element as current dir or NULL if stack is empty*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 return *stackptr ? (*stackptr)->dirname : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 * clean up directory stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2028 qf_clean_dir_stack(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 while ((ds_ptr = *stackptr) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 * Check in which directory of the directory stack the given file can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 * found.
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2043 * Returns a pointer to the directory name or NULL if not found.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 * Cleans up intermediate directory entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 * TODO: How to solve the following problem?
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2047 * If we have this directory tree:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 * ./
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 * ./aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 * ./aa/bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 * ./bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 * ./bb/x.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 * and make says:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 * making all in aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 * making all in bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 * x.c:9: Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 * 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
2058 * qf_guess_filepath will return NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 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
2061 qf_guess_filepath(qf_info_T *qi, int qf_idx, char_u *filename)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 struct dir_stack_T *ds_tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 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
2066 qf_list_T *qfl = &qi->qf_lists[qf_idx];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 /* 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
2069 if (qfl->qf_dir_stack == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071
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
2072 ds_ptr = qfl->qf_dir_stack->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 fullname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 while (ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 /* If concat_fnames failed, just go on. The worst thing that can happen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 * is that we delete the entire stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 if ((fullname != NULL) && (mch_getperm(fullname) >= 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 ds_ptr = ds_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 /* 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
2091 while (qfl->qf_dir_stack->next != ds_ptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 {
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
2093 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
2094 qfl->qf_dir_stack->next = qfl->qf_dir_stack->next->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 vim_free(ds_tmp->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 vim_free(ds_tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2099 return ds_ptr == NULL ? NULL : ds_ptr->dirname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 /*
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2103 * 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
2104 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2105 static int
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2106 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
2107 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2108 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
2109 int i;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2110
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2111 if (wp != NULL)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2112 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2113 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
2114 if (qi == NULL)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2115 return FALSE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2116 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2117
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2118 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
2119 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
2120 return TRUE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2121
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2122 return FALSE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2123 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2124
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2125 /*
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2126 * 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
2127 * This may invalidate the current quickfix entry. This function checks
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2128 * whether an entry is still present in the quickfix list.
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2129 * Similar to location list.
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2130 */
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2131 static int
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2132 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
2133 {
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2134 qf_list_T *qfl;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2135 qfline_T *qfp;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2136 int i;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2137
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2138 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
2139
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2140 /* 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
2141 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
2142 ++i, qfp = qfp->qf_next)
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2143 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
2144 break;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2145
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2146 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
2147 return FALSE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2148
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2149 return TRUE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2150 }
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2151
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2152 /*
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2153 * 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
2154 * 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
2155 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2156 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2157 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
2158 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
2159 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
2160 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2161 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2162 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2163 int idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2164 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
2165
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2166 idx = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2167 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
2168
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2169 do
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2170 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2171 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
2172 || 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
2173 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2174 ++idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2175 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
2176 } 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
2177 && !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
2178 || (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
2179
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2180 *qf_index = idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2181 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2182 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2183
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2184 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2185 * 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
2186 * 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
2187 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2188 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2189 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
2190 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
2191 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
2192 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2193 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2194 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2195 int idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2196 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
2197
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2198 idx = *qf_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2199 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
2200
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2201 do
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2202 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2203 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
2204 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2205 --idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2206 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
2207 } 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
2208 && !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
2209 || (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
2210
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2211 *qf_index = idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2212 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2213 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2214
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2215 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2216 * 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
2217 * the quickfix list.
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2218 * 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
2219 * 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
2220 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2221 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2222 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
2223 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
2224 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2225 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
2226 int *qf_index,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2227 int dir)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2228 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2229 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
2230 int prev_index;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2231 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
2232 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
2233
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2234 while (errornr--)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2235 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2236 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
2237 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
2238
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2239 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
2240 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
2241 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2242 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
2243 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
2244 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2245 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
2246 *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
2247 if (err != NULL)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2248 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2249 EMSG(_(err));
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2250 return NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2251 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2252 break;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2253 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2254
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2255 err = NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2256 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2257
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2258 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2259 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2260
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2261 /*
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2262 * 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
2263 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2264 static qfline_T *
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2265 get_nth_entry(
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2266 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
2267 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2268 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
2269 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
2270 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2271 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
2272
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2273 /* 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
2274 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
2275 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2276 --qf_idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2277 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
2278 }
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2279 /* 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
2280 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
2281 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
2282 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
2283 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2284 ++qf_idx;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2285 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
2286 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2287
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2288 *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
2289 return qf_ptr;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2290 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2291
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2292 /*
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2293 * Find a window displaying a Vim help file.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2294 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2295 static win_T *
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2296 qf_find_help_win(void)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2297 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2298 win_T *wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2299
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2300 FOR_ALL_WINDOWS(wp)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2301 if (bt_help(wp->w_buffer))
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2302 return wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2303
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2304 return NULL;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2305 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2306
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2307 /*
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2308 * 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
2309 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2310 static int
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2311 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
2312 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2313 win_T *wp;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2314 int flags;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2315
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2316 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
2317 wp = NULL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2318 else
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2319 wp = qf_find_help_win();
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2320 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
2321 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
2322 else
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2323 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2324 /*
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2325 * 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
2326 * 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
2327 */
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2328 flags = WSP_HELP;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2329 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
2330 && 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
2331 flags |= WSP_TOP;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2332 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
2333 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
2334
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2335 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
2336 return FAIL;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2337
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2338 *opened_window = TRUE;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2339
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2340 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
2341 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
2342
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2343 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
2344 {
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2345 /* 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
2346 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
2347 qi->qf_refcount++;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2348 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2349 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2350
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2351 if (!p_im)
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2352 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
2353
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2354 return OK;
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2355 }
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2356
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2357 /*
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2358 * Find a non-quickfix window using the given location list.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2359 * Returns NULL if a matching window is not found.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2360 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2361 static win_T *
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2362 qf_find_win_with_loclist(qf_info_T *ll)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2363 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2364 win_T *wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2365
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2366 FOR_ALL_WINDOWS(wp)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2367 if (wp->w_llist == ll && !bt_quickfix(wp->w_buffer))
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2368 return wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2369
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2370 return NULL;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2371 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2372
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2373 /*
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2374 * Find a window containing a normal buffer
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2375 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2376 static win_T *
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2377 qf_find_win_with_normal_buf(void)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2378 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2379 win_T *wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2380
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2381 FOR_ALL_WINDOWS(wp)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2382 if (wp->w_buffer->b_p_bt[0] == NUL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2383 return wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2384
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2385 return NULL;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2386 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2387
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2388 /*
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2389 * Go to a window in any tabpage containing the specified file. Returns TRUE
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2390 * if successfully jumped to the window. Otherwise returns FALSE.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2391 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2392 static int
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2393 qf_goto_tabwin_with_file(int fnum)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2394 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2395 tabpage_T *tp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2396 win_T *wp;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2397
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2398 FOR_ALL_TAB_WINDOWS(tp, wp)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2399 if (wp->w_buffer->b_fnum == fnum)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2400 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2401 goto_tabpage_win(tp, wp);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2402 return TRUE;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2403 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2404
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2405 return FALSE;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2406 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2407
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2408 /*
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2409 * Create a new window to show a file above the quickfix window. Called when
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2410 * only the quickfix window is present.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2411 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2412 static int
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2413 qf_open_new_file_win(qf_info_T *ll_ref)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2414 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2415 int flags;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2416
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2417 flags = WSP_ABOVE;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2418 if (ll_ref != NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2419 flags |= WSP_NEWLOC;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2420 if (win_split(0, flags) == FAIL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2421 return FAIL; /* not enough room for window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2422 p_swb = empty_option; /* don't split again */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2423 swb_flags = 0;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2424 RESET_BINDING(curwin);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2425 if (ll_ref != NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2426 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2427 /* The new window should use the location list from the
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2428 * location list window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2429 curwin->w_llist = ll_ref;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2430 ll_ref->qf_refcount++;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2431 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2432 return OK;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2433 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2434
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2435 /*
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2436 * Go to a window that shows the right buffer. If the window is not found, go
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2437 * to the window just above the location list window. This is used for opening
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2438 * a file from a location window and not from a quickfix window. If some usable
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2439 * window is previously found, then it is supplied in 'use_win'.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2440 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2441 static void
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2442 qf_goto_win_with_ll_file(win_T *use_win, int qf_fnum, qf_info_T *ll_ref)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2443 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2444 win_T *win = use_win;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2445
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2446 if (win == NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2447 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2448 /* Find the window showing the selected file */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2449 FOR_ALL_WINDOWS(win)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2450 if (win->w_buffer->b_fnum == qf_fnum)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2451 break;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2452 if (win == NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2453 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2454 /* Find a previous usable window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2455 win = curwin;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2456 do
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2457 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2458 if (win->w_buffer->b_p_bt[0] == NUL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2459 break;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2460 if (win->w_prev == NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2461 win = lastwin; /* wrap around the top */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2462 else
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2463 win = win->w_prev; /* go to previous window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2464 } while (win != curwin);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2465 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2466 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2467 win_goto(win);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2468
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2469 /* If the location list for the window is not set, then set it
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2470 * to the location list from the location window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2471 if (win->w_llist == NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2472 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2473 win->w_llist = ll_ref;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2474 ll_ref->qf_refcount++;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2475 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2476 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2477
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2478 /*
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2479 * Go to a window that shows the specified file. If a window is not found, go
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2480 * to the window just above the quickfix window. This is used for opening a
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2481 * file from a quickfix window and not from a location window.
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2482 */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2483 static void
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2484 qf_goto_win_with_qfl_file(int qf_fnum)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2485 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2486 win_T *win;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2487 win_T *altwin;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2488
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2489 win = curwin;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2490 altwin = NULL;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2491 for (;;)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2492 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2493 if (win->w_buffer->b_fnum == qf_fnum)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2494 break;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2495 if (win->w_prev == NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2496 win = lastwin; /* wrap around the top */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2497 else
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2498 win = win->w_prev; /* go to previous window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2499
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2500 if (IS_QF_WINDOW(win))
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2501 {
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2502 /* Didn't find it, go to the window before the quickfix
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2503 * window. */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2504 if (altwin != NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2505 win = altwin;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2506 else if (curwin->w_prev != NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2507 win = curwin->w_prev;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2508 else
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2509 win = curwin->w_next;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2510 break;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2511 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2512
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2513 /* Remember a usable window. */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2514 if (altwin == NULL && !win->w_p_pvw
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2515 && win->w_buffer->b_p_bt[0] == NUL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2516 altwin = win;
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2517 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2518
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2519 win_goto(win);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2520 }
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2521
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2522 /*
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2523 * Find a suitable window for opening a file (qf_fnum) from the
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2524 * quickfix/location list and jump to it. If the file is already opened in a
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2525 * window, jump to it. Otherwise open a new window to display the file. This is
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2526 * called from either a quickfix or a location list window.
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2527 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2528 static int
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2529 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
2530 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2531 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
2532 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
2533 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
2534 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
2535
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2536 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
2537
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2538 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
2539 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
2540 {
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2541 /* Find a non-quickfix window with this location list */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2542 usable_win_ptr = qf_find_win_with_loclist(ll_ref);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2543 if (usable_win_ptr != NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2544 usable_win = 1;
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2545 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2546
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2547 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
2548 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2549 /* Locate a window showing a normal buffer */
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2550 win = qf_find_win_with_normal_buf();
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2551 if (win != NULL)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2552 usable_win = 1;
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2553 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2554
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2555 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2556 * 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
2557 * 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
2558 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2559 if (!usable_win && (swb_flags & SWB_USETAB))
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2560 usable_win = qf_goto_tabwin_with_file(qf_fnum);
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2561
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2562 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2563 * 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
2564 * 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
2565 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2566 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
2567 {
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2568 if (qf_open_new_file_win(ll_ref) != OK)
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2569 return FAIL;
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2570 *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
2571 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2572 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2573 {
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2574 if (curwin->w_llist_ref != NULL) /* In a location window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2575 qf_goto_win_with_ll_file(usable_win_ptr, qf_fnum, ll_ref);
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2576 else /* In a quickfix window */
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2577 qf_goto_win_with_qfl_file(qf_fnum);
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2578 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2579
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2580 return OK;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2581 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2582
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2583 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2584 * 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
2585 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2586 static int
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2587 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
2588 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
2589 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
2590 int forceit,
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2591 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
2592 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
2593 int *abort)
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2594 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2595 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
2596
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2597 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
2598 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2599 /* 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
2600 * 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
2601 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
2602 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2603 no_write_message();
13800
e4dc4ede9ef8 patch 8.0.1772: quickfix: mixup of FALSE and FAIL, returning -1
Christian Brabandt <cb@256bit.org>
parents: 13764
diff changeset
2604 retval = FAIL;
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2605 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2606 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2607 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
2608 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
2609 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
2610 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2611 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2612 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2613 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
2614 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
2615
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2616 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
2617 (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
2618
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2619 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
2620 {
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2621 /*
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2622 * 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
2623 * 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
2624 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2625 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
2626 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2627 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
2628 *abort = TRUE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2629 *opened_window = FALSE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2630 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2631 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
2632 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2633 EMSG(_(e_loc_list_changed));
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2634 *abort = TRUE;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2635 }
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2636 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2637 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
2638 || !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
2639 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2640 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
2641 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
2642 else
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
2643 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
2644 *abort = TRUE;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2645 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2646
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2647 if (*abort)
13800
e4dc4ede9ef8 patch 8.0.1772: quickfix: mixup of FALSE and FAIL, returning -1
Christian Brabandt <cb@256bit.org>
parents: 13764
diff changeset
2648 retval = FAIL;
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2649 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2650
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2651 return retval;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2652 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2653
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2654 /*
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2655 * Go to the error line in the current file using either line/column number or
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
2656 * a search pattern.
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2657 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2658 static void
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2659 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
2660 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
2661 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
2662 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
2663 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
2664 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2665 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
2666 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
2667 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
2668 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
2669
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2670 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
2671 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2672 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2673 * 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
2674 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2675 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
2676 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
2677 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2678 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
2679 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
2680 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
2681 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2682 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
2683 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2684 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
2685 #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
2686 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
2687 #endif
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2688 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
2689 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2690 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2691 * 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
2692 * 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
2693 * 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
2694 * 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
2695 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2696 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
2697 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
2698 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
2699 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2700 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
2701 break;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2702 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
2703 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2704 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
2705 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
2706 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2707 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2708 ++screen_col;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2709 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2710 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2711 check_cursor();
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2712 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2713 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2714 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
2715 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2716 else
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2717 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2718 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
2719
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2720 /* 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
2721 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
2722 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
2723 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
2724 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
2725 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
2726 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2727 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2728
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2729 /*
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2730 * 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
2731 */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2732 static void
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2733 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
2734 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
2735 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
2736 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
2737 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
2738 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
2739 {
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2740 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
2741 int len;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2742
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2743 /* 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
2744 * scrolled up. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2745 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
2746 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
2747 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
2748 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
2749 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
2750 (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
2751 /* 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
2752 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
2753 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
2754
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2755 /* 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
2756 * 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
2757 * whole message. */
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2758 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
2759 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
2760 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
2761 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
2762 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
2763 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
2764 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
2765 }
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2766
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2767 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 * jump to a quickfix line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 * if dir == FORWARD go "errornr" valid entries forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 * if dir == BACKWARD go "errornr" valid entries backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 * if dir == FORWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 * else if "errornr" is zero, redisplay the same line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774 * else go to entry "errornr"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 void
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2777 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
2778 int dir,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2779 int errornr,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2780 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2782 qfline_T *qf_ptr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2783 qfline_T *old_qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 int qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 int old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 buf_T *old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 linenr_T old_lnum;
639
c79d4df4686e updated for version 7.0185
vimboss
parents: 634
diff changeset
2788 char_u *old_swb = p_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2789 unsigned old_swb_flags = swb_flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 int opened_window = FALSE;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2791 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 int print_message = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 int old_KeyTyped = KeyTyped; /* getting file may reset it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 #endif
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2796 int retval = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2797
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2798 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2799 qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2800
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2801 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2802 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2808 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 old_qf_ptr = qf_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2810 qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 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
2812 if (dir != 0) /* next/prev valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 {
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2814 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
2815 if (qf_ptr == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 {
12449
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
2817 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
2818 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
2819 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822 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
2823 qf_ptr = get_nth_entry(qi, errornr, qf_ptr, &qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2825 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2826 if (qf_win_pos_update(qi, old_qf_index))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827 /* No need to print the error message if it's visible in the error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 * window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 print_message = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 /*
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2832 * For ":helpgrep" find a help window or open one.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2833 */
11800
5ceaecedbad2 patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents: 11788
diff changeset
2834 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
2835 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
2836 goto theend;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2837
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2838 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 * If currently in the quickfix window, find another window to show the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 * file in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
2842 if (bt_quickfix(curbuf) && !opened_window)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 * If there is no file specified, we don't know where to go.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 * But do advance, otherwise ":cn" gets stuck.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 if (qf_ptr->qf_fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2851 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
2852 goto failed;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856 * If there is a file name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 * read the wanted file if needed, and check autowrite etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 old_lnum = curwin->w_cursor.lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2861
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2862 if (qf_ptr->qf_fnum != 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2863 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2864 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
2865
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2866 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
2867 &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
2868 if (abort)
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2869 {
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2870 qi = NULL;
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2871 qf_ptr = NULL;
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2872 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2873 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2874
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2875 if (retval == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 /* When not switched to another buffer, still need to set pc mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 if (curbuf == old_curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880
12503
4d40b2644e92 patch 8.0.1130: the qf_jump() function is still too long
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
2881 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
2882 qf_ptr->qf_pattern);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 foldOpenCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888 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
2889 qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 if (opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 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
2895 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 * Couldn't open file, so put index back where it was. This could
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2899 * happen if the file was readonly and we changed something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901 failed:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 qf_index = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 theend:
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2907 if (qi != NULL)
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2908 {
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2909 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
2910 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
2911 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 if (p_swb != old_swb && opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 /* Restore old 'switchbuf' value, but not when an autocommand or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 * modeline has changed the value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 if (p_swb == empty_option)
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2917 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 p_swb = old_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2919 swb_flags = old_swb_flags;
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2920 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 free_string_option(old_swb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 * ":clist": list all errors
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2928 * ":llist": list all locations
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2931 qf_list(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2933 buf_T *buf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2934 char_u *fname;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2935 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2936 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2937 int idx1 = 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2938 int idx2 = -1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2939 char_u *arg = eap->arg;
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2940 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
2941 int qfFileAttr;
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2942 int qfSepAttr;
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2943 int qfLineAttr;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2944 int all = eap->forceit; /* if not :cl!, only show
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945 recognised errors */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2946 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2947
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2948 if (eap->cmdidx == CMD_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2949 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2950 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2951 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2952 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2953 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2954 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2955 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2956 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2957
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2958 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2959 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2964 if (*arg == '+')
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2965 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2966 ++arg;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2967 plus = TRUE;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2968 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2974 if (plus)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2975 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2976 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
2977 idx2 = i + idx1;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2978 idx1 = i;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2979 }
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2980 else
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2981 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2982 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
2983 if (idx1 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2984 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
2985 if (idx2 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2986 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
2987 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988
13819
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
2989 /* Shorten all the file names, so that it is easy to read */
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
2990 shorten_fnames(FALSE);
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
2991
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2992 /*
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2993 * 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
2994 * 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
2995 */
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2996 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
2997 if (qfFileAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
2998 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
2999 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
3000 if (qfSepAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
3001 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
3002 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
3003 if (qfLineAttr == 0)
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
3004 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
3005
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3006 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007 all = TRUE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3008 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3009 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
3010 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 {
2047
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
3013 msg_putchar('\n');
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
3014 if (got_int)
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
3015 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3016
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3017 fname = NULL;
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3018 if (qfp->qf_module != NULL && *qfp->qf_module != NUL)
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3019 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", i, (char *)qfp->qf_module);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3020 else {
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3021 if (qfp->qf_fnum != 0
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3022 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3023 {
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3024 fname = buf->b_fname;
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3025 if (qfp->qf_type == 1) /* :helpgrep */
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3026 fname = gettail(fname);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3027 }
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3028 if (fname == NULL)
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3029 sprintf((char *)IObuff, "%2d", i);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3030 else
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3031 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3032 i, (char *)fname);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3033 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3034 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
3035 ? 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
3036
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
3037 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
3038 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3039 if (qfp->qf_lnum == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3040 IObuff[0] = NUL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3041 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
3042 sprintf((char *)IObuff, "%ld", qfp->qf_lnum);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3043 else
12912
888441e8fbb0 patch 8.0.1332: highlighting in quickfix window could be better
Christian Brabandt <cb@256bit.org>
parents: 12531
diff changeset
3044 sprintf((char *)IObuff, "%ld col %d",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 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
3046 sprintf((char *)IObuff + STRLEN(IObuff), "%s",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 (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
3048 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
3049 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3050 if (qfp->qf_pattern != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3051 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3052 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3053 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
3054 msg_puts_attr((char_u *)":", qfSepAttr);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3055 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3056 msg_puts((char_u *)" ");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3057
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3058 /* Remove newlines and leading whitespace from the text. For an
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3059 * unrecognized line keep the indent, the compiler may mark a word
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3060 * with ^^^^. */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3061 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063 IObuff, IOSIZE);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3064 msg_prt_line(IObuff, FALSE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3065 out_flush(); /* show one line at a time */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3066 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3067
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3068 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3069 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3070 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3071 ++i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3075
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 * Remove newlines and leading whitespace from an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 * Put the result in "buf[bufsize]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3080 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3081 qf_fmt_text(char_u *text, char_u *buf, int bufsize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 char_u *p = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086 for (i = 0; *p != NUL && i < bufsize - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3087 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3088 if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3090 buf[i] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3091 while (*++p != NUL)
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11063
diff changeset
3092 if (!VIM_ISWHITE(*p) && *p != '\n')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3095 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 buf[i] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 buf[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3101 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3102 * Display information (list number, list size and the title) about a
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3103 * quickfix/location list.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3104 */
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3105 static void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3106 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
3107 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3108 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
3109 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
3110 char_u buf[IOSIZE];
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3111
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3112 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
3113 lead,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3114 which + 1,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3115 qi->qf_listcount,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3116 count);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3117
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3118 if (title != NULL)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3119 {
9579
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3120 size_t len = STRLEN(buf);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3121
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3122 if (len < 34)
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3123 {
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3124 vim_memset(buf + len, ' ', 34 - len);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3125 buf[34] = NUL;
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3126 }
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
3127 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
3128 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3129 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
3130 msg(buf);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3131 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3132
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3134 * ":colder [count]": Up in the quickfix stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 * ":cnewer [count]": Down in the quickfix stack.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3136 * ":lolder [count]": Up in the location list stack.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3137 * ":lnewer [count]": Down in the location list stack.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3140 qf_age(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3142 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3145 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3146 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3147 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3148 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3149 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3150 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3151 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3152 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3153 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3154
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3155 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 while (count--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3161 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3162 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3163 if (qi->qf_curlist == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3164 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3165 EMSG(_("E380: At bottom of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3166 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3167 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3168 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3171 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3172 if (qi->qf_curlist >= qi->qf_listcount - 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3174 EMSG(_("E381: At top of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
3175 break;
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 ++qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3179 }
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3180 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
3181 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3184 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3185 * Display the information about all the quickfix/location lists in the stack
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3186 */
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3187 void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3188 qf_history(exarg_T *eap)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3189 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3190 qf_info_T *qi = &ql_info;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3191 int i;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3192
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3193 if (eap->cmdidx == CMD_lhistory)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3194 qi = GET_LOC_LIST(curwin);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3195 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
3196 && 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
3197 MSG(_("No entries"));
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3198 else
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3199 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
3200 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
3201 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
3202
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3203 /*
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3204 * 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
3205 * associated with the list like context and title are not freed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3206 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3207 static void
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3208 qf_free_items(qf_info_T *qi, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3209 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3210 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3211 qfline_T *qfpnext;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
3212 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
3213 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
3214
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
3215 while (qfl->qf_count && qfl->qf_start != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3216 {
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
3217 qfp = qfl->qf_start;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3218 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
3219 if (!stop)
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
3220 {
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3221 vim_free(qfp->qf_module);
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3222 vim_free(qfp->qf_text);
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3223 vim_free(qfp->qf_pattern);
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3224 stop = (qfp == qfpnext);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3225 vim_free(qfp);
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
3226 if (stop)
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
3227 /* 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
3228 * to avoid crashing when it's wrong.
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
3229 * 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
3230 qfl->qf_count = 1;
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
3231 }
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
3232 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
3233 --qfl->qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3235
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
3236 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
3237 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
3238 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
3239 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
3240 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
3241
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
3242 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
3243 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
3244 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
3245 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
3246 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
3247 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
3248 qfl->qf_multiscan = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251 /*
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3252 * 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
3253 * 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
3254 */
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3255 static void
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3256 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
3257 {
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
3258 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
3259
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3260 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
3261
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13115
diff changeset
3262 VIM_CLEAR(qfl->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
3263 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
3264 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
3265 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
3266 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
3267 }
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3268
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
3269 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3270 * qf_mark_adjust: adjust marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3271 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3272 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3273 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
3274 win_T *wp,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3275 linenr_T line1,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3276 linenr_T line2,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3277 long amount,
7a743053dfd6 patch 8.0.1104: the qf_jump() function is too long
Christian Brabandt <cb@256bit.org>
parents: 12427
diff changeset
3278 long amount_after)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3279 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3280 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3281 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3282 int idx;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3283 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
3284 int found_one = FALSE;
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3285 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
3286
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3287 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
3288 return;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3289 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3290 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3291 if (wp->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3292 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3293 qi = wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3294 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3295
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3296 for (idx = 0; idx < qi->qf_listcount; ++idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3297 if (qi->qf_lists[idx].qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3298 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
3299 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
3300 ++i, qfp = qfp->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3301 if (qfp->qf_fnum == curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3302 {
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3303 found_one = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3304 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3306 if (amount == MAXLNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3307 qfp->qf_cleared = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3308 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3309 qfp->qf_lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3310 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3311 else if (amount_after && qfp->qf_lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3312 qfp->qf_lnum += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3313 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3314
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
3315 if (!found_one)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
3316 curbuf->b_has_qf_entry &= ~buf_has_flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 * Make a nice message out of the error character and the error number:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 * char number message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 * e or E 0 " error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 * w or W 0 " warning"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3324 * i or I 0 " info"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3325 * 0 0 ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 * other 0 " c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 * e or E n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 * w or W n " warning n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329 * i or I n " info n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 * 0 n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 * other n " c n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 * 1 x "" :helpgrep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3335 qf_types(int c, int nr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 static char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 static char_u cc[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3341 if (c == 'W' || c == 'w')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 p = (char_u *)" warning";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 else if (c == 'I' || c == 'i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 p = (char_u *)" info";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 p = (char_u *)" error";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347 else if (c == 0 || c == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 p = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3349 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 cc[0] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 cc[1] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 cc[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354 p = cc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3357 if (nr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3358 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3360 sprintf((char *)buf, "%s %3d", (char *)p, nr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3361 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3362 }
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 * ":cwindow": open the quickfix window if we have errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366 * close it if not.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3367 * ":lwindow": open the location list window if we have locations to display,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3368 * close it if not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3369 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3370 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3371 ex_cwindow(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3372 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3373 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3374 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3375
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3376 if (eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3377 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3378 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3379 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3380 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3381 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3382
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3383 /* Look for an existing quickfix window. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3384 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3386 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3387 * If a quickfix window is open but we have no errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3388 * close the window. If a quickfix window is not open, then open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3389 * it if we have errors; otherwise, leave it closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3390 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3391 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
3392 || qi->qf_lists[qi->qf_curlist].qf_count == 0
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3393 || qi->qf_curlist >= qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3395 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3396 ex_cclose(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3398 else if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3399 ex_copen(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3402 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3403 * ":cclose": close the window showing the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3404 * ":lclose": close the window showing the location list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3405 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3407 ex_cclose(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3409 win_T *win = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3410 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3411
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3412 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3413 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3414 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3415 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3416 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3417 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3418
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3419 /* Find existing quickfix window and close it. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3420 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3421 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3422 win_close(win, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3423 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3425 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3426 * ":copen": open a window that shows the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3427 * ":lopen": open a window that shows the location list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3428 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3429 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3430 ex_copen(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3431 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3432 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3433 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3434 win_T *win;
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3435 tabpage_T *prevtab = curtab;
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3436 buf_T *qf_buf;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3437 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3439 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3440 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3441 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3442 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3443 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3444 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3445 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3446 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3447 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3448
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3449 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3450 height = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3451 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3452 height = QF_WINHEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3454 reset_VIsual_and_resel(); /* stop Visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3455 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3456 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3457 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3458
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3459 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3460 * Find existing quickfix window, or open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3461 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3462 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3463
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3464 if (win != NULL && cmdmod.tab == 0)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3465 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3466 win_goto(win);
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3467 if (eap->addr_count != 0)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3468 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3469 if (cmdmod.split & WSP_VERT)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3470 {
12515
972ea22c946f patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12503
diff changeset
3471 if (height != win->w_width)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3472 win_setwidth(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3473 }
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3474 else if (height != win->w_height)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3475 win_setheight(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3476 }
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3477 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3478 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3479 {
13105
bfa7f5b23c53 patch 8.0.1427: the :leftabove modifier doesn't work for :copen
Christian Brabandt <cb@256bit.org>
parents: 13090
diff changeset
3480 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
3481
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3482 qf_buf = qf_find_buf(qi);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3483
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3484 /* The current window becomes the previous window afterwards. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3485 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3486
3939
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
3487 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
3488 && 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
3489 /* 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
3490 * :belowright or :aboveleft is used. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3491 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
3492 /* 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
3493 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
3494 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
3495 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
3496 if (win_split(height, flags) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3497 return; /* not enough room for window */
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
3498 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3499
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3500 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3501 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3502 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3503 * For the location list window, create a reference to the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3504 * location list from the window 'win'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3505 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3506 curwin->w_llist_ref = win->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3507 win->w_llist->qf_refcount++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3508 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3509
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3510 if (oldwin != curwin)
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3511 oldwin = NULL; /* don't store info when in another window */
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3512 if (qf_buf != NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3513 /* Use the existing quickfix buffer */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3514 (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
3515 ECMD_HIDE + ECMD_OLDBUF, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3516 else
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3517 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3518 /* Create a new quickfix buffer */
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3519 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3520 /* switch off 'swapfile' */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3521 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3522 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
729
3d0ca316efab updated for version 7.0221
vimboss
parents: 717
diff changeset
3523 OPT_LOCAL);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3524 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
3525 RESET_BINDING(curwin);
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3526 #ifdef FEAT_DIFF
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3527 curwin->w_p_diff = FALSE;
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3528 #endif
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3529 #ifdef FEAT_FOLDING
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3530 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3531 OPT_LOCAL);
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3532 #endif
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3533 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3534
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3535 /* 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
3536 * window to the side. */
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3537 if (curtab == prevtab && curwin->w_width == Columns)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538 win_setheight(height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3539 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3540 if (win_valid(win))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3541 prevwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3542 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3543
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3544 qf_set_title_var(qi);
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3545
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3546 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3547 * Fill the buffer with the quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3548 */
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3549 qf_fill_buffer(qi, curbuf, NULL);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3550
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3551 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3553 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3554 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3555 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557 /*
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3558 * 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
3559 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3560 static void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3561 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
3562 {
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3563 win_T *old_curwin = curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3564
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3565 curwin = win;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3566 curbuf = win->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3567 curwin->w_cursor.lnum = lnum;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3568 curwin->w_cursor.col = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3569 #ifdef FEAT_VIRTUALEDIT
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3570 curwin->w_cursor.coladd = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3571 #endif
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3572 curwin->w_curswant = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3573 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
3574 redraw_later(VALID);
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3575 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
3576 curwin = old_curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3577 curbuf = curwin->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3578 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3579
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3580 /*
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3581 * :cbottom/:lbottom commands.
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3582 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3583 void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3584 ex_cbottom(exarg_T *eap UNUSED)
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3585 {
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3586 qf_info_T *qi = &ql_info;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3587 win_T *win;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3588
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3589 if (eap->cmdidx == CMD_lbottom)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3590 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3591 qi = GET_LOC_LIST(curwin);
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3592 if (qi == NULL)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3593 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3594 EMSG(_(e_loclist));
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3595 return;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3596 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3597 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3598
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3599 win = qf_find_win(qi);
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3600 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
3601 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
3602 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3603
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3604 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3605 * Return the number of the current entry (line number in the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3606 * window).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3607 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608 linenr_T
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3609 qf_current_entry(win_T *wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3610 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3611 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3612
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3613 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3614 /* In the location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3615 qi = wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3616
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3617 return qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3620 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3621 * Update the cursor position in the quickfix window to the current error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3622 * Return TRUE if there is a quickfix window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3623 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3624 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3625 qf_win_pos_update(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3626 qf_info_T *qi,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3627 int old_qf_index) /* previous qf_index or zero */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3628 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3629 win_T *win;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3630 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 * Put the cursor on the current error in the quickfix window, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3634 * it's viewable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3636 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3637 if (win != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638 && qf_index <= win->w_buffer->b_ml.ml_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 && old_qf_index != qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3640 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3641 if (qf_index > old_qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3643 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
3644 win->w_redraw_bot = qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3645 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3646 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3648 win->w_redraw_top = qf_index;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3649 win->w_redraw_bot = old_qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3650 }
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3651 qf_win_goto(win, qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3653 return win != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3656 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3657 * Check whether the given window is displaying the specified quickfix/location
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3658 * list buffer
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3659 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3660 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3661 is_qf_win(win_T *win, qf_info_T *qi)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3662 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3663 /*
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3664 * A window displaying the quickfix buffer will have the w_llist_ref field
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3665 * set to NULL.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3666 * A window displaying a location list buffer will have the w_llist_ref
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3667 * pointing to the location list.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3668 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3669 if (bt_quickfix(win->w_buffer))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3670 if ((qi == &ql_info && win->w_llist_ref == NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3671 || (qi != &ql_info && win->w_llist_ref == qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3672 return TRUE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3673
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3674 return FALSE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3675 }
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3676
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3677 /*
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3678 * 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
3679 * Only searches in the current tabpage.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3680 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3681 static win_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3682 qf_find_win(qf_info_T *qi)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3683 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3684 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3685
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3686 FOR_ALL_WINDOWS(win)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3687 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
3688 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
3689 return NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3690 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3691
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3692 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3693 * Find a quickfix buffer.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3694 * Searches in windows opened in all the tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3697 qf_find_buf(qf_info_T *qi)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3699 tabpage_T *tp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3700 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3701
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3702 FOR_ALL_TAB_WINDOWS(tp, win)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3703 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3704 return win->w_buffer;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3705
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3706 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3709 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3710 * 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
3711 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3712 static void
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3713 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
3714 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3715 win_T *win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3716 win_T *curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3717
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3718 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
3719 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3720 curwin_save = curwin;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3721 curwin = win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3722 qf_set_title_var(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3723 curwin = curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3724 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3725 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3726
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3727 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3728 * Find the quickfix buffer. If it exists, update the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3729 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3730 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3731 qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3732 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3733 buf_T *buf;
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3734 win_T *win;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735 aco_save_T aco;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3736
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3737 /* Check if a buffer for the quickfix list exists. Update it. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3738 buf = qf_find_buf(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3739 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740 {
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3741 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
3742
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3743 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3744 /* 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
3745 aucmd_prepbuf(&aco, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3746
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3747 qf_update_win_titlevar(qi);
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3748
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3749 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
3750 ++CHANGEDTICK(buf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3751
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3752 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3753 {
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
3754 (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
3755
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3756 /* 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
3757 aucmd_restbuf(&aco);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3758 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3759
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3760 /* 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
3761 * 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
3762 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
3763 redraw_buf_later(buf, NOT_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3764 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3766
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3767 /*
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3768 * Set "w:quickfix_title" if "qi" has a title.
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3769 */
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3770 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3771 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
3772 {
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3773 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL)
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3774 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
3775 qi->qf_lists[qi->qf_curlist].qf_title);
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3776 }
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3777
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3778 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3779 * Fill current buffer with quickfix errors, replacing any previous contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3780 * 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
3781 * 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
3782 * 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
3783 * ml_delete() is used and autocommands will be triggered.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3784 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3785 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3786 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
3787 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3788 linenr_T lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3789 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3790 buf_T *errbuf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3791 int len;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3792 int old_KeyTyped = KeyTyped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3793
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3794 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3795 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3796 if (buf != curbuf)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3797 {
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
3798 internal_error("qf_fill_buffer()");
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3799 return;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3800 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3801
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3802 /* delete all existing lines */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3803 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
3804 (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
3805 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3807 /* Check if there is anything to display */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3808 if (qi->qf_curlist < qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3809 {
13819
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3810 char_u dirname[MAXPATHL];
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3811
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3812 *dirname = NUL;
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3813
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3814 /* 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
3815 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3816 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3817 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
3818 lnum = 0;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3819 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3820 else
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3821 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3822 qfp = old_last->qf_next;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3823 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
3824 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3825 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3826 {
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3827 if (qfp->qf_module != NULL)
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3828 {
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3829 STRCPY(IObuff, qfp->qf_module);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3830 len = (int)STRLEN(IObuff);
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3831 }
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
3832 else if (qfp->qf_fnum != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3833 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3834 && errbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3835 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3836 if (qfp->qf_type == 1) /* :helpgrep */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3837 STRCPY(IObuff, gettail(errbuf->b_fname));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3838 else
13819
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3839 {
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3840 /* shorten the file name if not done already */
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3841 if (errbuf->b_sfname == NULL
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3842 || mch_isFullName(errbuf->b_sfname))
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3843 {
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3844 if (*dirname == NUL)
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3845 mch_dirname(dirname, MAXPATHL);
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3846 shorten_buf_fname(errbuf, dirname, FALSE);
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3847 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3848 STRCPY(IObuff, errbuf->b_fname);
13819
31bb8e1f7625 patch 8.0.1781: file names in quickfix window are not shortened
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
3849 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3850 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3852 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3853 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3854 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3856 if (qfp->qf_lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3858 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3859 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3861 if (qfp->qf_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3863 sprintf((char *)IObuff + len, " col %d", qfp->qf_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3864 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3866
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3867 sprintf((char *)IObuff + len, "%s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3868 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3869 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3870 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3871 else if (qfp->qf_pattern != NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3872 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3873 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3874 len += (int)STRLEN(IObuff + len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3875 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3876 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3877 IObuff[len++] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3878
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3879 /* Remove newlines and leading whitespace from the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3880 * For an unrecognized line keep the indent, the compiler may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3881 * mark a word with ^^^^. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3882 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3883 IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3884
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3885 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
3886 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3887 break;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3888 ++lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3889 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3890 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3891 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3892 }
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3893
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3894 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3895 /* 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
3896 (void)ml_delete(lnum + 1, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3899 /* correct cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3900 check_lnums(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3901
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3902 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3903 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3904 /* 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
3905 * 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
3906 * using autocommands. */
11589
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3907 ++curbuf_lock;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3908 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
3909 curbuf->b_p_ma = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3910
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3911 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
3912 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3913 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3914 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3915 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3916 keep_filetype = FALSE;
11589
39787def24bb patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents: 11549
diff changeset
3917 --curbuf_lock;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
3918
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3919 /* make sure it will be redrawn */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3920 redraw_curbuf_later(NOT_VALID);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3921 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3922
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3923 /* Restore KeyTyped, setting 'filetype' may reset it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3924 KeyTyped = old_KeyTyped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3926
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3927 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3928 * For every change made to the quickfix list, update the changed tick.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
3929 */
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3930 static void
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3931 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
3932 {
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3933 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
3934 }
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
3935
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3936 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3937 * Return TRUE when using ":vimgrep" for ":grep".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3938 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3939 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3940 grep_internal(cmdidx_T cmdidx)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3941 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3942 return ((cmdidx == CMD_grep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3943 || cmdidx == CMD_lgrep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3944 || cmdidx == CMD_grepadd
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3945 || cmdidx == CMD_lgrepadd)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3946 && STRCMP("internal",
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3947 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3948 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3949
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3950 /*
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3951 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3952 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3953 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3954 ex_make(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3955 {
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3956 char_u *fname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3957 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
3958 char_u *enc = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3959 unsigned len;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3960 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3961 qf_info_T *qi = &ql_info;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3962 int res;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3963 char_u *au_name = NULL;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3964
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3965 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3966 if (grep_internal(eap->cmdidx))
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3967 {
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3968 ex_vimgrep(eap);
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3969 return;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3970 }
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3971
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3972 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3973 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3974 case CMD_make: au_name = (char_u *)"make"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3975 case CMD_lmake: au_name = (char_u *)"lmake"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3976 case CMD_grep: au_name = (char_u *)"grep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3977 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3978 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3979 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3980 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3981 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3982 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
3983 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3984 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
3985 #ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3986 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3987 return;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3988 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
3989 }
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3990 #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
3991 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
3992 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3993
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3994 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3995 || eap->cmdidx == CMD_lgrepadd)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3996 wp = curwin;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3997
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3998 autowrite_all();
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3999 fname = get_mef_name();
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4000 if (fname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4001 return;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4002 mch_remove(fname); /* in case it's not unique */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4004 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4005 * If 'shellpipe' empty: don't redirect to 'errorfile'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4006 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4009 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4010 cmd = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4011 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4013 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4014 (char *)p_shq);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4015 if (*p_sp != NUL)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1864
diff changeset
4016 append_redir(cmd, len, p_sp, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4017 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4018 * Output a newline if there's something else than the :make command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4019 * was typed (in which case the cursor is in column 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4020 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4021 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4022 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4023 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4024 MSG_PUTS(":!");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4025 msg_outtrans(cmd); /* show what we are doing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4027 /* let the shell know if we are redirecting output or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4028 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4030 #ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4031 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4032 /* read window status report and redraw before message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4033 (void)char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4034 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4035
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4036 res = qf_init(wp, fname, (eap->cmdidx != CMD_make
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4037 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4038 (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
4039 && eap->cmdidx != CMD_lgrepadd),
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
4040 qf_cmdtitle(*eap->cmdlinep), enc);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
4041 if (wp != NULL)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
4042 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
4043 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
4044 qf_list_changed(qi, qi->qf_curlist);
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4045 if (au_name != NULL)
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
4046 {
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4047 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4048 curbuf->b_fname, TRUE, curbuf);
13252
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4049 if (qi != NULL && qi->qf_curlist < qi->qf_listcount)
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
4050 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
4051 else
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
4052 res = 0;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
4053 }
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4054 if (res > 0 && !eap->forceit)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4055 qf_jump(qi, 0, 0, FALSE); /* display first error */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4056
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4057 mch_remove(fname);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4058 vim_free(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4059 vim_free(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4060 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4062 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4063 * Return the name for the errorfile, in allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4064 * Find a new unique name when 'makeef' contains "##".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4065 * Returns NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4066 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4067 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4068 get_mef_name(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4069 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4070 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4071 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4072 static int start = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4073 static int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4074 #ifdef HAVE_LSTAT
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents: 9379
diff changeset
4075 stat_T sb;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4076 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4078 if (*p_mef == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4079 {
6721
7347229a646a updated for version 7.4.684
Bram Moolenaar <bram@vim.org>
parents: 6450
diff changeset
4080 name = vim_tempname('e', FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4081 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4082 EMSG(_(e_notmp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4083 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4084 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4085
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4086 for (p = p_mef; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4087 if (p[0] == '#' && p[1] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4088 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4090 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4091 return vim_strsave(p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4093 /* Keep trying until the name doesn't exist yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4094 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4096 if (start == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4097 start = mch_get_pid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4098 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 off += 19;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 name = alloc((unsigned)STRLEN(p_mef) + 30);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4102 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4103 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 STRCPY(name, p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106 STRCAT(name, p + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4107 if (mch_getperm(name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4108 #ifdef HAVE_LSTAT
10226
7a4fb555c83a commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents: 10056
diff changeset
4109 /* Don't accept a symbolic link, it's a security risk. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 && mch_lstat((char *)name, &sb) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4111 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4112 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4113 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4114 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4115 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4116 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4119 /*
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4120 * 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
4121 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4122 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4123 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
4124 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4125 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4126 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4127 int i, sz = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4128 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4129
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4130 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
4131 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4132 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4133 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4134 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4135 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4136 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4137
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4138 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
4139 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
4140 ++i, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4141 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4142 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4143 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4144 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
4145 sz++; /* Count all valid entries */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4146 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
4147 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4148 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4149 sz++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4150 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4151 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4152 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4153 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4154
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4155 return sz;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4156 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4157
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4158 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4159 * 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
4160 * 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
4161 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4162 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4163 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
4164 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4165 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4166
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4167 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
4168 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4169 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4170 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4171 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4172 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4173 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4174
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4175 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
4176 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4177
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4178 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4179 * 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
4180 * 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
4181 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4182 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4183 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
4184 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4185 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4186 qf_list_T *qfl;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4187 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4188 int i, eidx = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4189 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4190
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4191 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
4192 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4193 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4194 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4195 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4196 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4197 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4198
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4199 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
4200 qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4201
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4202 /* 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
4203 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
4204 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4205
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4206 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
4207 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4208 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4209 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4210 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
4211 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4212 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
4213 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4214 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4215 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4216 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4217 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4218 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4219 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4220 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4221 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4222 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4223
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4224 return eidx ? eidx : 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4225 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4226
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4227 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4228 * 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
4229 * 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
4230 * 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
4231 * 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
4232 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4233 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4234 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
4235 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4236 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
4237 qfline_T *qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4238 int i, eidx;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4239 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4240
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4241 /* 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
4242 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
4243 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4244
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4245 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
4246 i++, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4247 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4248 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4249 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4250 if (fdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4251 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4252 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
4253 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4254 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4255 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4256 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4257 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4258 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4259 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4260 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4261 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4262
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4263 if (eidx == n)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4264 break;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4265 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4266
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4267 if (i <= qfl->qf_count)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4268 return i;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4269 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4270 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4271 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4272
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4273 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4274 * ":cc", ":crewind", ":cfirst" and ":clast".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4275 * ":ll", ":lrewind", ":lfirst" and ":llast".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4276 * ":cdo", ":ldo", ":cfdo" and ":lfdo"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4277 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4278 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4279 ex_cc(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4280 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4281 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
4282 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4283
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4284 if (eap->cmdidx == CMD_ll
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4285 || eap->cmdidx == CMD_lrewind
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4286 || eap->cmdidx == CMD_lfirst
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4287 || eap->cmdidx == CMD_llast
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4288 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4289 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4290 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4291 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4292 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4293 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4294 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4295 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4296 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4297 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4298
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4299 if (eap->addr_count > 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4300 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4301 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4302 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4303 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
4304 errornr = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4305 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
4306 || 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
4307 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4308 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4309 errornr = 32767;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4310 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4311
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4312 /* 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
4313 * 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
4314 */
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4315 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
4316 || 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
4317 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
4318 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
4319 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
4320
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4321 qf_jump(qi, 0, errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4324 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4325 * ":cnext", ":cnfile", ":cNext" and ":cprevious".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4326 * ":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
4327 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4328 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4329 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4330 ex_cnext(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4331 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4332 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
4333 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4334
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4335 if (eap->cmdidx == CMD_lnext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4336 || eap->cmdidx == CMD_lNext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4337 || eap->cmdidx == CMD_lprevious
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4338 || eap->cmdidx == CMD_lnfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4339 || eap->cmdidx == CMD_lNfile
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4340 || eap->cmdidx == CMD_lpfile
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4341 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4342 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4343 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4344 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4345 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4346 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4347 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4348 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4349 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4350 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4351
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4352 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
4353 && (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
4354 && 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
4355 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4356 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4357 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4358
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4359 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
4360 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4361 ? FORWARD
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4362 : (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
4363 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4364 ? FORWARD_FILE
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4365 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4366 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 ? BACKWARD_FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4368 : BACKWARD,
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
4369 errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4372 /*
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4373 * ":cfile"/":cgetfile"/":caddfile" commands.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4374 * ":lfile"/":lgetfile"/":laddfile" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4375 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4376 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4377 ex_cfile(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4378 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4379 char_u *enc = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4380 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4381 qf_info_T *qi = &ql_info;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4382 char_u *au_name = NULL;
13418
4db074f4394c patch 8.0.1583: using C99 comment
Christian Brabandt <cb@256bit.org>
parents: 13390
diff changeset
4383 int save_qfid = 0; /* init for gcc */
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4384 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4385
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4386 switch (eap->cmdidx)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4387 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4388 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
4389 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
4390 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
4391 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
4392 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
4393 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
4394 default: break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4395 }
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4396 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
4397 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf);
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
4398 #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
4399 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
4400 #endif
2296
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4401 #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
4402 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
4403 {
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4404 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg,
13802
378f9f8e6d8f patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents: 13800
diff changeset
4405 NULL, NULL,
378f9f8e6d8f patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents: 13800
diff changeset
4406 (char_u *)_(BROWSE_FILTER_ALL_FILES), NULL);
2296
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4407 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
4408 return;
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4409 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
4410 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
4411 }
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4412 else
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
4413 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4414 if (*eap->arg != NUL)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 682
diff changeset
4415 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
4416
13078
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4417 if (eap->cmdidx == CMD_lfile
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4418 || eap->cmdidx == CMD_lgetfile
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4419 || eap->cmdidx == CMD_laddfile)
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4420 wp = curwin;
a1f8939a4644 patch 8.0.1414: accessing freed memory in :lfile.
Christian Brabandt <cb@256bit.org>
parents: 13076
diff changeset
4421
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4422 /*
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4423 * This function is used by the :cfile, :cgetfile and :caddfile
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4424 * commands.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4425 * :cfile always creates a new quickfix list and jumps to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4426 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4427 * :cgetfile creates a new quickfix list but doesn't jump to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4428 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4429 * :caddfile adds to an existing quickfix list. If there is no
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4430 * quickfix list then a new list is created.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4431 */
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4432 res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
4433 && eap->cmdidx != CMD_laddfile),
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
4434 qf_cmdtitle(*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
4435 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
4436 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
4437 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
4438 qf_list_changed(qi, qi->qf_curlist);
13252
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4439 if (qi != NULL)
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4440 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
4441 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4442 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
13252
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4443
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4444 /* An autocmd might have freed the quickfix/location list. Check whether it
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4445 * is still valid. */
66b8b29854d9 patch 8.0.1500: possible NULL pointer dereference
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
4446 if (qi != NULL && !qflist_valid(wp, save_qfid))
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4447 return;
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
4448 if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile))
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4449 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 /*
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4453 * Return the quickfix/location list number with the given identifier.
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4454 * Returns -1 if list is not found.
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4455 */
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4456 static int
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4457 qf_id2nr(qf_info_T *qi, int_u qfid)
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4458 {
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4459 int qf_idx;
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4460
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4461 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++)
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4462 if (qi->qf_lists[qf_idx].qf_id == qfid)
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4463 return qf_idx;
13800
e4dc4ede9ef8 patch 8.0.1772: quickfix: mixup of FALSE and FAIL, returning -1
Christian Brabandt <cb@256bit.org>
parents: 13764
diff changeset
4464 return INVALID_QFIDX;
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4465 }
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4466
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4467 /*
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4468 * Return the vimgrep autocmd name.
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4469 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4470 static char_u *
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4471 vgr_get_auname(cmdidx_T cmdidx)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4472 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4473 switch (cmdidx)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4474 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4475 case CMD_vimgrep: return (char_u *)"vimgrep";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4476 case CMD_lvimgrep: return (char_u *)"lvimgrep";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4477 case CMD_vimgrepadd: return (char_u *)"vimgrepadd";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4478 case CMD_lvimgrepadd: return (char_u *)"lvimgrepadd";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4479 case CMD_grep: return (char_u *)"grep";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4480 case CMD_lgrep: return (char_u *)"lgrep";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4481 case CMD_grepadd: return (char_u *)"grepadd";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4482 case CMD_lgrepadd: return (char_u *)"lgrepadd";
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4483 default: return NULL;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4484 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4485 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4486
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4487 /*
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4488 * Initialize the regmatch used by vimgrep for pattern "s".
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4489 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4490 static void
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4491 vgr_init_regmatch(regmmatch_T *regmatch, char_u *s)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4492 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4493 /* Get the search pattern: either white-separated or enclosed in // */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4494 regmatch->regprog = NULL;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4495
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4496 if (s == NULL || *s == NUL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4497 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4498 /* Pattern is empty, use last search pattern. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4499 if (last_search_pat() == NULL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4500 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4501 EMSG(_(e_noprevre));
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4502 return;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4503 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4504 regmatch->regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4505 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4506 else
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4507 regmatch->regprog = vim_regcomp(s, RE_MAGIC);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4508
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4509 regmatch->rmm_ic = p_ic;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4510 regmatch->rmm_maxcol = 0;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4511 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4512
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4513 /*
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4514 * Display a file name when vimgrep is running.
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4515 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4516 static void
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4517 vgr_display_fname(char_u *fname)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4518 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4519 char_u *p;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4520
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4521 msg_start();
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4522 p = msg_strtrunc(fname, TRUE);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4523 if (p == NULL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4524 msg_outtrans(fname);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4525 else
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4526 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4527 msg_outtrans(p);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4528 vim_free(p);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4529 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4530 msg_clr_eos();
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4531 msg_didout = FALSE; /* overwrite this message */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4532 msg_nowait = TRUE; /* don't wait for this message */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4533 msg_col = 0;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4534 out_flush();
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4535 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4536
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4537 /*
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4538 * Load a dummy buffer to search for a pattern using vimgrep.
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4539 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4540 static buf_T *
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4541 vgr_load_dummy_buf(
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4542 char_u *fname,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4543 char_u *dirname_start,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4544 char_u *dirname_now)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4545 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4546 int save_mls;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4547 #if defined(FEAT_SYN_HL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4548 char_u *save_ei = NULL;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4549 #endif
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4550 buf_T *buf;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4551
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4552 #if defined(FEAT_SYN_HL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4553 /* Don't do Filetype autocommands to avoid loading syntax and
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4554 * indent scripts, a great speed improvement. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4555 save_ei = au_event_disable(",Filetype");
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4556 #endif
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4557 /* Don't use modelines here, it's useless. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4558 save_mls = p_mls;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4559 p_mls = 0;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4560
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4561 /* Load file into a buffer, so that 'fileencoding' is detected,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4562 * autocommands applied, etc. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4563 buf = load_dummy_buffer(fname, dirname_start, dirname_now);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4564
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4565 p_mls = save_mls;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4566 #if defined(FEAT_SYN_HL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4567 au_event_restore(save_ei);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4568 #endif
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4569
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4570 return buf;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4571 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4572
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4573 /*
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4574 * Check whether a quickfix/location list valid. Autocmds may remove or change
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4575 * a quickfix list when vimgrep is running. If the list is not found, create a
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4576 * new list.
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4577 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4578 static int
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4579 vgr_qflist_valid(
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4580 win_T *wp,
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4581 qf_info_T *qi,
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4582 int_u qfid,
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4583 char_u *title)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4584 {
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4585 /* Verify that the quickfix/location list was not freed by an autocmd */
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4586 if (!qflist_valid(wp, qfid))
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4587 {
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4588 if (wp != NULL)
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4589 {
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4590 /* An autocmd has freed the location list. */
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4591 EMSG(_(e_loc_list_changed));
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4592 return FALSE;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4593 }
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4594 else
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4595 {
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4596 /* Quickfix list is not found, create a new one. */
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4597 qf_new_list(qi, title);
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4598 return TRUE;
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4599 }
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4600 }
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4601
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4602 if (qi->qf_lists[qi->qf_curlist].qf_id != qfid)
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4603 /* Autocommands changed the quickfix list. Find the one we were
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4604 * using and restore it. */
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4605 qi->qf_curlist = qf_id2nr(qi, qfid);
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4606
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4607 return TRUE;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4608 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4609
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4610 /*
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4611 * Search for a pattern in all the lines in a buffer and add the matching lines
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4612 * to a quickfix list.
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4613 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4614 static int
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4615 vgr_match_buflines(
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4616 qf_info_T *qi,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4617 char_u *fname,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4618 buf_T *buf,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4619 regmmatch_T *regmatch,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4620 long tomatch,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4621 int duplicate_name,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4622 int flags)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4623 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4624 int found_match = FALSE;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4625 long lnum;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4626 colnr_T col;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4627
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4628 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; ++lnum)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4629 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4630 col = 0;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4631 while (vim_regexec_multi(regmatch, curwin, buf, lnum,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4632 col, NULL, NULL) > 0)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4633 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4634 /* Pass the buffer number so that it gets used even for a
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4635 * dummy buffer, unless duplicate_name is set, then the
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4636 * buffer will be wiped out below. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4637 if (qf_add_entry(qi,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4638 qi->qf_curlist,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4639 NULL, /* dir */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4640 fname,
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
4641 NULL,
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4642 duplicate_name ? 0 : buf->b_fnum,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4643 ml_get_buf(buf,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4644 regmatch->startpos[0].lnum + lnum, FALSE),
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4645 regmatch->startpos[0].lnum + lnum,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4646 regmatch->startpos[0].col + 1,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4647 FALSE, /* vis_col */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4648 NULL, /* search pattern */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4649 0, /* nr */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4650 0, /* type */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4651 TRUE /* valid */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4652 ) == FAIL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4653 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4654 got_int = TRUE;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4655 break;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4656 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4657 found_match = TRUE;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4658 if (--tomatch == 0)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4659 break;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4660 if ((flags & VGR_GLOBAL) == 0
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4661 || regmatch->endpos[0].lnum > 0)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4662 break;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4663 col = regmatch->endpos[0].col
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4664 + (col == regmatch->endpos[0].col);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4665 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE)))
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4666 break;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4667 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4668 line_breakcheck();
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4669 if (got_int)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4670 break;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4671 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4672
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4673 return found_match;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4674 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4675
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4676 /*
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4677 * Jump to the first match and update the directory.
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4678 */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4679 static void
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4680 vgr_jump_to_match(
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4681 qf_info_T *qi,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4682 int forceit,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4683 int *redraw_for_dummy,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4684 buf_T *first_match_buf,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4685 char_u *target_dir)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4686 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4687 buf_T *buf;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4688
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4689 buf = curbuf;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4690 qf_jump(qi, 0, 0, forceit);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4691 if (buf != curbuf)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4692 /* If we jumped to another buffer redrawing will already be
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4693 * taken care of. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4694 *redraw_for_dummy = FALSE;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4695
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4696 /* Jump to the directory used after loading the buffer. */
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4697 if (curbuf == first_match_buf && target_dir != NULL)
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4698 {
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4699 exarg_T ea;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4700
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4701 ea.arg = target_dir;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4702 ea.cmdidx = CMD_lcd;
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4703 ex_cd(&ea);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4704 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4705 }
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4706
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4707 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4708 * ":vimgrep {pattern} file(s)"
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4709 * ":vimgrepadd {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4710 * ":lvimgrep {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4711 * ":lvimgrepadd {pattern} file(s)"
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4712 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4713 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4714 ex_vimgrep(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4715 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4716 regmmatch_T regmatch;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4717 int fcount;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4718 char_u **fnames;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4719 char_u *fname;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4720 char_u *title;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4721 char_u *s;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4722 char_u *p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4723 int fi;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4724 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
4725 int_u save_qfid;
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4726 win_T *wp = NULL;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4727 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4728 int duplicate_name = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4729 int using_dummy;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4730 int redraw_for_dummy = FALSE;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4731 int found_match;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4732 buf_T *first_match_buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4733 time_t seconds = 0;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4734 aco_save_T aco;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4735 int flags = 0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4736 long tomatch;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4737 char_u *dirname_start = NULL;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4738 char_u *dirname_now = NULL;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4739 char_u *target_dir = NULL;
1683
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4740 char_u *au_name = NULL;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4741
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4742 au_name = vgr_get_auname(eap->cmdidx);
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4743 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
4744 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4745 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
4746 #ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4747 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4748 return;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4749 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
4750 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4751
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4752 if (eap->cmdidx == CMD_lgrep
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4753 || eap->cmdidx == CMD_lvimgrep
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4754 || eap->cmdidx == CMD_lgrepadd
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4755 || eap->cmdidx == CMD_lvimgrepadd)
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4756 {
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4757 qi = ll_get_or_alloc_list(curwin);
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4758 if (qi == NULL)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4759 return;
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4760 wp = curwin;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4761 }
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4762
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4763 if (eap->addr_count > 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4764 tomatch = eap->line2;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4765 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4766 tomatch = MAXLNUM;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4767
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4768 /* Get the search pattern: either white-separated or enclosed in // */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4769 regmatch.regprog = NULL;
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
4770 title = vim_strsave(qf_cmdtitle(*eap->cmdlinep));
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4771 p = skip_vimgrep_pat(eap->arg, &s, &flags);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4772 if (p == NULL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4773 {
282
33d9c918b8ab updated for version 7.0075
vimboss
parents: 277
diff changeset
4774 EMSG(_(e_invalpat));
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4775 goto theend;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4776 }
4197
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4777
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4778 vgr_init_regmatch(&regmatch, s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4779 if (regmatch.regprog == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4780 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4781
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4782 p = skipwhite(p);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4783 if (*p == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4784 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4785 EMSG(_("E683: File name missing or invalid pattern"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4786 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4787 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4788
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
4789 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4790 && eap->cmdidx != CMD_vimgrepadd
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4791 && eap->cmdidx != CMD_lvimgrepadd)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4792 || qi->qf_curlist == qi->qf_listcount)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4793 /* make place for a new list */
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
4794 qf_new_list(qi, title != NULL ? title : qf_cmdtitle(*eap->cmdlinep));
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4795
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4796 /* parse the list of arguments */
3620
4f1c511e71f8 updated for version 7.3.570
Bram Moolenaar <bram@vim.org>
parents: 3555
diff changeset
4797 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4798 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4799 if (fcount == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4800 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4801 EMSG(_(e_nomatch));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4802 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4803 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4804
7558
9a4c9dccd603 commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents: 7515
diff changeset
4805 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
4806 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
4807 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
4808 {
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4809 FreeWild(fcount, fnames);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4810 goto theend;
7662
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4811 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4812
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4813 /* Remember the current directory, because a BufRead autocommand that does
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4814 * ":lcd %:p:h" changes the meaning of short path names. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4815 mch_dirname(dirname_start, MAXPATHL);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4816
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4817 /* Remember the current quickfix list identifier, so that we can check for
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4818 * autocommands changing the current quickfix list. */
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4819 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
4820
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4821 seconds = (time_t)0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4822 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4823 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4824 fname = shorten_fname1(fnames[fi]);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4825 if (time(NULL) > seconds)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4826 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4827 /* 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
4828 * working on it. */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4829 seconds = time(NULL);
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4830 vgr_display_fname(fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4831 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4832
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4833 buf = buflist_findname_exp(fnames[fi]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4834 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4835 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4836 /* Remember that a buffer with this name already exists. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4837 duplicate_name = (buf != NULL);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4838 using_dummy = TRUE;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4839 redraw_for_dummy = TRUE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4840
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4841 buf = vgr_load_dummy_buf(fname, dirname_start, dirname_now);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4842 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4843 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4844 /* Use existing, loaded buffer. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4845 using_dummy = FALSE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4846
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4847 /* Check whether the quickfix list is still valid. When loading a
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4848 * buffer above, autocommands might have changed the quickfix list. */
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
4849 if (!vgr_qflist_valid(wp, qi, save_qfid, qf_cmdtitle(*eap->cmdlinep)))
13660
2d94fcb0277d patch 8.0.1702: leaking memory when autocommands make quickfix list invalid
Christian Brabandt <cb@256bit.org>
parents: 13612
diff changeset
4850 {
2d94fcb0277d patch 8.0.1702: leaking memory when autocommands make quickfix list invalid
Christian Brabandt <cb@256bit.org>
parents: 13612
diff changeset
4851 FreeWild(fcount, fnames);
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4852 goto theend;
13660
2d94fcb0277d patch 8.0.1702: leaking memory when autocommands make quickfix list invalid
Christian Brabandt <cb@256bit.org>
parents: 13612
diff changeset
4853 }
13594
4d55eb79178b patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13521
diff changeset
4854 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
4855
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4856 if (buf == NULL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4857 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4858 if (!got_int)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4859 smsg((char_u *)_("Cannot open file \"%s\""), fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4860 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4861 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4862 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4863 /* Try for a match in all lines of the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4864 * For ":1vimgrep" look for first match only. */
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4865 found_match = vgr_match_buflines(qi, fname, buf, &regmatch,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4866 tomatch, duplicate_name, flags);
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4867
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4868 if (using_dummy)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4869 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4870 if (found_match && first_match_buf == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4871 first_match_buf = buf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4872 if (duplicate_name)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4873 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4874 /* Never keep a dummy buffer if there is another buffer
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4875 * with the same name. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4876 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4877 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4878 }
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4879 else if (!cmdmod.hide
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4880 || buf->b_p_bh[0] == 'u' /* "unload" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4881 || buf->b_p_bh[0] == 'w' /* "wipe" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4882 || buf->b_p_bh[0] == 'd') /* "delete" */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4883 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4884 /* When no match was found we don't need to remember the
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4885 * buffer, wipe it out. If there was a match and it
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4886 * wasn't the first one or we won't jump there: only
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4887 * unload the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4888 * Ignore 'hidden' here, because it may lead to having too
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4889 * many swap files. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4890 if (!found_match)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4891 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4892 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4893 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4894 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4895 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4896 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4897 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
4898 /* 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
4899 buf->b_flags &= ~BF_DUMMY;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4900 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4901 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4902 }
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4903
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4904 if (buf != NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4905 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4906 /* 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
4907 buf->b_flags &= ~BF_DUMMY;
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4908
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4909 /* If the buffer is still loaded we need to use the
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4910 * directory we jumped to below. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4911 if (buf == first_match_buf
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4912 && target_dir == NULL
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4913 && STRCMP(dirname_start, dirname_now) != 0)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4914 target_dir = vim_strsave(dirname_now);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4915
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4916 /* The buffer is still loaded, the Filetype autocommands
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4917 * need to be done now, in that buffer. And the modelines
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4918 * need to be done (again). But not the window-local
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4919 * options! */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4920 aucmd_prepbuf(&aco, buf);
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
4921 #if defined(FEAT_SYN_HL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4922 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4923 buf->b_fname, TRUE, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4924 #endif
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4925 do_modelines(OPT_NOWIN);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4926 aucmd_restbuf(&aco);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4927 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4928 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4929 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4930 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4931
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4932 FreeWild(fcount, fnames);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4933
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4934 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4935 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
4936 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
4937 qf_list_changed(qi, qi->qf_curlist);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4938
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4939 qf_update_buffer(qi, NULL);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4940
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4941 if (au_name != NULL)
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4942 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4943 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
4944 /*
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4945 * 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
4946 * is still valid.
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4947 */
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
4948 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
4949 goto theend;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4950
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4951 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4952 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4953 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4954 if ((flags & VGR_NOJUMP) == 0)
13521
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4955 vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy,
15c856a1617b patch 8.0.1634: the ex_vimgrep() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13497
diff changeset
4956 first_match_buf, target_dir);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4957 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4958 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4959 EMSG2(_(e_nomatch2), s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4960
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4961 /* If we loaded a dummy buffer into the current window, the autocommands
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4962 * may have messed up things, need to redraw and recompute folds. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4963 if (redraw_for_dummy)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4964 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4965 #ifdef FEAT_FOLDING
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4966 foldUpdateAll(curwin);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4967 #else
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4968 redraw_later(NOT_VALID);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4969 #endif
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4970 }
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4971
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4972 theend:
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4973 vim_free(title);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4974 vim_free(dirname_now);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4975 vim_free(dirname_start);
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4976 vim_free(target_dir);
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
4977 vim_regfree(regmatch.regprog);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4978 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4979
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4980 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4981 * 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
4982 * 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
4983 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4984 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4985 restore_start_dir(char_u *dirname_start)
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4986 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4987 char_u *dirname_now = alloc(MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4988
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4989 if (NULL != dirname_now)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4990 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4991 mch_dirname(dirname_now, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4992 if (STRCMP(dirname_start, dirname_now) != 0)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4993 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4994 /* 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
4995 * appropriate ex command and executing it. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4996 exarg_T ea;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4997
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4998 ea.arg = dirname_start;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4999 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
5000 ex_cd(&ea);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5001 }
3974
4d1753f3e85c updated for version 7.3.742
Bram Moolenaar <bram@vim.org>
parents: 3965
diff changeset
5002 vim_free(dirname_now);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5003 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5004 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5005
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5006 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5007 * 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
5008 * 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
5009 * "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
5010 * 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
5011 * 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
5012 *
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5013 * 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
5014 * or wipe_dummy_buffer() later!
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5015 *
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5016 * Returns NULL if it fails.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5017 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5018 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5019 load_dummy_buffer(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5020 char_u *fname,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5021 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
5022 char_u *resulting_dir) /* out: new directory */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5023 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5024 buf_T *newbuf;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5025 bufref_T newbufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5026 bufref_T newbuf_to_wipe;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5027 int failed = TRUE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5028 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
5029 int readfile_result;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5030
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5031 /* Allocate a buffer without putting it in the buffer list. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5032 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5033 if (newbuf == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5034 return NULL;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5035 set_bufref(&newbufref, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5036
177
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
5037 /* Init the options. */
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
5038 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
5039
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5040 /* need to open the memfile before putting the buffer in a window */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5041 if (ml_open(newbuf) == OK)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5042 {
13056
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
5043 /* 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
5044 ++newbuf->b_locked;
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
5045
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5046 /* set curwin/curbuf to buf and save a few things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5047 aucmd_prepbuf(&aco, newbuf);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5048
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5049 /* Need to set the filename for autocommands. */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5050 (void)setfname(curbuf, fname, NULL, FALSE);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5051
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5052 /* Create swap file now to avoid the ATTENTION message. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5053 check_need_swap(TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5054
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5055 /* Remove the "dummy" flag, otherwise autocommands may not
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5056 * work. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5057 curbuf->b_flags &= ~BF_DUMMY;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5058
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5059 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
5060 readfile_result = readfile(fname, NULL,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5061 (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
5062 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
5063 --newbuf->b_locked;
b931b2751650 patch 8.0.1403: using freed buffer in grep command
Christian Brabandt <cb@256bit.org>
parents: 13026
diff changeset
5064 if (readfile_result == OK
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5065 && !got_int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5066 && !(curbuf->b_flags & BF_NEW))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5067 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5068 failed = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5069 if (curbuf != newbuf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5070 {
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
5071 /* Bloody autocommands changed the buffer! Can happen when
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
5072 * 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
5073 * 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
5074 * window stuff. */
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5075 set_bufref(&newbuf_to_wipe, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5076 newbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5077 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5078 }
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5079
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5080 /* restore curwin/curbuf and a few other things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
5081 aucmd_restbuf(&aco);
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5082 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
5083 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
5084
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
5085 /* 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
5086 * skip it. */
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
5087 newbuf->b_flags |= BF_DUMMY;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5088 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5089
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5090 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5091 * When autocommands/'autochdir' option changed directory: go back.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5092 * 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
5093 * important.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5094 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5095 mch_dirname(resulting_dir, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5096 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5097
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
5098 if (!bufref_valid(&newbufref))
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5099 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5100 if (failed)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5101 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5102 wipe_dummy_buffer(newbuf, dirname_start);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5103 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5104 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5105 return newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5106 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5107
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5108 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5109 * 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
5110 * 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
5111 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5112 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5113 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5114 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5115 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5116 if (curbuf != buf) /* safety check */
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5117 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
5118 #if defined(FEAT_EVAL)
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5119 cleanup_T cs;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5120
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5121 /* Reset the error/interrupt/exception state here so that aborting()
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5122 * returns FALSE when wiping out the buffer. Otherwise it doesn't
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5123 * work when got_int is set. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5124 enter_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5125 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5126
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5127 wipe_buffer(buf, FALSE);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5128
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
5129 #if defined(FEAT_EVAL)
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5130 /* Restore the error/interrupt/exception state if not discarded by a
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5131 * new aborting error, interrupt, or uncaught exception. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5132 leave_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5133 #endif
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5134 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5135 restore_start_dir(dirname_start);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5136 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5137 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5138
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5139 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5140 * 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
5141 * 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
5142 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5143 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5144 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5145 unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5146 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5147 if (curbuf != buf) /* safety check */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5148 {
3365
9ccdc4a69d8f updated for version 7.3.449
Bram Moolenaar <bram@vim.org>
parents: 3269
diff changeset
5149 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5150
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5151 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5152 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
5153 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5154 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5155
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5156 #if defined(FEAT_EVAL) || defined(PROTO)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5157 /*
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5158 * 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
5159 * 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
5160 */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5161 int
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5162 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
5163 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5164 qf_info_T *qi = qi_arg;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5165 dict_T *dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5166 char_u buf[2];
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5167 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5168 int i;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5169 int bufnum;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5170
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5171 if (qi == NULL)
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
5172 {
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5173 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
5174 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
5175 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5176 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
5177 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
5178 return FAIL;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5179 }
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
5180 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
5181
13800
e4dc4ede9ef8 patch 8.0.1772: quickfix: mixup of FALSE and FAIL, returning -1
Christian Brabandt <cb@256bit.org>
parents: 13764
diff changeset
5182 if (qf_idx == INVALID_QFIDX)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5183 qf_idx = qi->qf_curlist;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5184
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5185 if (qf_idx >= qi->qf_listcount
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5186 || qi->qf_lists[qf_idx].qf_count == 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5187 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5188
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5189 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
5190 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
5191 {
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5192 /* Handle entries with a non-existing buffer number. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5193 bufnum = qfp->qf_fnum;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5194 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5195 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5196
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5197 if ((dict = dict_alloc()) == NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5198 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5199 if (list_append_dict(list, dict) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5200 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5201
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5202 buf[0] = qfp->qf_type;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5203 buf[1] = NUL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5204 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5205 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5206 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5207 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5208 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
5209 || dict_add_nr_str(dict, "module", 0L,
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
5210 qfp->qf_module == NULL ? (char_u *)"" : qfp->qf_module) == FAIL
960
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
5211 || dict_add_nr_str(dict, "pattern", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
5212 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
5213 || dict_add_nr_str(dict, "text", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
5214 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5215 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5216 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5217 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5218
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5219 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5220 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5221 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5222 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5223 return OK;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5224 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5225
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5226 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5227 * 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
5228 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5229 enum {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5230 QF_GETLIST_NONE = 0x0,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5231 QF_GETLIST_TITLE = 0x1,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5232 QF_GETLIST_ITEMS = 0x2,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5233 QF_GETLIST_NR = 0x4,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5234 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
5235 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
5236 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
5237 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
5238 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
5239 QF_GETLIST_TICK = 0x100,
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
5240 QF_GETLIST_ALL = 0x1FF,
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5241 };
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5242
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5243 /*
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5244 * Parse text from 'di' and return the quickfix list items.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5245 * Existing quickfix lists are not modified.
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5246 */
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5247 static int
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5248 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
5249 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5250 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
5251 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
5252 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
5253 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
5254 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
5255
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5256 /* 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
5257 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
5258 {
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5259 /* 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
5260 * option setting
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5261 */
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5262 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
5263 {
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5264 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
5265 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
5266 return FAIL;
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5267 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
5268 }
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5269
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5270 l = list_alloc();
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
5271 if (l == NULL)
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
5272 return FAIL;
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
5273
12252
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5274 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
5275 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
5276 {
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5277 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
5278 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
5279
12321
2779d593a706 patch 8.0.1040: cannot use another error format in getqflist()
Christian Brabandt <cb@256bit.org>
parents: 12303
diff changeset
5280 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
5281 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
5282 {
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
5283 (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
5284 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
5285 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5286 free(qi);
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5287 }
12299
f4d00472e617 patch 8.0.1029: return value of getqflist() is inconsistent
Christian Brabandt <cb@256bit.org>
parents: 12287
diff changeset
5288 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
5289 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
5290 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5291
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5292 return status;
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5293 }
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5294
3d0e042ec13c patch 8.0.1006: quickfix list changes when parsing text with 'erroformat'
Christian Brabandt <cb@256bit.org>
parents: 12146
diff changeset
5295 /*
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
5296 * 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
5297 */
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
5298 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
5299 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
5300 {
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
5301 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
5302
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
5303 /* 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
5304 * 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
5305 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
5306 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
5307 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
5308 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
5309 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
5310 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
5311 }
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
5312
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
5313 /*
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5314 * Convert the keys in 'what' to quickfix list property flags.
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5315 */
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5316 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5317 qf_getprop_keys2flags(dict_T *what)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5318 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5319 int flags = QF_GETLIST_NONE;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5320
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5321 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
5322 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
5323
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5324 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
5325 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
5326
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5327 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
5328 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
5329
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5330 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
5331 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
5332
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 (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
5334 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
5335
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5336 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
5337 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
5338
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5339 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
5340 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
5341
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
5342 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
5343 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
5344
805f7fd40e0d patch 8.0.1112: can't get size or current index from quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12449
diff changeset
5345 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
5346 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
5347
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5348 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
5349 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
5350
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5351 return flags;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5352 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5353
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5354 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5355 * Return the quickfix list index based on 'nr' or 'id' in 'what'.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5356 * If 'nr' and 'id' are not present in 'what' then return the current
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5357 * quickfix list index.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5358 * If 'nr' is zero then return the current quickfix list index.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5359 * If 'nr' is '$' then return the last quickfix list index.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5360 * If 'id' is present then return the index of the quickfix list with that id.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5361 * If 'id' is zero then return the quickfix list index specified by 'nr'.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5362 * Return -1, if quickfix list is not present or if the stack is empty.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5363 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5364 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5365 qf_getprop_qfidx(qf_info_T *qi, dict_T *what)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5366 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5367 int qf_idx;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5368 dictitem_T *di;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5369
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5370 qf_idx = qi->qf_curlist; /* default is the current list */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5371 if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5372 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5373 /* Use the specified quickfix/location list */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5374 if (di->di_tv.v_type == VAR_NUMBER)
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5375 {
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5376 /* for zero use the current list */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5377 if (di->di_tv.vval.v_number != 0)
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5378 {
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5379 qf_idx = di->di_tv.vval.v_number - 1;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5380 if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5381 qf_idx = INVALID_QFIDX;
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5382 }
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5383 }
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5384 else if (di->di_tv.v_type == VAR_STRING
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5385 && di->di_tv.vval.v_string != NULL
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5386 && STRCMP(di->di_tv.vval.v_string, "$") == 0)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5387 /* Get the last quickfix list number */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5388 qf_idx = qi->qf_listcount - 1;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5389 else
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5390 qf_idx = INVALID_QFIDX;
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5391 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5392
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5393 if ((di = dict_find(what, (char_u *)"id", -1)) != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5394 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5395 /* Look for a list with the specified id */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5396 if (di->di_tv.v_type == VAR_NUMBER)
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5397 {
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5398 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5399 * For zero, use the current list or the list specified by 'nr'
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5400 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5401 if (di->di_tv.vval.v_number != 0)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5402 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5403 }
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5404 else
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5405 qf_idx = INVALID_QFIDX;
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5406 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5407
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5408 return qf_idx;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5409 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5410
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5411 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5412 * Return default values for quickfix list properties in retdict.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5413 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5414 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5415 qf_getprop_defaults(qf_info_T *qi, int flags, dict_T *retdict)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5416 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5417 int status = OK;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5418
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5419 if (flags & QF_GETLIST_TITLE)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5420 status = dict_add_nr_str(retdict, "title", 0L, (char_u *)"");
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5421 if ((status == OK) && (flags & QF_GETLIST_ITEMS))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5422 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5423 list_T *l = list_alloc();
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5424 if (l != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5425 status = dict_add_list(retdict, "items", l);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5426 else
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5427 status = FAIL;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5428 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5429 if ((status == OK) && (flags & QF_GETLIST_NR))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5430 status = dict_add_nr_str(retdict, "nr", 0L, NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5431 if ((status == OK) && (flags & QF_GETLIST_WINID))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5432 status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5433 if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5434 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5435 if ((status == OK) && (flags & QF_GETLIST_ID))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5436 status = dict_add_nr_str(retdict, "id", 0L, NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5437 if ((status == OK) && (flags & QF_GETLIST_IDX))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5438 status = dict_add_nr_str(retdict, "idx", 0L, NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5439 if ((status == OK) && (flags & QF_GETLIST_SIZE))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5440 status = dict_add_nr_str(retdict, "size", 0L, NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5441 if ((status == OK) && (flags & QF_GETLIST_TICK))
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5442 status = dict_add_nr_str(retdict, "changedtick", 0L, NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5443
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5444 return status;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5445 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5446
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5447 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5448 * Return the quickfix list title as 'title' in retdict
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5449 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5450 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5451 qf_getprop_title(qf_info_T *qi, int qf_idx, dict_T *retdict)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5452 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5453 char_u *t;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5454
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5455 t = qi->qf_lists[qf_idx].qf_title;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5456 if (t == NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5457 t = (char_u *)"";
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5458 return dict_add_nr_str(retdict, "title", 0L, t);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5459 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5460
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5461 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5462 * Return the quickfix list items/entries as 'items' in retdict
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5463 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5464 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5465 qf_getprop_items(qf_info_T *qi, int qf_idx, dict_T *retdict)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5466 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5467 int status = OK;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5468 list_T *l = list_alloc();
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5469 if (l != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5470 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5471 (void)get_errorlist(qi, NULL, qf_idx, l);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5472 dict_add_list(retdict, "items", l);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5473 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5474 else
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5475 status = FAIL;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5476
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5477 return status;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5478 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5479
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5480 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5481 * Return the quickfix list context (if any) as 'context' in retdict.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5482 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5483 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5484 qf_getprop_ctx(qf_info_T *qi, int qf_idx, dict_T *retdict)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5485 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5486 int status;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5487 dictitem_T *di;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5488
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5489 if (qi->qf_lists[qf_idx].qf_ctx != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5490 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5491 di = dictitem_alloc((char_u *)"context");
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5492 if (di != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5493 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5494 copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5495 status = dict_add(retdict, di);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5496 if (status == FAIL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5497 dictitem_free(di);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5498 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5499 else
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5500 status = FAIL;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5501 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5502 else
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5503 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5504
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5505 return status;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5506 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5507
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5508 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5509 * Return the quickfix list index as 'idx' in retdict
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5510 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5511 static int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5512 qf_getprop_idx(qf_info_T *qi, int qf_idx, dict_T *retdict)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5513 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5514 int idx = qi->qf_lists[qf_idx].qf_index;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5515 if (qi->qf_lists[qf_idx].qf_count == 0)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5516 /* For empty lists, qf_index is set to 1 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5517 idx = 0;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5518 return dict_add_nr_str(retdict, "idx", idx, NULL);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5519 }
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5520
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5521 /*
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5522 * Return quickfix/location list details (title) as a
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5523 * dictionary. 'what' contains the details to return. If 'list_idx' is -1,
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5524 * then current list is used. Otherwise the specified list is used.
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5525 */
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5526 int
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5527 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5528 {
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5529 qf_info_T *qi = &ql_info;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5530 int status = OK;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5531 int qf_idx;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5532 dictitem_T *di;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5533 int flags = QF_GETLIST_NONE;
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5534
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5535 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5536 return qf_get_list_from_lines(what, di, retdict);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5537
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5538 if (wp != NULL)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5539 qi = GET_LOC_LIST(wp);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5540
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5541 flags = qf_getprop_keys2flags(what);
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5542
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5543 if (qi != NULL && qi->qf_listcount != 0)
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5544 qf_idx = qf_getprop_qfidx(qi, what);
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5545
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5546 /* List is not present or is empty */
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5547 if (qi == NULL || qi->qf_listcount == 0 || qf_idx == INVALID_QFIDX)
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5548 return qf_getprop_defaults(qi, flags, retdict);
13026
7c0e0e923537 patch 8.0.1389: getqflist() items are missing if not set
Christian Brabandt <cb@256bit.org>
parents: 13016
diff changeset
5549
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5550 if (flags & QF_GETLIST_TITLE)
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5551 status = qf_getprop_title(qi, qf_idx, retdict);
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5552 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
5553 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
5554 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
5555 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
5556 if ((status == OK) && (flags & QF_GETLIST_ITEMS))
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5557 status = qf_getprop_items(qi, qf_idx, retdict);
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5558 if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5559 status = qf_getprop_ctx(qi, qf_idx, retdict);
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5560 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
5561 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
5562 NULL);
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
5563 if ((status == OK) && (flags & QF_GETLIST_IDX))
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
5564 status = qf_getprop_idx(qi, qf_idx, retdict);
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
5565 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
5566 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
5567 qi->qf_lists[qf_idx].qf_count, NULL);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5568 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
5569 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
5570 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
5571
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5572 return status;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5573 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5574
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5575 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5576 * 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
5577 * a dictionary with item information.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5578 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5579 static int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5580 qf_add_entries(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5581 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
5582 int qf_idx,
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5583 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5584 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5585 int action)
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5586 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5587 listitem_T *li;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5588 dict_T *d;
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
5589 char_u *filename, *module, *pattern, *text, *type;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5590 int bufnum;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5591 long lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5592 int col, nr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5593 int vcol;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
5594 qfline_T *old_last = NULL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5595 int valid, status;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5596 int retval = OK;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5597 int did_bufnr_emsg = FALSE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5598
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5599 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
5600 {
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
5601 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
5602 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
5603 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
5604 }
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5605 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
5606 /* 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
5607 old_last = qi->qf_lists[qf_idx].qf_last;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
5608 else if (action == 'r')
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
5609 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5610 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
5611 qf_store_title(qi, qf_idx, title);
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
5612 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5613
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5614 for (li = list->lv_first; li != NULL; li = li->li_next)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5615 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5616 if (li->li_tv.v_type != VAR_DICT)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5617 continue; /* Skip non-dict items */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5618
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5619 d = li->li_tv.vval.v_dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5620 if (d == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5621 continue;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5622
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5623 filename = get_dict_string(d, (char_u *)"filename", TRUE);
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
5624 module = get_dict_string(d, (char_u *)"module", TRUE);
9389
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
5625 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
5626 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
5627 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
5628 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
5629 nr = (int)get_dict_number(d, (char_u *)"nr");
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5630 type = get_dict_string(d, (char_u *)"type", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5631 pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5632 text = get_dict_string(d, (char_u *)"text", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5633 if (text == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5634 text = vim_strsave((char_u *)"");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5635
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5636 valid = TRUE;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5637 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5638 valid = FALSE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5639
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5640 /* Mark entries with non-existing buffer number as not valid. Give the
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5641 * error message only once. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5642 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5643 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5644 if (!did_bufnr_emsg)
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5645 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5646 did_bufnr_emsg = TRUE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5647 EMSGN(_("E92: Buffer %ld not found"), bufnum);
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5648 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5649 valid = FALSE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5650 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5651 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5652
11390
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
5653 /* 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
5654 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
5655 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
5656
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5657 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
5658 qf_idx,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5659 NULL, /* dir */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5660 filename,
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
5661 module,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5662 bufnum,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5663 text,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5664 lnum,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5665 col,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5666 vcol, /* vis_col */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5667 pattern, /* search pattern */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5668 nr,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5669 type == NULL ? NUL : *type,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5670 valid);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5671
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5672 vim_free(filename);
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
5673 vim_free(module);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5674 vim_free(pattern);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5675 vim_free(text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5676 vim_free(type);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5677
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5678 if (status == FAIL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5679 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5680 retval = FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5681 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5682 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5683 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5684
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5685 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
5686 /* 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
5687 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
5688 else
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5689 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
5690 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
5691 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
5692 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
5693 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
5694 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
5695 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
5696 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5697
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
5698 /* 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
5699 qf_update_buffer(qi, old_last);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5700
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5701 return retval;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5702 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5703
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5704 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5705 * Get the quickfix list index from 'nr' or 'id'
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5706 */
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5707 static int
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5708 qf_setprop_get_qfidx(
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5709 qf_info_T *qi,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5710 dict_T *what,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5711 int action,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5712 int *newlist)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5713 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5714 dictitem_T *di;
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5715 int qf_idx = qi->qf_curlist; /* default is the current list */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5716
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5717 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
5718 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5719 /* Use the specified quickfix/location list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5720 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
5721 {
11445
461ac47c3793 patch 8.0.0606: cannot set the context for a specified quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11443
diff changeset
5722 /* 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
5723 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
5724 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
5725
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5726 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
5727 {
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5728 /*
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5729 * 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
5730 * 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
5731 * stack.
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5732 */
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5733 *newlist = TRUE;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5734 qf_idx = qi->qf_listcount > 0 ? qi->qf_listcount - 1 : 0;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5735 }
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5736 else if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5737 return INVALID_QFIDX;
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5738 else if (action != ' ')
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5739 *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
5740 }
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5741 else if (di->di_tv.v_type == VAR_STRING
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5742 && di->di_tv.vval.v_string != NULL
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5743 && 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
5744 {
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5745 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
5746 qf_idx = qi->qf_listcount - 1;
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5747 else if (*newlist)
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5748 qf_idx = 0;
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5749 else
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5750 return INVALID_QFIDX;
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5751 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5752 else
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5753 return INVALID_QFIDX;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5754 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5755
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5756 if (!*newlist && (di = dict_find(what, (char_u *)"id", -1)) != 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
5757 {
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5758 /* Use the quickfix/location list with the specified id */
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5759 if (di->di_tv.v_type != VAR_NUMBER)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5760 return INVALID_QFIDX;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5761
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5762 return qf_id2nr(qi, di->di_tv.vval.v_number);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5763 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5764
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5765 return qf_idx;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5766 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5767
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5768 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5769 * Set the quickfix list title.
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5770 */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5771 static int
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5772 qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5773 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5774 if (di->di_tv.v_type != VAR_STRING)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5775 return FAIL;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5776
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5777 vim_free(qi->qf_lists[qf_idx].qf_title);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5778 qi->qf_lists[qf_idx].qf_title =
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5779 get_dict_string(what, (char_u *)"title", TRUE);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5780 if (qf_idx == qi->qf_curlist)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5781 qf_update_win_titlevar(qi);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5782
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5783 return OK;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5784 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5785
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5786 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5787 * Set quickfix list items/entries.
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5788 */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5789 static int
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5790 qf_setprop_items(qf_info_T *qi, int qf_idx, dictitem_T *di, int action)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5791 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5792 int retval = FAIL;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5793 char_u *title_save;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5794
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5795 if (di->di_tv.v_type != VAR_LIST)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5796 return FAIL;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5797
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5798 title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5799 retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5800 title_save, action == ' ' ? 'a' : action);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5801 if (action == 'r')
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5802 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5803 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5804 * When replacing the quickfix list entries using
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5805 * qf_add_entries(), the title is set with a ':' prefix.
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5806 * Restore the title with the saved title.
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5807 */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5808 vim_free(qi->qf_lists[qf_idx].qf_title);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5809 qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5810 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5811 vim_free(title_save);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5812
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5813 return retval;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5814 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5815
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5816 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5817 * Set quickfix list items/entries from a list of lines.
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5818 */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5819 static int
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5820 qf_setprop_items_from_lines(
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5821 qf_info_T *qi,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5822 int qf_idx,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5823 dict_T *what,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5824 dictitem_T *di,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5825 int action)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5826 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5827 char_u *errorformat = p_efm;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5828 dictitem_T *efm_di;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5829 int retval = FAIL;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5830
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5831 /* Use the user supplied errorformat settings (if present) */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5832 if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5833 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5834 if (efm_di->di_tv.v_type != VAR_STRING ||
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5835 efm_di->di_tv.vval.v_string == 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
5836 return FAIL;
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5837 errorformat = efm_di->di_tv.vval.v_string;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5838 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5839
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5840 /* Only a List value is supported */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5841 if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5842 return FAIL;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5843
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5844 if (action == 'r')
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5845 qf_free_items(qi, qf_idx);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5846 if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat,
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5847 FALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5848 retval = OK;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5849
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5850 return retval;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5851 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5852
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5853 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5854 * Set quickfix list context.
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5855 */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5856 static int
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5857 qf_setprop_context(qf_info_T *qi, int qf_idx, dictitem_T *di)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5858 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5859 typval_T *ctx;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5860
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5861 free_tv(qi->qf_lists[qf_idx].qf_ctx);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5862 ctx = alloc_tv();
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5863 if (ctx != NULL)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5864 copy_tv(&di->di_tv, ctx);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5865 qi->qf_lists[qf_idx].qf_ctx = ctx;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5866
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5867 return OK;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5868 }
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5869
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5870 /*
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5871 * Set quickfix/location list properties (title, items, context).
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5872 * Also used to add items from parsing a list of lines.
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
5873 * Used by the setqflist() and setloclist() Vim script functions.
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5874 */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5875 static int
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5876 qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5877 {
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5878 dictitem_T *di;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5879 int retval = FAIL;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5880 int qf_idx;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5881 int newlist = FALSE;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5882
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5883 if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5884 newlist = TRUE;
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5885
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5886 qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist);
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5887 if (qf_idx == INVALID_QFIDX) /* List not found */
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5888 return FAIL;
12287
20641a7e1fc9 patch 8.0.1023: it is not easy to identify a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
5889
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5890 if (newlist)
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5891 {
12084
69ce6b3f0834 patch 8.0.0922: quickfix list always added after current one
Christian Brabandt <cb@256bit.org>
parents: 12048
diff changeset
5892 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
5893 qf_new_list(qi, title);
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5894 qf_idx = qi->qf_curlist;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5895 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5896
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5897 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL)
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5898 retval = qf_setprop_title(qi, qf_idx, what, di);
11549
f5add45f9848 patch 8.0.0657: cannot get and set quickfix list items
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
5899 if ((di = dict_find(what, (char_u *)"items", -1)) != NULL)
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5900 retval = qf_setprop_items(qi, qf_idx, di, action);
12303
ec7a4fd21dd5 patch 8.0.1031: "text" argument for getqflist() is confusing
Christian Brabandt <cb@256bit.org>
parents: 12299
diff changeset
5901 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL)
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5902 retval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action);
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5903 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL)
13760
aef8ba129a4f patch 8.0.1752: qf_set_properties() is to long
Christian Brabandt <cb@256bit.org>
parents: 13756
diff changeset
5904 retval = qf_setprop_context(qi, qf_idx, di);
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5905
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
5906 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
5907 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
5908
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5909 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5910 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5911
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5912 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5913 * 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
5914 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5915 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
5916 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
5917 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5918 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
5919
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5920 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
5921 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
5922 return wp;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5923
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5924 return NULL;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5925 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5926
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5927 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5928 * 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
5929 * 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
5930 */
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5931 static void
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5932 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
5933 {
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5934 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
5935 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
5936 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
5937
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5938 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
5939 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5940 /* 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
5941 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
5942 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
5943 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
5944 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5945
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5946 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
5947 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5948 /* 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
5949 * 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
5950 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5951 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
5952 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
5953 wp = llwin;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5954 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5955
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5956 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
5957 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
5958 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5959 /* quickfix list */
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5960 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
5961 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
5962 }
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5963 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
5964 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5965 /* 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
5966 * location list */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5967 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
5968
11398
30af33f4d353 patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents: 11390
diff changeset
5969 /* 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
5970 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
5971
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5972 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
5973 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
5974 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5975 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
5976 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
5977 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
5978 }
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5979 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5980
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5981 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5982 * 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
5983 * 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
5984 * "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
5985 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5986 int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5987 set_errorlist(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5988 win_T *wp,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5989 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5990 int action,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5991 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5992 dict_T *what)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5993 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5994 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5995 int retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5996
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5997 if (wp != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5998 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5999 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
6000 if (qi == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
6001 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
6002 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
6003
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
6004 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
6005 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
6006 /* 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
6007 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
6008 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
6009 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
6010 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
6011 else
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
6012 {
11449
d2f00eb352b9 patch 8.0.0608: cannot manipulate other than the current quickfix list
Christian Brabandt <cb@256bit.org>
parents: 11447
diff changeset
6013 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
6014 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
6015 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
6016 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
6017
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
6018 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
6019 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6020
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6021 /*
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6022 * Mark the context as in use for all the lists in a quickfix stack.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6023 */
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6024 static int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6025 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
6026 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6027 int i;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6028 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6029 typval_T *ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6030
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6031 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
6032 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6033 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
6034 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
6035 && 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
6036 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
6037 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6038
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6039 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6040 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6041
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6042 /*
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6043 * Mark the context of the quickfix list and the location lists (if present) as
13710
b33f04873475 patch 8.0.1727: qf_get_properties() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13660
diff changeset
6044 * "in use". So that garbage collection doesn't free the context.
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6045 */
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6046 int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6047 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
6048 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6049 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6050 tabpage_T *tp;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6051 win_T *win;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6052
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6053 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
6054 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6055 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6056
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6057 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
6058 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6059 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
6060 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6061 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
6062 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6063 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6064 }
13074
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
6065 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
6066 {
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
6067 /* 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
6068 * 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
6069 * context as still in use.
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
6070 */
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
6071 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
6072 if (abort)
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
6073 return abort;
66c014c71dad patch 8.0.1412: using free memory using setloclist()
Christian Brabandt <cb@256bit.org>
parents: 13066
diff changeset
6074 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6075 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6076
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6077 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
6078 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
6079 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
6080
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
6081 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6082 * ":[range]cbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
6083 * ":[range]caddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
6084 * ":[range]cgetbuffer [bufnr]" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6085 * ":[range]lbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
6086 * ":[range]laddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
6087 * ":[range]lgetbuffer [bufnr]" command.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6088 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6089 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6090 ex_cbuffer(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6091 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6092 buf_T *buf = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6093 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
6094 char_u *au_name = NULL;
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6095 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6096
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6097 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6098 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6099 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
6100 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
6101 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
6102 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
6103 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
6104 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
6105 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6106 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
6107 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
6108 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6109 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
6110 #ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
6111 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6112 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6113 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
6114 }
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6115
13076
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6116 /* Must come after autocommands. */
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6117 if (eap->cmdidx == CMD_lbuffer
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6118 || eap->cmdidx == CMD_lgetbuffer
13076
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6119 || eap->cmdidx == CMD_laddbuffer)
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6120 {
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6121 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
6122 if (qi == NULL)
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6123 return;
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6124 }
7c071a3f7f8e patch 8.0.1413: accessing freed memory in :cbuffer
Christian Brabandt <cb@256bit.org>
parents: 13074
diff changeset
6125
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6126 if (*eap->arg == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6127 buf = curbuf;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6128 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6129 buf = buflist_findnr(atoi((char *)eap->arg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6130 if (buf == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6131 EMSG(_(e_invarg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6132 else if (buf->b_ml.ml_mfp == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6133 EMSG(_("E681: Buffer is not loaded"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6134 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6135 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6136 if (eap->addr_count == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6137 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6138 eap->line1 = 1;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6139 eap->line2 = buf->b_ml.ml_line_count;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6140 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6141 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6142 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6143 EMSG(_(e_invrange));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6144 else
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
6145 {
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
6146 char_u *qf_title = qf_cmdtitle(*eap->cmdlinep);
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
6147
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
6148 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
6149 {
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
6150 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
6151 (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
6152 qf_title = IObuff;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
6153 }
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
6154
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6155 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
6156 (eap->cmdidx != CMD_caddbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
6157 && 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
6158 eap->line1, eap->line2,
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6159 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
6160 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
6161 qf_list_changed(qi, qi->qf_curlist);
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6162 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6163 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
6164 curbuf->b_fname, TRUE, curbuf);
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6165 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
6166 eap->cmdidx == CMD_lbuffer))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6167 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
6168 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6169 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6170 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6171
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
6172 #if defined(FEAT_EVAL) || defined(PROTO)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
6173 /*
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
6174 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command.
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
6175 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command.
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6176 */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6177 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6178 ex_cexpr(exarg_T *eap)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6179 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6180 typval_T *tv;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6181 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
6182 char_u *au_name = NULL;
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6183 int res;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6184
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6185 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6186 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6187 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
6188 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
6189 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
6190 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
6191 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
6192 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
6193 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6194 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
6195 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
6196 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6197 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
6198 #ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
6199 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6200 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6201 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
6202 }
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6203
13090
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6204 if (eap->cmdidx == CMD_lexpr
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6205 || eap->cmdidx == CMD_lgetexpr
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6206 || eap->cmdidx == CMD_laddexpr)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6207 {
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6208 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
6209 if (qi == NULL)
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6210 return;
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6211 }
a0c6910e7fa4 patch 8.0.1420: accessing freed memory in vimgrep
Christian Brabandt <cb@256bit.org>
parents: 13078
diff changeset
6212
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6213 /* 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
6214 * use it to fill the errorlist. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6215 tv = eval_expr(eap->arg, NULL);
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6216 if (tv != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6217 {
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6218 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6219 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6220 {
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6221 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
6222 (eap->cmdidx != CMD_caddexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
6223 && eap->cmdidx != CMD_laddexpr),
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
6224 (linenr_T)0, (linenr_T)0,
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
6225 qf_cmdtitle(*eap->cmdlinep), NULL);
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
6226 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
6227 qf_list_changed(qi, qi->qf_curlist);
12954
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6228 if (au_name != NULL)
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6229 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
6230 curbuf->b_fname, TRUE, curbuf);
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6231 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
6232 eap->cmdidx == CMD_lexpr))
49e136457c66 patch 8.0.1353: QuickFixCmdPost is not used consistently
Christian Brabandt <cb@256bit.org>
parents: 12912
diff changeset
6233 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6234 }
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6235 else
626
732c7ae5743e updated for version 7.0180
vimboss
parents: 625
diff changeset
6236 EMSG(_("E777: String or List expected"));
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6237 free_tv(tv);
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
6238 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6239 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
6240 #endif
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6241
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
6242 /*
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6243 * Get the location list for ":lhelpgrep"
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6244 */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6245 static qf_info_T *
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6246 hgr_get_ll(int *new_ll)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6247 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6248 win_T *wp;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6249 qf_info_T *qi;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6250
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6251 /* If the current window is a help window, then use it */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6252 if (bt_help(curwin->w_buffer))
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6253 wp = curwin;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6254 else
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6255 /* Find an existing help window */
13882
f48fcaa196a9 patch 8.0.1812: the qf_jump_to_usable_window() function is too long
Christian Brabandt <cb@256bit.org>
parents: 13868
diff changeset
6256 wp = qf_find_help_win();
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6257
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6258 if (wp == NULL) /* Help window not found */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6259 qi = NULL;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6260 else
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6261 qi = wp->w_llist;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6262
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6263 if (qi == NULL)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6264 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6265 /* Allocate a new location list for help text matches */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6266 if ((qi = ll_new_list()) == NULL)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6267 return NULL;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6268 *new_ll = TRUE;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6269 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6270
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6271 return qi;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6272 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6273
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6274 /*
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6275 * Search for a pattern in a help file.
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6276 */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6277 static void
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6278 hgr_search_file(
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6279 qf_info_T *qi,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6280 char_u *fname,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6281 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6282 vimconv_T *p_vc,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6283 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6284 regmatch_T *p_regmatch)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6285 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6286 FILE *fd;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6287 long lnum;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6288
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6289 fd = mch_fopen((char *)fname, "r");
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6290 if (fd == NULL)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6291 return;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6292
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6293 lnum = 1;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6294 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6295 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6296 char_u *line = IObuff;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6297 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6298 /* Convert a line if 'encoding' is not utf-8 and
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6299 * the line contains a non-ASCII character. */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6300 if (p_vc->vc_type != CONV_NONE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6301 && has_non_ascii(IObuff))
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6302 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6303 line = string_convert(p_vc, IObuff, NULL);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6304 if (line == NULL)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6305 line = IObuff;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6306 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6307 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6308
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6309 if (vim_regexec(p_regmatch, line, (colnr_T)0))
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6310 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6311 int l = (int)STRLEN(line);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6312
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6313 /* remove trailing CR, LF, spaces, etc. */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6314 while (l > 0 && line[l - 1] <= ' ')
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6315 line[--l] = NUL;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6316
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6317 if (qf_add_entry(qi,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6318 qi->qf_curlist,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6319 NULL, /* dir */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6320 fname,
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
6321 NULL,
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6322 0,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6323 line,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6324 lnum,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6325 (int)(p_regmatch->startp[0] - line)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6326 + 1, /* col */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6327 FALSE, /* vis_col */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6328 NULL, /* search pattern */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6329 0, /* nr */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6330 1, /* type */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6331 TRUE /* valid */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6332 ) == FAIL)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6333 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6334 got_int = TRUE;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6335 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6336 if (line != IObuff)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6337 vim_free(line);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6338 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6339 break;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6340 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6341 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6342 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6343 if (line != IObuff)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6344 vim_free(line);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6345 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6346 ++lnum;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6347 line_breakcheck();
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6348 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6349 fclose(fd);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6350 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6351
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6352 /*
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6353 * Search for a pattern in all the help files in the doc directory under
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6354 * the given directory.
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6355 */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6356 static void
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6357 hgr_search_files_in_dir(
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6358 qf_info_T *qi,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6359 char_u *dirname,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6360 regmatch_T *p_regmatch
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6361 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6362 , vimconv_T *p_vc
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6363 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6364 #ifdef FEAT_MULTI_LANG
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6365 , char_u *lang
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6366 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6367 )
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6368 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6369 int fcount;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6370 char_u **fnames;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6371 int fi;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6372
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6373 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6374 add_pathsep(dirname);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6375 STRCAT(dirname, "doc/*.\\(txt\\|??x\\)");
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6376 if (gen_expand_wildcards(1, &dirname, &fcount,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6377 &fnames, EW_FILE|EW_SILENT) == OK
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6378 && fcount > 0)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6379 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6380 for (fi = 0; fi < fcount && !got_int; ++fi)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6381 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6382 #ifdef FEAT_MULTI_LANG
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6383 /* Skip files for a different language. */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6384 if (lang != NULL
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6385 && STRNICMP(lang, fnames[fi]
13821
98274127d675 patch 8.0.1782: no simple way to label quickfix entries
Christian Brabandt <cb@256bit.org>
parents: 13819
diff changeset
6386 + STRLEN(fnames[fi]) - 3, 2) != 0
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6387 && !(STRNICMP(lang, "en", 2) == 0
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6388 && STRNICMP("txt", fnames[fi]
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6389 + STRLEN(fnames[fi]) - 3, 3) == 0))
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6390 continue;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6391 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6392
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6393 hgr_search_file(qi, fnames[fi],
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6394 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6395 p_vc,
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6396 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6397 p_regmatch);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6398 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6399 FreeWild(fcount, fnames);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6400 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6401 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6402
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6403 /*
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6404 * Search for a pattern in all the help files in the 'runtimepath'
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6405 * and add the matches to a quickfix list.
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6406 * 'arg' is the language specifier. If supplied, then only matches in the
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6407 * specified language are found.
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6408 */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6409 static void
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6410 hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *arg)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6411 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6412 char_u *p;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6413 #ifdef FEAT_MULTI_LANG
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6414 char_u *lang;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6415 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6416
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6417 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6418 vimconv_T vc;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6419
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6420 /* Help files are in utf-8 or latin1, convert lines when 'encoding'
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6421 * differs. */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6422 vc.vc_type = CONV_NONE;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6423 if (!enc_utf8)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6424 convert_setup(&vc, (char_u *)"utf-8", p_enc);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6425 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6426
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6427 #ifdef FEAT_MULTI_LANG
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6428 /* Check for a specified language */
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6429 lang = check_help_lang(arg);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6430 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6431
13868
1282a54c1f5a patch 8.0.1805: qf_parse_line() is too long
Christian Brabandt <cb@256bit.org>
parents: 13821
diff changeset
6432 /* Go through all the directories in 'runtimepath' */
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6433 p = p_rtp;
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6434 while (*p != NUL && !got_int)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6435 {
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6436 copy_option_part(&p, NameBuff, MAXPATHL, ",");
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6437
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6438 hgr_search_files_in_dir(qi, NameBuff, p_regmatch
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6439 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6440 , &vc
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6441 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6442 #ifdef FEAT_MULTI_LANG
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6443 , lang
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6444 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6445 );
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6446 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6447
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6448 #ifdef FEAT_MBYTE
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6449 if (vc.vc_type != CONV_NONE)
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6450 convert_setup(&vc, NULL, NULL);
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6451 #endif
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6452 }
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6453
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6454 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6455 * ":helpgrep {pattern}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6456 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6457 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6458 ex_helpgrep(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6460 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6461 char_u *save_cpo;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6462 qf_info_T *qi = &ql_info;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6463 int new_qi = FALSE;
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6464 char_u *au_name = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6466 switch (eap->cmdidx)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6467 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6468 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
6469 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
6470 default: break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6471 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
6472 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
6473 curbuf->b_fname, TRUE, curbuf))
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6474 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
6475 #ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
6476 if (aborting())
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6477 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6478 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13252
diff changeset
6479 }
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6480
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6481 /* 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
6482 save_cpo = p_cpo;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6483 p_cpo = empty_option;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6484
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6485 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6486 {
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6487 qi = hgr_get_ll(&new_qi);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6488 if (qi == NULL)
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6489 return;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6490 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6491
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6492 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6493 regmatch.rm_ic = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494 if (regmatch.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496 /* create a new quickfix list */
13921
3b6c29f8c1a2 patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Christian Brabandt <cb@256bit.org>
parents: 13882
diff changeset
6497 qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6498
13764
7bba231fdddc patch 8.0.1754: ex_helpgrep() is too long
Christian Brabandt <cb@256bit.org>
parents: 13760
diff changeset
6499 hgr_search_in_rtp(qi, &regmatch, eap->arg);
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
6500
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
6501 vim_regfree(regmatch.regprog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6502
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6503 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6504 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6505 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6506 qi->qf_lists[qi->qf_curlist].qf_index = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508
1672
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
6509 if (p_cpo == empty_option)
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
6510 p_cpo = save_cpo;
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
6511 else
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
6512 /* Darn, some plugin changed the value. */
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
6513 free_string_option(save_cpo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6514
13062
6479dadcf214 patch 8.0.1406: difficult to track changes to a quickfix list
Christian Brabandt <cb@256bit.org>
parents: 13056
diff changeset
6515 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
6516 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6517
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6518 if (au_name != NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6519 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6520 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6521 curbuf->b_fname, TRUE, curbuf);
13756
c38f29387245 patch 8.0.1750: crash when clearing loccation list in autocommand
Christian Brabandt <cb@256bit.org>
parents: 13710
diff changeset
6522 if (!new_qi && qi != &ql_info && qf_find_buf(qi) == NULL)
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6523 /* autocommands made "qi" invalid */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6524 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6525 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
6526
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
6528 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6529 qf_jump(qi, 0, 0, FALSE);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6530 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6531 EMSG2(_(e_nomatch2), eap->arg);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6532
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6533 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6534 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6535 /* 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
6536 * 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
6537 if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6538 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6539 if (new_qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6540 ll_free_all(&qi);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6541 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6542 else if (curwin->w_llist == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6543 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
6544 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6547 #endif /* FEAT_QUICKFIX */