annotate src/quickfix.c @ 11412:84baca75b7f2 v8.0.0590

patch 8.0.0590: cannot add a context to locations commit https://github.com/vim/vim/commit/8f77c5a4ec756f3f866bd6b18feb6fca6f2a2e91 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 30 14:21:00 2017 +0200 patch 8.0.0590: cannot add a context to locations Problem: Cannot add a context to locations. Solution: Add the "context" entry in location entries. (Yegappan Lakshmanan, closes #1012)
author Christian Brabandt <cb@256bit.org>
date Sun, 30 Apr 2017 14:30:04 +0200
parents 30af33f4d353
children ad4b56939140
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9982
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * quickfix.c: functions for quickfix mode, using a file with error messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #if defined(FEAT_QUICKFIX) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 struct dir_stack_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 struct dir_stack_T *next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char_u *dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 /*
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
25 * For each error the next struct is allocated and linked in a list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
27 typedef struct qfline_S qfline_T;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
28 struct qfline_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
30 qfline_T *qf_next; /* pointer to next error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
31 qfline_T *qf_prev; /* pointer to previous error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
32 linenr_T qf_lnum; /* line number where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
33 int qf_fnum; /* file number for the line */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
34 int qf_col; /* column where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
35 int qf_nr; /* error number */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
36 char_u *qf_pattern; /* search pattern for the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
37 char_u *qf_text; /* description of the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
38 char_u qf_viscol; /* set to TRUE if qf_col is screen column */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
39 char_u qf_cleared; /* set to TRUE if line has been deleted */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
40 char_u qf_type; /* type of the error (mostly 'E'); 1 for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 :helpgrep */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
42 char_u qf_valid; /* valid error message detected */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 * There is a stack of error lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #define LISTCOUNT 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
50 typedef struct qf_list_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
52 qfline_T *qf_start; /* pointer to the first error */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
53 qfline_T *qf_last; /* pointer to the last error */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
54 qfline_T *qf_ptr; /* pointer to the current error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
55 int qf_count; /* number of errors (0 means no error list) */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
56 int qf_index; /* current index in the error list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
57 int qf_nonevalid; /* TRUE if not a single valid entry found */
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
58 char_u *qf_title; /* title derived from the command that created
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
59 * the error list */
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
60 typval_T *qf_ctx; /* context set by setqflist/setloclist */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
61 } qf_list_T;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
62
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
63 struct qf_info_S
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
64 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
65 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
66 * Count of references to this list. Used only for location lists.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
67 * When a location list window reference this list, qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
68 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
69 * reaches 0, the list is freed.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
70 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
71 int qf_refcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
72 int qf_listcount; /* current number of lists */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
73 int qf_curlist; /* current error list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
74 qf_list_T qf_lists[LISTCOUNT];
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
75
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
76 int qf_dir_curlist; /* error list for qf_dir_stack */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
77 struct dir_stack_T *qf_dir_stack;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
78 char_u *qf_directory;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
79 struct dir_stack_T *qf_file_stack;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
80 char_u *qf_currfile;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
81 int qf_multiline;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
82 int qf_multiignore;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
83 int qf_multiscan;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
84 };
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
85
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
86 static qf_info_T ql_info; /* global quickfix list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
88 #define FMT_PATTERNS 10 /* maximum number of % recognized */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 * Structure used to hold the info of one part of 'errorformat'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
93 typedef struct efm_S efm_T;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
94 struct efm_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 regprog_T *prog; /* pre-formatted part of 'errorformat' */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
97 efm_T *next; /* pointer to next (NULL if last) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 char_u prefix; /* prefix of this format line: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 /* 'D' enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 /* 'X' leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 /* 'A' start of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 /* 'E' error message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 /* 'W' warning message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 /* 'I' informational message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 /* 'C' continuation line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 /* 'Z' end of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 /* 'G' general, unspecific message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 /* 'P' push file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 /* 'Q' pop/quit file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 /* 'O' overread (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 char_u flags; /* additional flags given in prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 /* '-' do not include this line */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
114 /* '+' include whole line in message */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
115 int conthere; /* %> used */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
118 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
119
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
120 static int qf_init_ext(qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title, char_u *enc);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
121 static void qf_store_title(qf_info_T *qi, char_u *title);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
122 static void qf_new_list(qf_info_T *qi, char_u *qf_title);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
123 static void ll_free_all(qf_info_T **pqi);
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
124 static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
125 static qf_info_T *ll_new_list(void);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
126 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
127 static char_u *qf_types(int, int);
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
128 static int qf_get_fnum(qf_info_T *qi, char_u *, char_u *);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
129 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
130 static char_u *qf_pop_dir(struct dir_stack_T **);
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
131 static char_u *qf_guess_filepath(qf_info_T *qi, char_u *);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
132 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
133 static void qf_clean_dir_stack(struct dir_stack_T **);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 #ifdef FEAT_WINDOWS
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
135 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
136 static int is_qf_win(win_T *win, qf_info_T *qi);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
137 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
138 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
139 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
140 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
141 static void 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
142 #endif
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
143 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
144 static void restore_start_dir(char_u *dirname_start);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7710
diff changeset
145 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
146 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
147 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
148 static qf_info_T *ll_get_or_alloc_list(win_T *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
150 /* Quickfix window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
151 #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
152 /* Location list window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
153 #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
154 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
155 * Return location list for window 'wp'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
156 * For location list window, return the referenced location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
157 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
158 #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
159
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
161 * 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
162 * list. Set the error list's title to qf_title.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 * Return -1 for error, number of errors for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
166 qf_init(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
167 win_T *wp,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
168 char_u *efile,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
169 char_u *errorformat,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
170 int newlist, /* TRUE: start a new error list */
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
171 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
172 char_u *enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
174 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
175
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
176 if (wp != NULL)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
177 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
178 qi = ll_get_or_alloc_list(wp);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
179 if (qi == NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
180 return FAIL;
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
181 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
182
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
183 return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist,
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
184 (linenr_T)0, (linenr_T)0,
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
185 qf_title, enc);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
186 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
187
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
188 /*
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
189 * 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
190 */
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
191 #define LINE_MAXLEN 4096
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
192
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
193 static struct fmtpattern
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
194 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
195 char_u convchar;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
196 char *pattern;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
197 } fmt_pat[FMT_PATTERNS] =
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
198 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
199 {'f', ".\\+"}, /* only used when at end */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
200 {'n', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
201 {'l', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
202 {'c', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
203 {'t', "."},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
204 {'m', ".\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
205 {'r', ".*"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
206 {'p', "[- .]*"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
207 {'v', "\\d\\+"},
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
208 {'s', ".\\+"}
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
209 };
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
210
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
211 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
212 * 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
213 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
214 static int
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
215 efm_to_regpat(
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
216 char_u *efm,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
217 int len,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
218 efm_T *fmt_ptr,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
219 char_u *regpat,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
220 char_u *errmsg)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
221 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
222 char_u *ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
223 char_u *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
224 char_u *srcptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
225 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
226 int idx = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
227
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
228 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
229 * 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
230 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
231 ptr = regpat;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
232 *ptr++ = '^';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
233 round = 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
234 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
235 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
236 if (*efmp == '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
237 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
238 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
239 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
240 if (fmt_pat[idx].convchar == *efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
241 break;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
242 if (idx < FMT_PATTERNS)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
243 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
244 if (fmt_ptr->addr[idx])
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
245 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
246 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
247 _("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
248 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
249 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
250 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
251 if ((idx
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
252 && idx < 6
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
253 && vim_strchr((char_u *)"DXOPQ",
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
254 fmt_ptr->prefix) != NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
255 || (idx == 6
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
256 && vim_strchr((char_u *)"OPQ",
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
257 fmt_ptr->prefix) == NULL))
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
258 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
259 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
260 _("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
261 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
262 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
263 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
264 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
265 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
266 *ptr++ = '(';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
267 #ifdef BACKSLASH_IN_FILENAME
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
268 if (*efmp == 'f')
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 /* 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
271 * checking for a colon next: "%f:".
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
272 * "\%(\a:\)\=" */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
273 STRCPY(ptr, "\\%(\\a:\\)\\=");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
274 ptr += 10;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
275 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
276 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
277 if (*efmp == 'f' && efmp[1] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
278 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
279 if (efmp[1] != '\\' && efmp[1] != '%')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
280 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
281 /* 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
282 * 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
283 * 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
284 * 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
285 * follows should work. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
286 STRCPY(ptr, ".\\{-1,}");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
287 ptr += 7;
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 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
290 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
291 /* 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
292 * many file name chars as possible. */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
293 STRCPY(ptr, "\\f\\+");
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
294 ptr += 4;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
295 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
296 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
297 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
298 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
299 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
300 while ((*ptr = *srcptr++) != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
301 ++ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
302 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
303 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
304 *ptr++ = ')';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
305 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
306 else if (*efmp == '*')
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 if (*++efmp == '[' || *efmp == '\\')
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 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
311 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
312 if (efmp[1] == '^')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
313 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
314 if (efmp < efm + len)
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 *ptr++ = *++efmp; /* could be ']' */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
317 while (efmp < efm + len
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
318 && (*ptr++ = *++efmp) != ']')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
319 /* skip */;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
320 if (efmp == efm + len)
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 EMSG(_("E374: Missing ] in format string"));
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
323 return -1;
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 }
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 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
328 *ptr++ = *++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
329 *ptr++ = '\\';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
330 *ptr++ = '+';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
331 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
332 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
333 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
334 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
335 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
336 _("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
337 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
338 return -1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
339 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
340 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
341 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
342 *ptr++ = *efmp; /* regexp magic characters */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
343 else if (*efmp == '#')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
344 *ptr++ = '*';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
345 else if (*efmp == '>')
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
346 fmt_ptr->conthere = TRUE;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
347 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
348 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
349 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
350 fmt_ptr->flags = *efmp++;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
351 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
352 fmt_ptr->prefix = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
353 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
354 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
355 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
356 _("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
357 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
358 return -1;
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 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
361 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
362 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
363 sprintf((char *)errmsg,
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
364 _("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
365 EMSG(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
366 return -1;
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 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
369 else /* copy normal character */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
370 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
371 if (*efmp == '\\' && efmp + 1 < efm + len)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
372 ++efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
373 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
374 *ptr++ = '\\'; /* escape regexp atoms */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
375 if (*efmp)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
376 *ptr++ = *efmp;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
377 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
378 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
379 *ptr++ = '$';
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
380 *ptr = NUL;
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 return 0;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
383 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
384
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
385 static void
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
386 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
387 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
388 efm_T *efm_ptr;
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 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
391 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
392 *efm_first = efm_ptr->next;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
393 vim_regfree(efm_ptr->prog);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
394 vim_free(efm_ptr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
395 }
10367
4e4e116e3689 commit https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
396 fmt_start = NULL;
9365
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
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
399 /* Parse 'errorformat' option */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
400 static efm_T *
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
401 parse_efm_option(char_u *efm)
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 char_u *errmsg = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
404 int errmsglen;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
405 efm_T *fmt_ptr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
406 efm_T *fmt_first = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
407 efm_T *fmt_last = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
408 char_u *fmtstr = NULL;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
409 int len;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
410 int i;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
411 int round;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
412
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
413 errmsglen = CMDBUFFSIZE + 1;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
414 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
415 if (errmsg == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
416 goto parse_efm_end;
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 /*
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
419 * 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
420 * 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
421 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
422
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
423 /*
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
424 * 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
425 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
426 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
427 for (round = FMT_PATTERNS; round > 0; )
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
428 i += (int)STRLEN(fmt_pat[--round].pattern);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
429 #ifdef COLON_IN_FILENAME
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
430 i += 12; /* "%f" can become twelve chars longer */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
431 #else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
432 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
433 #endif
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
434 if ((fmtstr = alloc(i)) == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
435 goto parse_efm_error;
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 while (efm[0] != NUL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
438 {
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
439 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
440 * 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
441 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
442 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
443 if (fmt_ptr == NULL)
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
444 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
445 if (fmt_first == NULL) /* first one */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
446 fmt_first = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
447 else
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
448 fmt_last->next = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
449 fmt_last = fmt_ptr;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
450
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
451 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
452 * 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
453 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
454 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
455 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
456 ++len;
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 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
459 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
460 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
461 goto parse_efm_error;
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
462 /*
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
463 * Advance to next part
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
464 */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
465 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
466 }
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
467
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
468 if (fmt_first == NULL) /* nothing found */
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
469 EMSG(_("E378: 'errorformat' contains no pattern"));
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 goto parse_efm_end;
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 parse_efm_error:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
474 free_efm_list(&fmt_first);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
475
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
476 parse_efm_end:
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
477 vim_free(fmtstr);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
478 vim_free(errmsg);
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
479
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
480 return fmt_first;
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
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
483 enum {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
484 QF_FAIL = 0,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
485 QF_OK = 1,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
486 QF_END_OF_INPUT = 2,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
487 QF_NOMEM = 3,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
488 QF_IGNORE_LINE = 4
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
489 };
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
490
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
491 typedef struct {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
492 char_u *linebuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
493 int linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
494 char_u *growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
495 int growbufsiz;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
496 FILE *fd;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
497 typval_T *tv;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
498 char_u *p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
499 listitem_T *p_li;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
500 buf_T *buf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
501 linenr_T buflnum;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
502 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
503 vimconv_T vc;
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
504 } qfstate_T;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
505
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
506 static char_u *
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
507 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
508 {
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 * 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
511 * 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
512 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
513 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
514 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
515 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
516 state->growbuf = alloc(state->linelen + 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
517 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
518 return NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
519 state->growbufsiz = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
520 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
521 else if (state->linelen > state->growbufsiz)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
522 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
523 state->growbuf = vim_realloc(state->growbuf, state->linelen + 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
524 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
525 return NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
526 state->growbufsiz = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
527 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
528 return state->growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
529 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
530
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
531 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
532 * 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
533 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
534 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
535 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
536 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
537 /* 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
538 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
539 char_u *p;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
540 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
541
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
542 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
543 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
544
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
545 p = vim_strchr(p_str, '\n');
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
546 if (p != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
547 len = (int)(p - p_str) + 1;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
548 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
549 len = (int)STRLEN(p_str);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
550
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
551 if (len > IOSIZE - 2)
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 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
554 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
555 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
556 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
557 else
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 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
560 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
561 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
562 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
563
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
564 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
565 * 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
566 * line if it exceeds LINE_MAXLEN.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
567 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
568 p_str += len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
569 state->p_str = p_str;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
570
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
571 return QF_OK;
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
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 * 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
576 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
577 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
578 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
579 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
580 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
581 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
582
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
583 while (p_li != NULL
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
584 && (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
585 || 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
586 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
587
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
588 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
589 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
590 state->p_li = NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
591 return QF_END_OF_INPUT;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
594 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
595 if (len > IOSIZE - 2)
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 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
598 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
599 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
600 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
601 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
602 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
603 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
604 state->linelen = len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
605 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
606
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
607 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
608
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
609 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
610 return QF_OK;
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
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
613 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
614 * 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
615 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
616 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
617 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
618 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
619 char_u *p_buf = NULL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
620 int len;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
621
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
622 /* 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
623 if (state->buflnum > state->lnumlast)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
624 return QF_END_OF_INPUT;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
625
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
626 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
627 state->buflnum += 1;
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 len = (int)STRLEN(p_buf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
630 if (len > IOSIZE - 2)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
631 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
632 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
633 if (state->linebuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
634 return QF_NOMEM;
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 else
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 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
639 state->linelen = len;
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 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
642
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
643 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
644 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
645
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
646 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
647 * 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
648 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
649 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
650 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
651 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
652 int discard;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
653 int growbuflen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
654
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
655 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
656 return QF_END_OF_INPUT;
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 discard = FALSE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
659 state->linelen = (int)STRLEN(IObuff);
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
660 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
661 {
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 * 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
664 * 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
665 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
666 if (state->growbuf == NULL)
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 state->growbufsiz = 2 * (IOSIZE - 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
669 state->growbuf = alloc(state->growbufsiz);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
670 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
671 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
672 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
673
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
674 /* 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
675 memcpy(state->growbuf, IObuff, IOSIZE - 1);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
676 growbuflen = state->linelen;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
677
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
678 for (;;)
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 if (fgets((char *)state->growbuf + growbuflen,
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
681 state->growbufsiz - growbuflen, state->fd) == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
682 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
683 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
684 growbuflen += state->linelen;
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
685 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
686 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
687 if (state->growbufsiz == LINE_MAXLEN)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
688 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
689 discard = TRUE;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
690 break;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
691 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
692
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
693 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
694 ? 2 * state->growbufsiz : LINE_MAXLEN;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
695 state->growbuf = vim_realloc(state->growbuf, state->growbufsiz);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
696 if (state->growbuf == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
697 return QF_NOMEM;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
698 }
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 while (discard)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
701 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
702 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
703 * 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
704 * 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
705 * reached.
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
706 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
707 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
708 || (int)STRLEN(IObuff) < IOSIZE - 1
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
709 || IObuff[IOSIZE - 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 }
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 state->linebuf = state->growbuf;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
714 state->linelen = growbuflen;
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 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
717 state->linebuf = IObuff;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
718
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
719 #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
720 /* 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
721 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
722 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
723 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
724
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
725 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
726 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
727 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
728 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
729 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
730 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
731 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
732 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
733 else
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
734 {
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
735 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
736 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
737 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
738 ? 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
739 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
740 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
741 }
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
742 #endif
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
743
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
744 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
745 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
746
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
747 /*
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
748 * 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
749 */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
750 static int
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
751 qf_get_nextline(qfstate_T *state)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
752 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
753 int status = QF_FAIL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
754
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
755 if (state->fd == NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
756 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
757 if (state->tv != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
758 {
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
759 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
760 /* 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
761 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
762 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
763 /* 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
764 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
765 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
766 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
767 /* 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
768 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
769 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
770 else
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
771 /* 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
772 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
773
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
774 if (status != QF_OK)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
775 return status;
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 /* remove newline/CR from the line */
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
778 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
779 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
780 state->linebuf[state->linelen - 1] = NUL;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
781 #ifdef USE_CRNL
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
782 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
783 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
784 #endif
9738
6818e3c96473 commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2
Christian Brabandt <cb@256bit.org>
parents: 9649
diff changeset
785 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
786
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
787 #ifdef FEAT_MBYTE
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
788 remove_bom(state->linebuf);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
789 #endif
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
790
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
791 return QF_OK;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
792 }
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
793
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
794 typedef struct {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
795 char_u *namebuf;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
796 char_u *errmsg;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
797 int errmsglen;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
798 long lnum;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
799 int col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
800 char_u use_viscol;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
801 char_u *pattern;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
802 int enr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
803 int type;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
804 int valid;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
805 } qffields_T;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
806
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
807 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
808 * 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
809 * Return the QF_ status.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
810 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
811 static int
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
812 qf_parse_line(
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
813 qf_info_T *qi,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
814 char_u *linebuf,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
815 int linelen,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
816 efm_T *fmt_first,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
817 qffields_T *fields)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
818 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
819 efm_T *fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
820 char_u *ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
821 int len;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
822 int i;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
823 int idx = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
824 char_u *tail = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
825 regmatch_T regmatch;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
826
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
827 /* Always ignore case when looking for a matching error. */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
828 regmatch.rm_ic = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
829
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
830 /* 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
831 if (fmt_start == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
832 fmt_ptr = fmt_first;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
833 else
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
834 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
835 fmt_ptr = fmt_start;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
836 fmt_start = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
837 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
838
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
839 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
840 * 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
841 * match or no match.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
842 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
843 fields->valid = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
844 restofline:
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
845 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
846 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
847 int r;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
848
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
849 idx = fmt_ptr->prefix;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
850 if (qi->qf_multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
851 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
852 fields->namebuf[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
853 fields->pattern[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
854 if (!qi->qf_multiscan)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
855 fields->errmsg[0] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
856 fields->lnum = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
857 fields->col = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
858 fields->use_viscol = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
859 fields->enr = -1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
860 fields->type = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
861 tail = NULL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
862
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
863 regmatch.regprog = fmt_ptr->prog;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
864 r = vim_regexec(&regmatch, linebuf, (colnr_T)0);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
865 fmt_ptr->prog = regmatch.regprog;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
866 if (r)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
867 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
868 if ((idx == 'C' || idx == 'Z') && !qi->qf_multiline)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
869 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
870 if (vim_strchr((char_u *)"EWI", idx) != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
871 fields->type = idx;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
872 else
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
873 fields->type = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
874 /*
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
875 * Extract error message data from matched line.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
876 * We check for an actual submatch, because "\[" and "\]" in
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
877 * the 'errorformat' may cause the wrong submatch to be used.
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
878 */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
879 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
880 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
881 int c;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
882
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
883 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
884 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
885
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
886 /* Expand ~/file and $HOME/file to full path. */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
887 c = *regmatch.endp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
888 *regmatch.endp[i] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
889 expand_env(regmatch.startp[i], fields->namebuf, CMDBUFFSIZE);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
890 *regmatch.endp[i] = c;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
891
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
892 if (vim_strchr((char_u *)"OPQ", idx) != NULL
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
893 && mch_getperm(fields->namebuf) == -1)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
894 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
895 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
896 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
897 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
898 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
899 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
900 fields->enr = (int)atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
901 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
902 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
903 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
904 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
905 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
906 fields->lnum = atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
907 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
908 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
909 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
910 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
911 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
912 fields->col = (int)atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
913 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
914 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
915 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
916 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
917 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
918 fields->type = *regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
919 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
920 if (fmt_ptr->flags == '+' && !qi->qf_multiscan) /* %+ */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
921 {
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
922 if (linelen > fields->errmsglen)
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
923 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
924 /* linelen + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
925 if ((fields->errmsg = vim_realloc(fields->errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
926 linelen + 1)) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
927 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
928 fields->errmsglen = linelen + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
929 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
930 vim_strncpy(fields->errmsg, linebuf, linelen);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
931 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
932 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
933 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
934 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
935 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
936 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
937 if (len > fields->errmsglen)
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
938 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
939 /* len + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
940 if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
941 == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
942 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
943 fields->errmsglen = len + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
944 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
945 vim_strncpy(fields->errmsg, regmatch.startp[i], len);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
946 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
947 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
948 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
949 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
950 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
951 tail = regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
952 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
953 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
954 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
955 char_u *match_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
956
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
957 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
958 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
959 fields->col = 0;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
960 for (match_ptr = regmatch.startp[i];
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
961 match_ptr != regmatch.endp[i]; ++match_ptr)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
962 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
963 ++fields->col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
964 if (*match_ptr == TAB)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
965 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
966 fields->col += 7;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
967 fields->col -= fields->col % 8;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
968 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
969 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
970 ++fields->col;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
971 fields->use_viscol = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
972 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
973 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
974 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
975 if (regmatch.startp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
976 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
977 fields->col = (int)atol((char *)regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
978 fields->use_viscol = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
979 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
980 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
981 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
982 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
983 continue;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
984 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
985 if (len > CMDBUFFSIZE - 5)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
986 len = CMDBUFFSIZE - 5;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
987 STRCPY(fields->pattern, "^\\V");
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
988 STRNCAT(fields->pattern, regmatch.startp[i], len);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
989 fields->pattern[len + 3] = '\\';
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
990 fields->pattern[len + 4] = '$';
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
991 fields->pattern[len + 5] = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
992 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
993 break;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
994 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
995 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
996 qi->qf_multiscan = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
997
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
998 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
999 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1000 if (fmt_ptr != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1001 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1002 if (idx == 'D') /* enter directory */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1003 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1004 if (*fields->namebuf == NUL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1005 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1006 EMSG(_("E379: Missing or empty directory name"));
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1007 return QF_FAIL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1008 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1009 qi->qf_directory =
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1010 qf_push_dir(fields->namebuf, &qi->qf_dir_stack, FALSE);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1011 if (qi->qf_directory == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1012 return QF_FAIL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1013 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1014 else if (idx == 'X') /* leave directory */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1015 qi->qf_directory = qf_pop_dir(&qi->qf_dir_stack);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1016 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1017 fields->namebuf[0] = NUL; /* no match found, remove file name */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1018 fields->lnum = 0; /* don't jump to this line */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1019 fields->valid = FALSE;
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
1020 if (linelen > fields->errmsglen)
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
1021 {
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1022 /* linelen + null terminator */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1023 if ((fields->errmsg = vim_realloc(fields->errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1024 linelen + 1)) == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1025 return QF_NOMEM;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1026 fields->errmsglen = linelen + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1027 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1028 /* copy whole line to error message */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1029 vim_strncpy(fields->errmsg, linebuf, linelen);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1030 if (fmt_ptr == NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1031 qi->qf_multiline = qi->qf_multiignore = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1032 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1033 else if (fmt_ptr != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1034 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1035 /* honor %> item */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1036 if (fmt_ptr->conthere)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1037 fmt_start = fmt_ptr;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1038
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1039 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
1040 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1041 qi->qf_multiline = TRUE; /* start of a multi-line message */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1042 qi->qf_multiignore = FALSE; /* reset continuation */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1043 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1044 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
1045 { /* continuation of multi-line msg */
10257
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1046 if (!qi->qf_multiignore)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1047 {
10257
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1048 qfline_T *qfprev = qi->qf_lists[qi->qf_curlist].qf_last;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1049
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1050 if (qfprev == NULL)
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1051 return QF_FAIL;
10257
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1052 if (*fields->errmsg && !qi->qf_multiignore)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1053 {
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1054 len = (int)STRLEN(qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1055 if ((ptr = alloc((unsigned)(len + STRLEN(fields->errmsg) + 2)))
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1056 == NULL)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1057 return QF_FAIL;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1058 STRCPY(ptr, qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1059 vim_free(qfprev->qf_text);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1060 qfprev->qf_text = ptr;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1061 *(ptr += len) = '\n';
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1062 STRCPY(++ptr, fields->errmsg);
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1063 }
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1064 if (qfprev->qf_nr == -1)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1065 qfprev->qf_nr = fields->enr;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1066 if (vim_isprintc(fields->type) && !qfprev->qf_type)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1067 /* only printable chars allowed */
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1068 qfprev->qf_type = fields->type;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1069
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1070 if (!qfprev->qf_lnum)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1071 qfprev->qf_lnum = fields->lnum;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1072 if (!qfprev->qf_col)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1073 qfprev->qf_col = fields->col;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1074 qfprev->qf_viscol = fields->use_viscol;
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1075 if (!qfprev->qf_fnum)
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1076 qfprev->qf_fnum = qf_get_fnum(qi, qi->qf_directory,
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1077 *fields->namebuf || qi->qf_directory != NULL
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1078 ? fields->namebuf
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1079 : qi->qf_currfile != NULL && fields->valid
2d0e6034743a commit https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49
Christian Brabandt <cb@256bit.org>
parents: 10237
diff changeset
1080 ? qi->qf_currfile : 0);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1081 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1082 if (idx == 'Z')
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1083 qi->qf_multiline = qi->qf_multiignore = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1084 line_breakcheck();
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1085 return QF_IGNORE_LINE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1086 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1087 else if (vim_strchr((char_u *)"OPQ", idx) != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1088 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1089 /* global file names */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1090 fields->valid = FALSE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1091 if (*fields->namebuf == NUL || mch_getperm(fields->namebuf) >= 0)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1092 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1093 if (*fields->namebuf && idx == 'P')
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1094 qi->qf_currfile =
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1095 qf_push_dir(fields->namebuf, &qi->qf_file_stack, TRUE);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1096 else if (idx == 'Q')
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1097 qi->qf_currfile = qf_pop_dir(&qi->qf_file_stack);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1098 *fields->namebuf = NUL;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1099 if (tail && *tail)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1100 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1101 STRMOVE(IObuff, skipwhite(tail));
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1102 qi->qf_multiscan = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1103 goto restofline;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1104 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1105 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1106 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1107 if (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
1108 {
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1109 if (qi->qf_multiline)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1110 /* also exclude continuation lines */
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1111 qi->qf_multiignore = TRUE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1112 return QF_IGNORE_LINE;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1113 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1114 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1115
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1116 return QF_OK;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1117 }
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1118
9033
0536d1469b67 commit https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
Christian Brabandt <cb@256bit.org>
parents: 8932
diff changeset
1119 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1120 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1121 * list.
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1122 * 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
1123 * 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
1124 * 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
1125 * 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
1126 * Set the title of the list to "qf_title".
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1127 * Return -1 for error, number of errors for success.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1128 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1129 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1130 qf_init_ext(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1131 qf_info_T *qi,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1132 char_u *efile,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1133 buf_T *buf,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1134 typval_T *tv,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1135 char_u *errorformat,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1136 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
1137 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
1138 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
1139 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
1140 char_u *enc)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1141 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1142 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
1143 qffields_T fields;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1144 #ifdef FEAT_WINDOWS
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1145 qfline_T *old_last = NULL;
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1146 int adding = FALSE;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1147 #endif
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1148 static efm_T *fmt_first = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 char_u *efm;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1150 static char_u *last_efm = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 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
1152 int status;
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1153
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1154 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
1155 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
1156 #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
1157 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
1158 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
1159 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
1160 #endif
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1161 fields.namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1162 fields.errmsglen = CMDBUFFSIZE + 1;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1163 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
1164 fields.pattern = alloc_id(CMDBUFFSIZE + 1, aid_qf_pattern);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1165 if (fields.namebuf == NULL || fields.errmsg == NULL ||
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1166 fields.pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1169 if (efile != NULL && (state.fd = mch_fopen((char *)efile, "r")) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 EMSG2(_(e_openerrf), efile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1175 if (newlist || qi->qf_curlist == qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
1177 qf_new_list(qi, qf_title);
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1178 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1179 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1180 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1181 /* 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
1182 adding = TRUE;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1183 old_last = qi->qf_lists[qi->qf_curlist].qf_last;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1184 }
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1185 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 /* Use the local value of 'errorformat' if it's set. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1188 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1189 efm = buf->b_p_efm;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 efm = errorformat;
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1192
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1193 /*
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1194 * If we are not adding or adding to another list: clear the state.
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1195 */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1196 if (newlist || qi->qf_curlist != qi->qf_dir_curlist)
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1197 {
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1198 qi->qf_dir_curlist = qi->qf_curlist;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1199 qf_clean_dir_stack(&qi->qf_dir_stack);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1200 qi->qf_directory = NULL;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1201 qf_clean_dir_stack(&qi->qf_file_stack);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1202 qi->qf_currfile = NULL;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1203 qi->qf_multiline = FALSE;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1204 qi->qf_multiignore = FALSE;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1205 qi->qf_multiscan = FALSE;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1206 }
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1207
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1208 /*
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1209 * 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
1210 * previously parsed values.
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1211 */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1212 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
1213 {
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1214 /* free the previously parsed data */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1215 vim_free(last_efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1216 last_efm = NULL;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1217 free_efm_list(&fmt_first);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1218
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1219 /* parse the current 'efm' */
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1220 fmt_first = parse_efm_option(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1221 if (fmt_first != NULL)
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1222 last_efm = vim_strsave(efm);
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1223 }
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1224
9365
3830a92c12bf commit https://github.com/vim/vim/commit/688e3d1fd9b9129a5ba0e0d599ccfe6f4443daf3
Christian Brabandt <cb@256bit.org>
parents: 9334
diff changeset
1225 if (fmt_first == NULL) /* nothing found */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 * got_int is reset here, because it was probably set when killing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 * ":make" command, but we still want to read the errorfile then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1234 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1235 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1236 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
1237 state.p_str = tv->vval.v_string;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1238 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
1239 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
1240 state.tv = tv;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1241 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1242 state.buf = buf;
9534
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1243 state.buflnum = lnumfirst;
340106787852 commit https://github.com/vim/vim/commit/bfafb4c4a01db3f8c508716daf689e0dfe92b649
Christian Brabandt <cb@256bit.org>
parents: 9531
diff changeset
1244 state.lnumlast = lnumlast;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
1245
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 * Read the lines in the error file one by one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 * Try to recognize one of the error formats in each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
1250 while (!got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 {
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1252 /* 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
1253 status = qf_get_nextline(&state);
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1254 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
1255 goto qf_init_end;
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1256 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
1257 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1259 status = qf_parse_line(qi, state.linebuf, state.linelen, fmt_first,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1260 &fields);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1261 if (status == QF_FAIL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1262 goto error2;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1263 if (status == QF_NOMEM)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1264 goto qf_init_end;
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1265 if (status == QF_IGNORE_LINE)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1266 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1268 if (qf_add_entry(qi,
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1269 qi->qf_directory,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1270 (*fields.namebuf || qi->qf_directory != NULL)
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1271 ? fields.namebuf
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1272 : ((qi->qf_currfile != NULL && fields.valid)
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1273 ? qi->qf_currfile : (char_u *)NULL),
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1274 0,
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1275 fields.errmsg,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1276 fields.lnum,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1277 fields.col,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1278 fields.use_viscol,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1279 fields.pattern,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1280 fields.enr,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1281 fields.type,
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1282 fields.valid) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 }
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1286 if (state.fd == NULL || !ferror(state.fd))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1288 if (qi->qf_lists[qi->qf_curlist].qf_index == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1290 /* no valid entry found */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1291 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1292 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1293 qi->qf_lists[qi->qf_curlist].qf_index = 1;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1294 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1298 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1299 if (qi->qf_lists[qi->qf_curlist].qf_ptr == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1300 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1301 qi->qf_lists[qi->qf_curlist].qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1303 /* return number of matches */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1304 retval = qi->qf_lists[qi->qf_curlist].qf_count;
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1305 goto qf_init_end;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 EMSG(_(e_readerrf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 error2:
10369
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1309 if (!adding)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1310 {
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1311 qf_free(qi, qi->qf_curlist);
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1312 qi->qf_listcount--;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1313 if (qi->qf_curlist > 0)
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1314 --qi->qf_curlist;
4e5b307638cb commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129
Christian Brabandt <cb@256bit.org>
parents: 10367
diff changeset
1315 }
9369
ce5b79b005ec commit https://github.com/vim/vim/commit/bcf7772a23624edc0942120e564f6b4ac95604ad
Christian Brabandt <cb@256bit.org>
parents: 9365
diff changeset
1316 qf_init_end:
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1317 if (state.fd != NULL)
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1318 fclose(state.fd);
9568
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1319 vim_free(fields.namebuf);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1320 vim_free(fields.errmsg);
ccbd2e604e59 commit https://github.com/vim/vim/commit/e87e6dddc2b2a99572ec0db0833c052214c4fbd3
Christian Brabandt <cb@256bit.org>
parents: 9540
diff changeset
1321 vim_free(fields.pattern);
9531
50697f3b49d6 commit https://github.com/vim/vim/commit/e0d3797664c59afc9705808f86a7cf00fd6d874d
Christian Brabandt <cb@256bit.org>
parents: 9487
diff changeset
1322 vim_free(state.growbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 #ifdef FEAT_WINDOWS
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
1325 qf_update_buffer(qi, old_last);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 #endif
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
1327 #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
1328 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
1329 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
1330 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1335 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1336 qf_store_title(qf_info_T *qi, char_u *title)
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1337 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1338 if (title != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1339 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1340 char_u *p = alloc((int)STRLEN(title) + 2);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1341
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1342 qi->qf_lists[qi->qf_curlist].qf_title = p;
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1343 if (p != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1344 sprintf((char *)p, ":%s", (char *)title);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1345 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1346 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1347
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 * Prepare for adding a new quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1352 qf_new_list(qf_info_T *qi, char_u *qf_title)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 /*
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1357 * If the current entry is not the last entry, delete entries beyond
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 * the current entry. This makes it possible to browse in a tree-like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 * way with ":grep'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1361 while (qi->qf_listcount > qi->qf_curlist + 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1362 qf_free(qi, --qi->qf_listcount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 * When the stack is full, remove to oldest entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 * Otherwise, add a new entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1368 if (qi->qf_listcount == LISTCOUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1370 qf_free(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 for (i = 1; i < LISTCOUNT; ++i)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1372 qi->qf_lists[i - 1] = qi->qf_lists[i];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1373 qi->qf_curlist = LISTCOUNT - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 else
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1376 qi->qf_curlist = qi->qf_listcount++;
3259
9eb7fdfb5e63 updated for version 7.3.398
Bram Moolenaar <bram@vim.org>
parents: 3257
diff changeset
1377 vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
1378 qf_store_title(qi, qf_title);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1381 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1382 * Free a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1383 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1384 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1385 ll_free_all(qf_info_T **pqi)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1386 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1387 int i;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1388 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1389
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1390 qi = *pqi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1391 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1392 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1393 *pqi = NULL; /* Remove reference to this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1394
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1395 qi->qf_refcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1396 if (qi->qf_refcount < 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1397 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1398 /* No references to this location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1399 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1400 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1401 vim_free(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1402 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1403 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1404
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1405 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1406 qf_free_all(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1407 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1408 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1409 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1410
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1411 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1412 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1413 /* location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1414 ll_free_all(&wp->w_llist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1415 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1416 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1417 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1418 /* quickfix list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1419 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1420 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1421 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
1422
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 * Add an entry to the end of the list of errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1428 qf_add_entry(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1429 qf_info_T *qi, /* quickfix list */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1430 char_u *dir, /* optional directory name */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1431 char_u *fname, /* file name or NULL */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1432 int bufnum, /* buffer number or zero */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1433 char_u *mesg, /* message */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1434 long lnum, /* line number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1435 int col, /* column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1436 int vis_col, /* using visual column */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1437 char_u *pattern, /* search pattern */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1438 int nr, /* error number */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1439 int type, /* type character */
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1440 int valid) /* valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1442 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1443 qfline_T **lastp; /* pointer to qf_last or NULL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1445 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 return FAIL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1447 if (bufnum != 0)
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1448 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1449 buf_T *buf = buflist_findnr(bufnum);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1450
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1451 qfp->qf_fnum = bufnum;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1452 if (buf != NULL)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1453 buf->b_has_qf_entry |=
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1454 (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
1455 }
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1456 else
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1457 qfp->qf_fnum = qf_get_fnum(qi, dir, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 vim_free(qfp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 qfp->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 qfp->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
1465 qfp->qf_viscol = vis_col;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1466 if (pattern == NULL || *pattern == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1467 qfp->qf_pattern = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1468 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1469 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1470 vim_free(qfp->qf_text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1471 vim_free(qfp);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1472 return FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1473 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 qfp->qf_nr = nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 qfp->qf_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 qfp->qf_valid = valid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1480 lastp = &qi->qf_lists[qi->qf_curlist].qf_last;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1481 if (qi->qf_lists[qi->qf_curlist].qf_count == 0)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1482 /* first element in the list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1484 qi->qf_lists[qi->qf_curlist].qf_start = qfp;
8716
4ce26276caeb commit https://github.com/vim/vim/commit/8b20179c657b4266dff115486ca68c6a50324071
Christian Brabandt <cb@256bit.org>
parents: 8702
diff changeset
1485 qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
4ce26276caeb commit https://github.com/vim/vim/commit/8b20179c657b4266dff115486ca68c6a50324071
Christian Brabandt <cb@256bit.org>
parents: 8702
diff changeset
1486 qi->qf_lists[qi->qf_curlist].qf_index = 0;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1487 qfp->qf_prev = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1491 qfp->qf_prev = *lastp;
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1492 (*lastp)->qf_next = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 }
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1494 qfp->qf_next = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 qfp->qf_cleared = FALSE;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1496 *lastp = qfp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1497 ++qi->qf_lists[qi->qf_curlist].qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1498 if (qi->qf_lists[qi->qf_curlist].qf_index == 0 && qfp->qf_valid)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1499 /* first valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1501 qi->qf_lists[qi->qf_curlist].qf_index =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1502 qi->qf_lists[qi->qf_curlist].qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1503 qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 /*
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1510 * Allocate a new location list
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1511 */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1512 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1513 ll_new_list(void)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1514 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1515 qf_info_T *qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1516
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1517 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1518 if (qi != NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1519 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1520 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1521 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1522 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1523
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1524 return qi;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1525 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1526
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1527 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1528 * Return the location list for window 'wp'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1529 * If not present, allocate a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1530 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1531 static qf_info_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1532 ll_get_or_alloc_list(win_T *wp)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1533 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1534 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1535 /* For a location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1536 return wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1537
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1538 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1539 * 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
1540 * location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1541 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1542 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1543
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1544 if (wp->w_llist == NULL)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1545 wp->w_llist = ll_new_list(); /* new location list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1546 return wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1547 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1548
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1549 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1550 * Copy the location list from window "from" to window "to".
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1551 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1552 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1553 copy_loclist(win_T *from, win_T *to)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1554 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1555 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1556 int idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1557 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1558
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1559 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1560 * When copying from a location list window, copy the referenced
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1561 * location list. For other windows, copy the location list for
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1562 * that window.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1563 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1564 if (IS_LL_WINDOW(from))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1565 qi = from->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1566 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1567 qi = from->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1568
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1569 if (qi == NULL) /* no location list to copy */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1570 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1571
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1572 /* allocate a new location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1573 if ((to->w_llist = ll_new_list()) == NULL)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1574 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1575
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1576 to->w_llist->qf_listcount = qi->qf_listcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1577
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1578 /* Copy the location lists one at a time */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1579 for (idx = 0; idx < qi->qf_listcount; idx++)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1580 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1581 qf_list_T *from_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1582 qf_list_T *to_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1583
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1584 to->w_llist->qf_curlist = idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1585
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1586 from_qfl = &qi->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1587 to_qfl = &to->w_llist->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1588
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1589 /* Some of the fields are populated by qf_add_entry() */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1590 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1591 to_qfl->qf_count = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1592 to_qfl->qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1593 to_qfl->qf_start = NULL;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1594 to_qfl->qf_last = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1595 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
1596 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
1597 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
1598 else
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1599 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
1600 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
1601 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1602 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
1603 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
1604 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
1605 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1606 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
1607 to_qfl->qf_ctx = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1608
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1609 if (from_qfl->qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1610 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1611 qfline_T *from_qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1612 qfline_T *prevp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1613
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1614 /* 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
1615 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
1616 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
1617 ++i, from_qfp = from_qfp->qf_next)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1618 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1619 if (qf_add_entry(to->w_llist,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1620 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1621 NULL,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1622 0,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1623 from_qfp->qf_text,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1624 from_qfp->qf_lnum,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1625 from_qfp->qf_col,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1626 from_qfp->qf_viscol,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1627 from_qfp->qf_pattern,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1628 from_qfp->qf_nr,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1629 0,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1630 from_qfp->qf_valid) == FAIL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1631 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1632 qf_free_all(to);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1633 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1634 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1635 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1636 * qf_add_entry() will not set the qf_num field, as the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1637 * directory and file names are not supplied. So the qf_fnum
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1638 * field is copied here.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1639 */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1640 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
1641 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1642 prevp->qf_type = from_qfp->qf_type; /* error type */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1643 if (from_qfl->qf_ptr == from_qfp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1644 to_qfl->qf_ptr = prevp; /* current location */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1645 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1646 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1647
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1648 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1649
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1650 /* When no valid entries are present in the list, qf_ptr points to
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1651 * the first item in the list */
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
1652 if (to_qfl->qf_nonevalid)
5060
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1653 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1654 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
1655 to_qfl->qf_index = 1;
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1656 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1657 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1658
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1659 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1660 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1661
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1662 /*
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1663 * Looking up a buffer can be slow if there are many. Remember the last one
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1664 * to make this a lot faster if there are multiple matches in the same file.
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1665 */
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1666 static char_u *qf_last_bufname = NULL;
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1667 static bufref_T qf_last_bufref = {NULL, 0};
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1668
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1669 /*
10379
73e2a7abe2a3 commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents: 10369
diff changeset
1670 * 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
1671 * Also sets the b_has_qf_entry flag.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 static int
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1674 qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 {
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1676 char_u *ptr = NULL;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1677 buf_T *buf;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1678 char_u *bufname;
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1679
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 if (fname == NULL || *fname == NUL) /* no file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1683 #ifdef VMS
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1684 vms_remove_version(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1685 #endif
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1686 #ifdef BACKSLASH_IN_FILENAME
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1687 if (directory != NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1688 slash_adjust(directory);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1689 slash_adjust(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1690 #endif
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1691 if (directory != NULL && !vim_isAbsName(fname)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1692 && (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
1693 {
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1694 /*
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1695 * 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
1696 * 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
1697 * "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
1698 * directory change.
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1699 */
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1700 if (mch_getperm(ptr) < 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 vim_free(ptr);
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1703 directory = qf_guess_filepath(qi, fname);
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1704 if (directory)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1705 ptr = concat_fnames(directory, fname, TRUE);
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1706 else
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1707 ptr = vim_strsave(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1709 /* 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
1710 bufname = ptr;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1711 }
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1712 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1713 bufname = fname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1714
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1715 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
1716 && bufref_valid(&qf_last_bufref))
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1717 {
9475
4d8f7f8da90c commit https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Christian Brabandt <cb@256bit.org>
parents: 9473
diff changeset
1718 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
1719 vim_free(ptr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1721 else
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1722 {
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1723 vim_free(qf_last_bufname);
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1724 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
1725 if (bufname == ptr)
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1726 qf_last_bufname = bufname;
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1727 else
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1728 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
1729 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
1730 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1731 if (buf == NULL)
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
1732 return 0;
9473
bdac1019552f commit https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Christian Brabandt <cb@256bit.org>
parents: 9458
diff changeset
1733
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1734 buf->b_has_qf_entry =
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
1735 (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
1736 return buf->b_fnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 /*
9334
674f9e3ccd1a commit https://github.com/vim/vim/commit/38df43bd13a2498cc96b3ddd9a20dd75126bd171
Christian Brabandt <cb@256bit.org>
parents: 9201
diff changeset
1740 * 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
1741 * NULL on error.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 static char_u *
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1744 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
1745 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 struct dir_stack_T *ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 /* allocate new stack element and hook it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 ds_new->next = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 *stackptr = ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 /* store directory on the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 if (vim_isAbsName(dirbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 || (*stackptr)->next == NULL
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1760 || (*stackptr && is_file_stack))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 /* Okay we don't have an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 * dirbuf must be a subdir of one of the directories on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 * Let's search...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 ds_new = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 (*stackptr)->dirname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 while (ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 if (mch_isdir((*stackptr)->dirname) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 ds_new = ds_new->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 while ((*stackptr)->next != ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 ds_ptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 (*stackptr)->next = (*stackptr)->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 /* Nothing found -> it must be on top level */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 if ((*stackptr)->dirname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 return (*stackptr)->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 * pop dirbuf from the directory stack and return previous directory or NULL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 * stack is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1815 qf_pop_dir(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 /* TODO: Should we check if dirbuf is the directory on top of the stack?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 * What to do if it isn't? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 /* pop top element and free it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 if (*stackptr != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 /* return NEW top element as current dir or NULL if stack is empty*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 return *stackptr ? (*stackptr)->dirname : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 * clean up directory stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1839 qf_clean_dir_stack(struct dir_stack_T **stackptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 while ((ds_ptr = *stackptr) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 * Check in which directory of the directory stack the given file can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 * found.
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
1854 * Returns a pointer to the directory name or NULL if not found.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 * Cleans up intermediate directory entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 * TODO: How to solve the following problem?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 * If we have the this directory tree:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 * ./
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 * ./aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 * ./aa/bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 * ./bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 * ./bb/x.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 * and make says:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 * making all in aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 * making all in bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 * x.c:9: Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 * 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
1869 * qf_guess_filepath will return NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 static char_u *
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1872 qf_guess_filepath(qf_info_T *qi, char_u *filename)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 struct dir_stack_T *ds_tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 char_u *fullname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 /* no dirs on the stack - there's nothing we can do */
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1879 if (qi->qf_dir_stack == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1882 ds_ptr = qi->qf_dir_stack->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 fullname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 while (ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 /* If concat_fnames failed, just go on. The worst thing that can happen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 * is that we delete the entire stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 if ((fullname != NULL) && (mch_getperm(fullname) >= 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 ds_ptr = ds_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 /* clean up all dirs we already left */
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1901 while (qi->qf_dir_stack->next != ds_ptr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 {
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1903 ds_tmp = qi->qf_dir_stack->next;
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
1904 qi->qf_dir_stack->next = qi->qf_dir_stack->next->next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 vim_free(ds_tmp->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 vim_free(ds_tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 return ds_ptr==NULL? NULL: ds_ptr->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 /*
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1913 * 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
1914 * This may invalidate the current quickfix entry. This function checks
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1915 * whether a entry is still present in the quickfix.
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1916 * Similar to location list.
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1917 */
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1918 static int
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1919 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
1920 {
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1921 qf_list_T *qfl;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1922 qfline_T *qfp;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1923 int i;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1924
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1925 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
1926
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1927 /* 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
1928 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
1929 ++i, qfp = qfp->qf_next)
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
1930 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
1931 break;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1932
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1933 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
1934 return FALSE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1935
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1936 return TRUE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1937 }
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1938
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1939 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 * jump to a quickfix line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 * if dir == FORWARD go "errornr" valid entries forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 * if dir == BACKWARD go "errornr" valid entries backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 * if dir == FORWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 * else if "errornr" is zero, redisplay the same line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 * else go to entry "errornr"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1949 qf_jump(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1950 qf_info_T *qi,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1951 int dir,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1952 int errornr,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1953 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1955 qf_info_T *ll_ref;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1956 qfline_T *qf_ptr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1957 qfline_T *old_qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 int qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 int old_qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 int old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 int prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 static char_u *e_no_more_items = (char_u *)N_("E553: No more items");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 char_u *err = e_no_more_items;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 linenr_T i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 buf_T *old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 linenr_T old_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 colnr_T screen_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 colnr_T char_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 #ifdef FEAT_WINDOWS
639
c79d4df4686e updated for version 7.0185
vimboss
parents: 634
diff changeset
1971 char_u *old_swb = p_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1972 unsigned old_swb_flags = swb_flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 int opened_window = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 win_T *altwin;
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1976 int flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 #endif
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
1978 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 int print_message = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 int old_KeyTyped = KeyTyped; /* getting file may reset it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1984 int ok = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1985 int usable_win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1986
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1987 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1988 qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1989
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1990 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1991 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1997 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 old_qf_ptr = qf_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1999 qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 old_qf_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 if (dir == FORWARD || dir == FORWARD_FILE) /* next valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 while (errornr--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 old_qf_ptr = qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 prev_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 old_qf_fnum = qf_ptr->qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2010 if (qf_index == qi->qf_lists[qi->qf_curlist].qf_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 || qf_ptr->qf_next == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 qf_index = prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 if (err != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 EMSG(_(err));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 errornr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 ++qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 qf_ptr = qf_ptr->qf_next;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2025 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2026 && !qf_ptr->qf_valid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 err = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 else if (dir == BACKWARD || dir == BACKWARD_FILE) /* prev. valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 while (errornr--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 old_qf_ptr = qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 prev_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 old_qf_fnum = qf_ptr->qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 if (qf_index == 1 || qf_ptr->qf_prev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 qf_index = prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 if (err != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 EMSG(_(err));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 errornr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 --qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 qf_ptr = qf_ptr->qf_prev;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2054 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2055 && !qf_ptr->qf_valid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 err = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 else if (errornr != 0) /* go to specified number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 while (errornr < qf_index && qf_index > 1 && qf_ptr->qf_prev != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 --qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 qf_ptr = qf_ptr->qf_prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2067 while (errornr > qf_index && qf_index <
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2068 qi->qf_lists[qi->qf_curlist].qf_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 && qf_ptr->qf_next != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 ++qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 qf_ptr = qf_ptr->qf_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2077 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2078 if (qf_win_pos_update(qi, old_qf_index))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 /* No need to print the error message if it's visible in the error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 * window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 print_message = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 /*
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2084 * For ":helpgrep" find a help window or open one.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2085 */
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2086 if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0))
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2087 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2088 win_T *wp;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2089
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2090 if (cmdmod.tab != 0)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2091 wp = NULL;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2092 else
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9608
diff changeset
2093 FOR_ALL_WINDOWS(wp)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2094 if (wp->w_buffer != NULL && wp->w_buffer->b_help)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2095 break;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2096 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2097 win_enter(wp, TRUE);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2098 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2099 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2100 /*
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2101 * Split off help window; put it at far top if no position
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2102 * specified, the current window is vertically split and narrow.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2103 */
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2104 flags = WSP_HELP;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2105 if (cmdmod.split == 0 && curwin->w_width != Columns
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2106 && curwin->w_width < 80)
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2107 flags |= WSP_TOP;
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2108 if (qi != &ql_info)
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2109 flags |= WSP_NEWLOC; /* don't copy the location list */
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2110
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2111 if (win_split(0, flags) == FAIL)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2112 goto theend;
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
2113 opened_window = TRUE; /* close it when fail */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2114
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2115 if (curwin->w_height < p_hh)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2116 win_setheight((int)p_hh);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2117
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2118 if (qi != &ql_info) /* not a quickfix list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2119 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2120 /* The new window should use the supplied location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2121 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2122 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2123 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2124 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2125
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2126 if (!p_im)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2127 restart_edit = 0; /* don't want insert mode in help file */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2128 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2129
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2130 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 * If currently in the quickfix window, find another window to show the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 * file in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
2134 if (bt_quickfix(curbuf) && !opened_window)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 {
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2136 win_T *usable_win_ptr = NULL;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2137
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 * If there is no file specified, we don't know where to go.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 * But do advance, otherwise ":cn" gets stuck.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 if (qf_ptr->qf_fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2145 usable_win = 0;
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2146
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2147 ll_ref = curwin->w_llist_ref;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2148 if (ll_ref != NULL)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2149 {
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2150 /* Find a window using the same location list that is not a
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2151 * quickfix window. */
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2152 FOR_ALL_WINDOWS(usable_win_ptr)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2153 if (usable_win_ptr->w_llist == ll_ref
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2154 && usable_win_ptr->w_buffer->b_p_bt[0] != 'q')
5084
14e7a115d54d updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents: 5062
diff changeset
2155 {
14e7a115d54d updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents: 5062
diff changeset
2156 usable_win = 1;
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2157 break;
5084
14e7a115d54d updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents: 5062
diff changeset
2158 }
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2159 }
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2160
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2161 if (!usable_win)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2162 {
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2163 /* Locate a window showing a normal buffer */
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2164 FOR_ALL_WINDOWS(win)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2165 if (win->w_buffer->b_p_bt[0] == NUL)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2166 {
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2167 usable_win = 1;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2168 break;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2169 }
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2170 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2171
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 /*
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2173 * If no usable window is found and 'switchbuf' contains "usetab"
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2174 * then search in other tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 */
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2176 if (!usable_win && (swb_flags & SWB_USETAB))
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2177 {
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2178 tabpage_T *tp;
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2179 win_T *wp;
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2180
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2181 FOR_ALL_TAB_WINDOWS(tp, wp)
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2182 {
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2183 if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum)
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2184 {
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2185 goto_tabpage_win(tp, wp);
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2186 usable_win = 1;
1819
15130d4dfea1 updated for version 7.2-117
vimboss
parents: 1743
diff changeset
2187 goto win_found;
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2188 }
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2189 }
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2190 }
1819
15130d4dfea1 updated for version 7.2-117
vimboss
parents: 1743
diff changeset
2191 win_found:
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2192
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2193 /*
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
2194 * If there is only one window and it is the quickfix window, create a
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
2195 * new one above the quickfix window.
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
2196 */
10349
cf988222b150 commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents: 10346
diff changeset
2197 if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 {
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2199 flags = WSP_ABOVE;
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2200 if (ll_ref != NULL)
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2201 flags |= WSP_NEWLOC;
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2202 if (win_split(0, flags) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 goto failed; /* not enough room for window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 opened_window = TRUE; /* close it when fail */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205 p_swb = empty_option; /* don't split again */
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2206 swb_flags = 0;
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
2207 RESET_BINDING(curwin);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2208 if (ll_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2209 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2210 /* The new window should use the location list from the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2211 * location list window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2212 curwin->w_llist = ll_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2213 ll_ref->qf_refcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2214 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2218 if (curwin->w_llist_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2219 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2220 /* In a location window */
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
2221 win = usable_win_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2222 if (win == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2223 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2224 /* Find the window showing the selected file */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2225 FOR_ALL_WINDOWS(win)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2226 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2227 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2228 if (win == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2229 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2230 /* Find a previous usable window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2231 win = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2232 do
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2233 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2234 if (win->w_buffer->b_p_bt[0] == NUL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2235 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2236 if (win->w_prev == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2237 win = lastwin; /* wrap around the top */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2238 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2239 win = win->w_prev; /* go to previous window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2240 } while (win != curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2241 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2242 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2243 win_goto(win);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2244
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2245 /* If the location list for the window is not set, then set it
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2246 * to the location list from the location window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2247 if (win->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2248 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2249 win->w_llist = ll_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2250 ll_ref->qf_refcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2251 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2252 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2253 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2254 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2255
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 * Try to find a window that shows the right buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 * Default to the window just above the quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 altwin = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 if (win->w_prev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 win = lastwin; /* wrap around the top */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 win = win->w_prev; /* go to previous window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2271 if (IS_QF_WINDOW(win))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 /* Didn't find it, go to the window before the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 * window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 if (altwin != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 win = altwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 else if (curwin->w_prev != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 win = curwin->w_prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 win = curwin->w_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 /* Remember a usable window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 if (altwin == NULL && !win->w_p_pvw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 && win->w_buffer->b_p_bt[0] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 altwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 win_goto(win);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2291 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 * If there is a file name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 * read the wanted file if needed, and check autowrite etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 old_lnum = curwin->w_cursor.lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2302
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2303 if (qf_ptr->qf_fnum != 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2304 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2305 if (qf_ptr->qf_type == 1)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2306 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2307 /* Open help file (do_ecmd() will set b_help flag, readfile() will
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2308 * set b_p_ro flag). */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2309 if (!can_abandon(curbuf, forceit))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2310 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2311 EMSG(_(e_nowrtmsg));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2312 ok = FALSE;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2313 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2314 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2315 ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2316 ECMD_HIDE + ECMD_SET_HELP,
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2317 oldwin == curwin ? curwin : NULL);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2318 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2319 else
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2320 {
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2321 int old_qf_curlist = qi->qf_curlist;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2322 int is_abort = FALSE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2323
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2324 ok = buflist_getfile(qf_ptr->qf_fnum,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2325 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
10281
92fa8e5ef210 commit https://github.com/vim/vim/commit/0a9046fbcb33770517ab0220b8100c4494bddab2
Christian Brabandt <cb@256bit.org>
parents: 10257
diff changeset
2326 if (qi != &ql_info && !win_valid_any_tab(oldwin))
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2327 {
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2328 EMSG(_("E924: Current window was closed"));
8702
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2329 is_abort = TRUE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2330 opened_window = FALSE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2331 }
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2332 else if (old_qf_curlist != qi->qf_curlist
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2333 || !is_qf_entry_present(qi, qf_ptr))
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2334 {
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2335 if (qi == &ql_info)
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2336 EMSG(_("E925: Current quickfix was changed"));
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2337 else
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2338 EMSG(_("E926: Current location list was changed"));
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2339 is_abort = TRUE;
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2340 }
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2341
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2342 if (is_abort)
39d6e4f2f748 commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
2343 {
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2344 ok = FALSE;
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2345 qi = NULL;
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2346 qf_ptr = NULL;
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2347 }
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2348 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2349 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2350
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2351 if (ok == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 /* When not switched to another buffer, still need to set pc mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 if (curbuf == old_curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2357 if (qf_ptr->qf_pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2359 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2360 * Go to line with error, unless qf_lnum is 0.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2361 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2362 i = qf_ptr->qf_lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2363 if (i > 0)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2364 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2365 if (i > curbuf->b_ml.ml_line_count)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2366 i = curbuf->b_ml.ml_line_count;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2367 curwin->w_cursor.lnum = i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2368 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2369 if (qf_ptr->qf_col > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2371 curwin->w_cursor.col = qf_ptr->qf_col - 1;
6853
d1a87b307a50 patch 7.4.747
Bram Moolenaar <bram@vim.org>
parents: 6793
diff changeset
2372 #ifdef FEAT_VIRTUALEDIT
d1a87b307a50 patch 7.4.747
Bram Moolenaar <bram@vim.org>
parents: 6793
diff changeset
2373 curwin->w_cursor.coladd = 0;
d1a87b307a50 patch 7.4.747
Bram Moolenaar <bram@vim.org>
parents: 6793
diff changeset
2374 #endif
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2375 if (qf_ptr->qf_viscol == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2377 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2378 * Check each character from the beginning of the error
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2379 * line up to the error column. For each tab character
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2380 * found, reduce the error column value by the length of
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2381 * a tab character.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2382 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2383 line = ml_get_curline();
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2384 screen_col = 0;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2385 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2387 if (*line == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2388 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2389 if (*line++ == '\t')
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2390 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2391 curwin->w_cursor.col -= 7 - (screen_col % 8);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2392 screen_col += 8 - (screen_col % 8);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2393 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2394 else
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2395 ++screen_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2398 check_cursor();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2400 else
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2401 beginline(BL_WHITE | BL_FIX);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 else
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2404 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2405 pos_T save_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2406
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2407 /* Move the cursor to the first line in the buffer */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2408 save_cursor = curwin->w_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2409 curwin->w_cursor.lnum = 0;
1521
cc4fe241baa3 updated for version 7.1-236
vimboss
parents: 1411
diff changeset
2410 if (!do_search(NULL, '/', qf_ptr->qf_pattern, (long)1,
cc4fe241baa3 updated for version 7.1-236
vimboss
parents: 1411
diff changeset
2411 SEARCH_KEEP, NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2412 curwin->w_cursor = save_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2413 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 foldOpenCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 if (print_message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 {
3267
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
2421 /* Update the screen before showing the message, unless the screen
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
2422 * scrolled up. */
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
2423 if (!msg_scrolled)
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
2424 update_topline_redraw();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2426 qi->qf_lists[qi->qf_curlist].qf_count,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 qf_ptr->qf_cleared ? _(" (line deleted)") : "",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 /* Add the message, skipping leading whitespace and newlines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 /* Output the message. Overwrite to avoid scrolling when the 'O'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 * flag is present in 'shortmess'; But when not jumping, print the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 * whole message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 i = msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 msg_scroll = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 else if (!msg_scrolled && shortmess(SHM_OVERALL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 msg_attr_keep(IObuff, 0, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 msg_scroll = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 if (opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 win_close(curwin, TRUE); /* Close opened window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 #endif
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2451 if (qf_ptr != NULL && qf_ptr->qf_fnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 * Couldn't open file, so put index back where it was. This could
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 * happen if the file was readonly and we changed something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 failed:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 qf_index = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 theend:
8605
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2465 if (qi != NULL)
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2466 {
536b9b88d1ca commit https://github.com/vim/vim/commit/0899d698030ec076eb26352cda1ea334ab0819d9
Christian Brabandt <cb@256bit.org>
parents: 8603
diff changeset
2467 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
2468 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
2469 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 if (p_swb != old_swb && opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 /* Restore old 'switchbuf' value, but not when an autocommand or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 * modeline has changed the value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 if (p_swb == empty_option)
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2476 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 p_swb = old_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2478 swb_flags = old_swb_flags;
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
2479 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 free_string_option(old_swb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 * ":clist": list all errors
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2488 * ":llist": list all locations
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2491 qf_list(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2493 buf_T *buf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2494 char_u *fname;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2495 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2496 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2497 int idx1 = 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2498 int idx2 = -1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2499 char_u *arg = eap->arg;
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2500 int plus = FALSE;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2501 int all = eap->forceit; /* if not :cl!, only show
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 recognised errors */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2503 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2504
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2505 if (eap->cmdidx == CMD_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2506 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2507 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2508 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2509 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2510 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2511 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2512 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2513 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2514
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2515 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2516 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2521 if (*arg == '+')
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2522 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2523 ++arg;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2524 plus = TRUE;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2525 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 }
9379
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2531 if (plus)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2532 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2533 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
2534 idx2 = i + idx1;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2535 idx1 = i;
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2536 }
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2537 else
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2538 {
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2539 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
2540 if (idx1 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2541 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
2542 if (idx2 < 0)
b398e4e12751 commit https://github.com/vim/vim/commit/e8fea0728a2fa1fe78ef0ac90dee1a84bd7ef9fb
Christian Brabandt <cb@256bit.org>
parents: 9369
diff changeset
2543 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
2544 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2546 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 all = TRUE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2548 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2549 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
2550 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 {
2047
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2553 msg_putchar('\n');
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2554 if (got_int)
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2555 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2556
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2557 fname = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2558 if (qfp->qf_fnum != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2560 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2561 fname = buf->b_fname;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2562 if (qfp->qf_type == 1) /* :helpgrep */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2563 fname = gettail(fname);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2564 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2565 if (fname == NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2566 sprintf((char *)IObuff, "%2d", i);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2567 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2568 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 236
diff changeset
2569 i, (char *)fname);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2570 msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
11158
501f46f7644c patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2571 ? HL_ATTR(HLF_L) : HL_ATTR(HLF_D));
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2572 if (qfp->qf_lnum == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2573 IObuff[0] = NUL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2574 else if (qfp->qf_col == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2575 sprintf((char *)IObuff, ":%ld", qfp->qf_lnum);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2576 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2577 sprintf((char *)IObuff, ":%ld col %d",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 qfp->qf_lnum, qfp->qf_col);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2579 sprintf((char *)IObuff + STRLEN(IObuff), "%s:",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
11158
501f46f7644c patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2581 msg_puts_attr(IObuff, HL_ATTR(HLF_N));
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2582 if (qfp->qf_pattern != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2583 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2584 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2585 STRCAT(IObuff, ":");
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2586 msg_puts(IObuff);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2587 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2588 msg_puts((char_u *)" ");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2589
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2590 /* Remove newlines and leading whitespace from the text. For an
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2591 * unrecognized line keep the indent, the compiler may mark a word
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2592 * with ^^^^. */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2593 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 IObuff, IOSIZE);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2596 msg_prt_line(IObuff, FALSE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2597 out_flush(); /* show one line at a time */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2599
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2600 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2601 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2602 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2603 ++i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 * Remove newlines and leading whitespace from an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 * Put the result in "buf[bufsize]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2613 qf_fmt_text(char_u *text, char_u *buf, int bufsize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 char_u *p = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 for (i = 0; *p != NUL && i < bufsize - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 buf[i] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 while (*++p != NUL)
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11063
diff changeset
2624 if (!VIM_ISWHITE(*p) && *p != '\n')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 buf[i] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 buf[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2633 static void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2634 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
2635 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2636 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
2637 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
2638 char_u buf[IOSIZE];
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2639
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2640 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
2641 lead,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2642 which + 1,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2643 qi->qf_listcount,
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2644 count);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2645
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2646 if (title != NULL)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2647 {
9579
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2648 size_t len = STRLEN(buf);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2649
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2650 if (len < 34)
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2651 {
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2652 vim_memset(buf + len, ' ', 34 - len);
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2653 buf[34] = NUL;
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2654 }
2fb7e008ac9b commit https://github.com/vim/vim/commit/16ec3c9be3fcdc38530bddb12978bc5a7b98c0f6
Christian Brabandt <cb@256bit.org>
parents: 9573
diff changeset
2655 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
2656 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2657 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
2658 msg(buf);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2659 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2660
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 * ":colder [count]": Up in the quickfix stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 * ":cnewer [count]": Down in the quickfix stack.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2664 * ":lolder [count]": Up in the location list stack.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2665 * ":lnewer [count]": Down in the location list stack.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2668 qf_age(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2670 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2673 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2674 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2675 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2676 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2677 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2678 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2679 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2680 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2681 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2682
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 while (count--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2689 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2691 if (qi->qf_curlist == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 EMSG(_("E380: At bottom of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2694 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2696 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2700 if (qi->qf_curlist >= qi->qf_listcount - 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 EMSG(_("E381: At top of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2703 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2705 ++qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 }
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2708 qf_msg(qi, qi->qf_curlist, "");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 #ifdef FEAT_WINDOWS
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
2710 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2714 void
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2715 qf_history(exarg_T *eap)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2716 {
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2717 qf_info_T *qi = &ql_info;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2718 int i;
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2719
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2720 if (eap->cmdidx == CMD_lhistory)
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2721 qi = GET_LOC_LIST(curwin);
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2722 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
2723 && 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
2724 MSG(_("No entries"));
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2725 else
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2726 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
2727 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
2728 }
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9534
diff changeset
2729
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 /*
581
ec04f19aed55 updated for version 7.0165
vimboss
parents: 532
diff changeset
2731 * Free error list "idx".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2734 qf_free(qf_info_T *qi, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2736 qfline_T *qfp;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2737 qfline_T *qfpnext;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2738 int stop = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2740 while (qi->qf_lists[idx].qf_count && qi->qf_lists[idx].qf_start != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2742 qfp = qi->qf_lists[idx].qf_start;
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2743 qfpnext = qfp->qf_next;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2744 if (qi->qf_lists[idx].qf_title != NULL && !stop)
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2745 {
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2746 vim_free(qfp->qf_text);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2747 stop = (qfp == qfpnext);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2748 vim_free(qfp->qf_pattern);
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2749 vim_free(qfp);
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2750 if (stop)
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2751 /* 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
2752 * to avoid crashing when it's wrong.
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2753 * TODO: Avoid qf_count being incorrect. */
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2754 qi->qf_lists[idx].qf_count = 1;
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2755 }
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2756 qi->qf_lists[idx].qf_start = qfpnext;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2757 --qi->qf_lists[idx].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 }
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
2759 vim_free(qi->qf_lists[idx].qf_title);
2576
2a8bf2ba504f updated for version 7.3.003
Bram Moolenaar <bram@vim.org>
parents: 2530
diff changeset
2760 qi->qf_lists[idx].qf_title = NULL;
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
2761 free_tv(qi->qf_lists[idx].qf_ctx);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
2762 qi->qf_lists[idx].qf_ctx = NULL;
6081
16cfdf28be40 updated for version 7.4.379
Bram Moolenaar <bram@vim.org>
parents: 6079
diff changeset
2763 qi->qf_lists[idx].qf_index = 0;
11378
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
2764 qi->qf_lists[idx].qf_start = NULL;
11360
83303ad9f1ff patch 8.0.0565: using freed memory in :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11301
diff changeset
2765 qi->qf_lists[idx].qf_last = NULL;
11378
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
2766 qi->qf_lists[idx].qf_ptr = NULL;
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
2767 qi->qf_lists[idx].qf_nonevalid = TRUE;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
2768
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
2769 qf_clean_dir_stack(&qi->qf_dir_stack);
10379
73e2a7abe2a3 commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents: 10369
diff changeset
2770 qi->qf_directory = NULL;
9397
e08e8b00fe48 commit https://github.com/vim/vim/commit/361c8f0e517e41f1f1d34dae328044406fde80ac
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
2771 qf_clean_dir_stack(&qi->qf_file_stack);
10379
73e2a7abe2a3 commit https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df
Christian Brabandt <cb@256bit.org>
parents: 10369
diff changeset
2772 qi->qf_currfile = NULL;
11378
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
2773 qi->qf_multiline = FALSE;
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
2774 qi->qf_multiignore = FALSE;
2ed7a34ecc54 patch 8.0.0574: get only one quickfix list after :caddbuf
Christian Brabandt <cb@256bit.org>
parents: 11360
diff changeset
2775 qi->qf_multiscan = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 * qf_mark_adjust: adjust marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2782 qf_mark_adjust(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2783 win_T *wp,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2784 linenr_T line1,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2785 linenr_T line2,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2786 long amount,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2787 long amount_after)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2789 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2790 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2791 int idx;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2792 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
2793 int found_one = FALSE;
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
2794 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
2795
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
2796 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
2797 return;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2798 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2799 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2800 if (wp->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2801 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2802 qi = wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2803 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2804
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2805 for (idx = 0; idx < qi->qf_listcount; ++idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2806 if (qi->qf_lists[idx].qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2807 for (i = 0, qfp = qi->qf_lists[idx].qf_start;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2808 i < qi->qf_lists[idx].qf_count && qfp != NULL;
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
2809 ++i, qfp = qfp->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810 if (qfp->qf_fnum == curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 {
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
2812 found_one = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815 if (amount == MAXLNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 qfp->qf_cleared = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 qfp->qf_lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 else if (amount_after && qfp->qf_lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821 qfp->qf_lnum += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822 }
9201
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
2823
692e156c7023 commit https://github.com/vim/vim/commit/2f095a4bc4d786e0ac834f48dd18a94fe2d140e3
Christian Brabandt <cb@256bit.org>
parents: 9197
diff changeset
2824 if (!found_one)
9608
fa64afb99dda commit https://github.com/vim/vim/commit/c1542744e788d96fed24dd421f43009288092504
Christian Brabandt <cb@256bit.org>
parents: 9579
diff changeset
2825 curbuf->b_has_qf_entry &= ~buf_has_flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 * Make a nice message out of the error character and the error number:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 * char number message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 * e or E 0 " error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 * w or W 0 " warning"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 * i or I 0 " info"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 * 0 0 ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 * other 0 " c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 * e or E n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 * w or W n " warning n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 * i or I n " info n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 * 0 n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 * other n " c n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 * 1 x "" :helpgrep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2844 qf_types(int c, int nr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 static char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 static char_u cc[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 if (c == 'W' || c == 'w')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851 p = (char_u *)" warning";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852 else if (c == 'I' || c == 'i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 p = (char_u *)" info";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855 p = (char_u *)" error";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856 else if (c == 0 || c == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 p = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 cc[0] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 cc[1] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 cc[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 p = cc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 if (nr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 sprintf((char *)buf, "%s %3d", (char *)p, nr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2873 #if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875 * ":cwindow": open the quickfix window if we have errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 * close it if not.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2877 * ":lwindow": open the location list window if we have locations to display,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2878 * close it if not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2881 ex_cwindow(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2883 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2886 if (eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2887 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2888 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2889 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2890 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2891 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2892
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2893 /* Look for an existing quickfix window. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2894 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897 * If a quickfix window is open but we have no errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 * close the window. If a quickfix window is not open, then open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2899 * it if we have errors; otherwise, leave it closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2901 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
2902 || qi->qf_lists[qi->qf_curlist].qf_count == 0
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
2903 || qi->qf_curlist >= qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 ex_cclose(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 else if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909 ex_copen(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 * ":cclose": close the window showing the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2914 * ":lclose": close the window showing the location list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2917 ex_cclose(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2919 win_T *win = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2920 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2921
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2922 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2923 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2924 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2925 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2926 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2927 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2928
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2929 /* Find existing quickfix window and close it. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2930 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 win_close(win, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936 * ":copen": open a window that shows the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2937 * ":lopen": open a window that shows the location list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2940 ex_copen(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2942 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944 win_T *win;
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2945 tabpage_T *prevtab = curtab;
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2946 buf_T *qf_buf;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2947 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2949 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2950 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2951 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2952 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2953 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2954 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2955 return;
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
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 height = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962 height = QF_WINHEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 reset_VIsual_and_resel(); /* stop Visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 * Find existing quickfix window, or open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2972 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2973
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2974 if (win != NULL && cmdmod.tab == 0)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2975 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 win_goto(win);
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2977 if (eap->addr_count != 0)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2978 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2979 if (cmdmod.split & WSP_VERT)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2980 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2981 if (height != W_WIDTH(win))
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2982 win_setwidth(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2983 }
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
2984 else if (height != win->w_height)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2985 win_setheight(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2986 }
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2987 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2990 qf_buf = qf_find_buf(qi);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2991
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 /* The current window becomes the previous window afterwards. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994
3939
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2995 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
2996 && cmdmod.split == 0)
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2997 /* Create the new window at the very bottom, except when
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2998 * :belowright or :aboveleft is used. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2999 win_goto(lastwin);
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
3000 if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001 return; /* not enough room for window */
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
3002 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3004 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3006 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3007 * For the location list window, create a reference to the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3008 * location list from the window 'win'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3009 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3010 curwin->w_llist_ref = win->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3011 win->w_llist->qf_refcount++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3013
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3014 if (oldwin != curwin)
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3015 oldwin = NULL; /* don't store info when in another window */
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3016 if (qf_buf != NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3017 /* Use the existing quickfix buffer */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3018 (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
3019 ECMD_HIDE + ECMD_OLDBUF, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3020 else
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3021 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3022 /* Create a new quickfix buffer */
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
3023 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3024 /* switch off 'swapfile' */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3025 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3026 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
729
3d0ca316efab updated for version 7.0221
vimboss
parents: 717
diff changeset
3027 OPT_LOCAL);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3028 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
3029 RESET_BINDING(curwin);
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3030 #ifdef FEAT_DIFF
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3031 curwin->w_p_diff = FALSE;
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3032 #endif
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3033 #ifdef FEAT_FOLDING
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3034 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3035 OPT_LOCAL);
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
3036 #endif
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3037 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
3039 /* 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
3040 * window to the side. */
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8605
diff changeset
3041 if (curtab == prevtab && curwin->w_width == Columns)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3042 win_setheight(height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3043 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3044 if (win_valid(win))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 prevwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3048 qf_set_title_var(qi);
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3049
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 * Fill the buffer with the quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3052 */
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3053 qf_fill_buffer(qi, curbuf, NULL);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3054
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3055 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3057 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3058 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3060
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3061 /*
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3062 * 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
3063 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3064 static void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3065 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
3066 {
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3067 win_T *old_curwin = curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3068
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3069 curwin = win;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3070 curbuf = win->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3071 curwin->w_cursor.lnum = lnum;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3072 curwin->w_cursor.col = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3073 #ifdef FEAT_VIRTUALEDIT
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3074 curwin->w_cursor.coladd = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3075 #endif
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3076 curwin->w_curswant = 0;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3077 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
3078 redraw_later(VALID);
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3079 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
3080 curwin = old_curwin;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3081 curbuf = curwin->w_buffer;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3082 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3083
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3084 /*
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3085 * :cbottom/:lbottom commands.
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3086 */
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3087 void
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3088 ex_cbottom(exarg_T *eap UNUSED)
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3089 {
9458
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3090 qf_info_T *qi = &ql_info;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3091 win_T *win;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3092
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3093 if (eap->cmdidx == CMD_lbottom)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3094 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3095 qi = GET_LOC_LIST(curwin);
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3096 if (qi == NULL)
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3097 {
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3098 EMSG(_(e_loclist));
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3099 return;
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3100 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3101 }
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3102
374afcf9d11d commit https://github.com/vim/vim/commit/537ef08408c50e0c4104d57f74993b3b0ed9560d
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
3103 win = qf_find_win(qi);
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3104 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
3105 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
3106 }
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3107
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3108 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109 * Return the number of the current entry (line number in the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 * window).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 linenr_T
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3113 qf_current_entry(win_T *wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3115 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3116
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3117 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3118 /* In the location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3119 qi = wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3120
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3121 return qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3122 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3124 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 * Update the cursor position in the quickfix window to the current error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126 * Return TRUE if there is a quickfix window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3129 qf_win_pos_update(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3130 qf_info_T *qi,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3131 int old_qf_index) /* previous qf_index or zero */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 win_T *win;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3134 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3136 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3137 * Put the cursor on the current error in the quickfix window, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 * it's viewable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3140 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 if (win != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142 && qf_index <= win->w_buffer->b_ml.ml_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143 && old_qf_index != qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3145 if (qf_index > old_qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3146 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3147 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
3148 win->w_redraw_bot = qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3150 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3151 {
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3152 win->w_redraw_top = qf_index;
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3153 win->w_redraw_bot = old_qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3154 }
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9397
diff changeset
3155 qf_win_goto(win, qf_index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 return win != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3161 * Check whether the given window is displaying the specified quickfix/location
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3162 * list buffer
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3163 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3164 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3165 is_qf_win(win_T *win, qf_info_T *qi)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3166 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3167 /*
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3168 * A window displaying the quickfix buffer will have the w_llist_ref field
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3169 * set to NULL.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3170 * A window displaying a location list buffer will have the w_llist_ref
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3171 * pointing to the location list.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3172 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3173 if (bt_quickfix(win->w_buffer))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3174 if ((qi == &ql_info && win->w_llist_ref == NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3175 || (qi != &ql_info && win->w_llist_ref == qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3176 return TRUE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3177
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3178 return FALSE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3179 }
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3180
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3181 /*
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3182 * Find a window displaying the quickfix/location list 'qi'
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3183 * Searches in only the windows opened in the current tab.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3184 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3185 static win_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3186 qf_find_win(qf_info_T *qi)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3187 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3188 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3189
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3190 FOR_ALL_WINDOWS(win)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3191 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3192 break;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3193
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3194 return win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3195 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3196
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3197 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3198 * Find a quickfix buffer.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3199 * Searches in windows opened in all the tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3200 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3201 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3202 qf_find_buf(qf_info_T *qi)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3203 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3204 tabpage_T *tp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3205 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3206
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3207 FOR_ALL_TAB_WINDOWS(tp, win)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3208 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3209 return win->w_buffer;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3210
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
3211 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3212 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3214 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3215 * 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
3216 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3217 static void
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3218 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
3219 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3220 win_T *win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3221 win_T *curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3222
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3223 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
3224 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3225 curwin_save = curwin;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3226 curwin = win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3227 qf_set_title_var(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3228 curwin = curwin_save;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3229 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3230 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3231
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3232 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3233 * Find the quickfix buffer. If it exists, update the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3235 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3236 qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3237 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238 buf_T *buf;
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3239 win_T *win;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 aco_save_T aco;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 /* Check if a buffer for the quickfix list exists. Update it. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3243 buf = qf_find_buf(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3245 {
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3246 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
3247
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3248 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3249 /* 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
3250 aucmd_prepbuf(&aco, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
3252 qf_update_win_titlevar(qi);
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3253
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3254 qf_fill_buffer(qi, buf, old_last);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3255
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3256 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3257 {
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
3258 (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
3259
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3260 /* 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
3261 aucmd_restbuf(&aco);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3262 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3263
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3264 /* 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
3265 * 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
3266 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
3267 redraw_buf_later(buf, NOT_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3270
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3271 /*
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3272 * Set "w:quickfix_title" if "qi" has a title.
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3273 */
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3274 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3275 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
3276 {
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3277 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL)
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
3278 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
3279 qi->qf_lists[qi->qf_curlist].qf_title);
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3280 }
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
3281
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3282 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283 * Fill current buffer with quickfix errors, replacing any previous contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3284 * 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
3285 * 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
3286 * 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
3287 * ml_delete() is used and autocommands will be triggered.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3288 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3289 static void
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3290 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
3291 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3292 linenr_T lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3293 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3294 buf_T *errbuf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3295 int len;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3296 int old_KeyTyped = KeyTyped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3298 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3299 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3300 if (buf != curbuf)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3301 {
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
3302 internal_error("qf_fill_buffer()");
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3303 return;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3304 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3305
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3306 /* delete all existing lines */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3307 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
3308 (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
3309 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3311 /* Check if there is anything to display */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3312 if (qi->qf_curlist < qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3313 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3314 /* 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
3315 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3316 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3317 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
3318 lnum = 0;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3319 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3320 else
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3321 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3322 qfp = old_last->qf_next;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3323 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
3324 }
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3325 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 if (qfp->qf_fnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329 && errbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 if (qfp->qf_type == 1) /* :helpgrep */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 STRCPY(IObuff, gettail(errbuf->b_fname));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 STRCPY(IObuff, errbuf->b_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3335 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3341 if (qfp->qf_lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 if (qfp->qf_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 sprintf((char *)IObuff + len, " col %d", qfp->qf_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3349 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 sprintf((char *)IObuff + len, "%s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3355 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3356 else if (qfp->qf_pattern != NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3357 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3358 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3359 len += (int)STRLEN(IObuff + len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3360 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3361 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3362 IObuff[len++] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3364 /* Remove newlines and leading whitespace from the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 * For an unrecognized line keep the indent, the compiler may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366 * mark a word with ^^^^. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3367 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3368 IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3369
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3370 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
3371 (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3372 break;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3373 ++lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3374 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3375 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3376 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3377 }
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3378
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3379 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3380 /* 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
3381 (void)ml_delete(lnum + 1, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3384 /* correct cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385 check_lnums(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3386
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3387 if (old_last == NULL)
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3388 {
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3389 /* 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
3390 * 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
3391 * using autocommands. */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3392 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
3393 curbuf->b_p_ma = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3395 #ifdef FEAT_AUTOCMD
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3396 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
3397 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3398 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3399 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3400 FALSE, curbuf);
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3401 keep_filetype = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3402 #endif
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3403 /* make sure it will be redrawn */
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3404 redraw_curbuf_later(NOT_VALID);
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
3405 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3407 /* Restore KeyTyped, setting 'filetype' may reset it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 KeyTyped = old_KeyTyped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3411 #endif /* FEAT_WINDOWS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3412
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3413 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3414 * Return TRUE if "buf" is the quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3415 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3416 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3417 bt_quickfix(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3418 {
3242
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
3419 return buf != NULL && buf->b_p_bt[0] == 'q';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3422 /*
17
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
3423 * Return TRUE if "buf" is a "nofile" or "acwrite" buffer.
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
3424 * This means the buffer name is not a file name.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3425 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3426 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3427 bt_nofile(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3428 {
3242
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
3429 return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
3430 || buf->b_p_bt[0] == 'a');
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3433 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3434 * Return TRUE if "buf" is a "nowrite" or "nofile" buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3435 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3436 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3437 bt_dontwrite(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 {
3242
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
3439 return buf != NULL && buf->b_p_bt[0] == 'n';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3440 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3441
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3442 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3443 bt_dontwrite_msg(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3445 if (bt_dontwrite(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3446 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3447 EMSG(_("E382: Cannot write, 'buftype' option is set"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3448 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3450 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3451 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3452
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3453 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3454 * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3455 * and 'bufhidden'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3456 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3457 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3458 buf_hide(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3460 /* 'bufhidden' overrules 'hidden' and ":hide", check it first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3461 switch (buf->b_p_bh[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3462 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3463 case 'u': /* "unload" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3464 case 'w': /* "wipe" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3465 case 'd': return FALSE; /* "delete" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3466 case 'h': return TRUE; /* "hide" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3467 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3468 return (p_hid || cmdmod.hide);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3471 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3472 * Return TRUE when using ":vimgrep" for ":grep".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3473 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3474 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3475 grep_internal(cmdidx_T cmdidx)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3476 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3477 return ((cmdidx == CMD_grep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3478 || cmdidx == CMD_lgrep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3479 || cmdidx == CMD_grepadd
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3480 || cmdidx == CMD_lgrepadd)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3481 && STRCMP("internal",
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3482 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3483 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3484
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3485 /*
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3486 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3487 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3488 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3489 ex_make(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3490 {
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3491 char_u *fname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3492 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
3493 char_u *enc = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3494 unsigned len;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3495 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3496 qf_info_T *qi = &ql_info;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3497 int res;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3498 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3499 char_u *au_name = NULL;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3500
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3501 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3502 if (grep_internal(eap->cmdidx))
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3503 {
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3504 ex_vimgrep(eap);
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3505 return;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3506 }
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3507
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3508 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3509 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3510 case CMD_make: au_name = (char_u *)"make"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3511 case CMD_lmake: au_name = (char_u *)"lmake"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3512 case CMD_grep: au_name = (char_u *)"grep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3513 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3514 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3515 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3516 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3517 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3518 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
3519 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3520 {
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3521 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
3522 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3523 return;
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
3524 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3525 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3526 #endif
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3527 #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
3528 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
3529 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3531 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3532 || eap->cmdidx == CMD_lgrepadd)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3533 wp = curwin;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3534
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3535 autowrite_all();
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3536 fname = get_mef_name();
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3537 if (fname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538 return;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3539 mch_remove(fname); /* in case it's not unique */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3541 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3542 * If 'shellpipe' empty: don't redirect to 'errorfile'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3543 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3544 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3545 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3546 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3547 cmd = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3548 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3549 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3550 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3551 (char *)p_shq);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 if (*p_sp != NUL)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1864
diff changeset
3553 append_redir(cmd, len, p_sp, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3554 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3555 * Output a newline if there's something else than the :make command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556 * was typed (in which case the cursor is in column 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3558 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3559 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3560 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3561 MSG_PUTS(":!");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3562 msg_outtrans(cmd); /* show what we are doing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3563
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3564 /* let the shell know if we are redirecting output or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3565 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3566
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3567 #ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3568 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3569 /* read window status report and redraw before message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3570 (void)char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3571 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3572
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3573 res = qf_init(wp, fname, (eap->cmdidx != CMD_make
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3574 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3575 (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
3576 && eap->cmdidx != CMD_lgrepadd),
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3577 *eap->cmdlinep, enc);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3578 if (wp != NULL)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3579 qi = GET_LOC_LIST(wp);
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3580 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3581 if (au_name != NULL)
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3582 {
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3583 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3584 curbuf->b_fname, TRUE, curbuf);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3585 if (qi->qf_curlist < qi->qf_listcount)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3586 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
3587 else
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3588 res = 0;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
3589 }
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3590 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3591 if (res > 0 && !eap->forceit)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3592 qf_jump(qi, 0, 0, FALSE); /* display first error */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3593
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3594 mch_remove(fname);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3595 vim_free(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3596 vim_free(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3599 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3600 * Return the name for the errorfile, in allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3601 * Find a new unique name when 'makeef' contains "##".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3602 * Returns NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3603 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3604 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3605 get_mef_name(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3606 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3607 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3609 static int start = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3610 static int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3611 #ifdef HAVE_LSTAT
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents: 9379
diff changeset
3612 stat_T sb;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3613 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3615 if (*p_mef == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3616 {
6721
7347229a646a updated for version 7.4.684
Bram Moolenaar <bram@vim.org>
parents: 6450
diff changeset
3617 name = vim_tempname('e', FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3618 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3619 EMSG(_(e_notmp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3620 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3623 for (p = p_mef; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3624 if (p[0] == '#' && p[1] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3625 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3626
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3627 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3628 return vim_strsave(p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3630 /* Keep trying until the name doesn't exist yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3631 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 if (start == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3634 start = mch_get_pid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3636 off += 19;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638 name = alloc((unsigned)STRLEN(p_mef) + 30);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3640 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3641 STRCPY(name, p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3643 STRCAT(name, p + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3644 if (mch_getperm(name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3645 #ifdef HAVE_LSTAT
10226
7a4fb555c83a commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents: 10056
diff changeset
3646 /* Don't accept a symbolic link, it's a security risk. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 && mch_lstat((char *)name, &sb) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3648 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3649 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3650 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3651 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3653 return name;
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 /*
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3657 * 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
3658 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3659 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3660 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
3661 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3662 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3663 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3664 int i, sz = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3665 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3666
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3667 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
3668 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3669 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3670 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3671 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3672 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3673 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3674
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3675 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
3676 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
3677 ++i, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3678 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3679 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3680 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3681 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
3682 sz++; /* Count all valid entries */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3683 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
3684 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3685 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3686 sz++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3687 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3688 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3689 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3690 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3691
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3692 return sz;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3693 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3694
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3695 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3696 * 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
3697 * 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
3698 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3699 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3700 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
3701 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3702 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3703
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3704 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
3705 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3706 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3707 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3708 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3709 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3710 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3711
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3712 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
3713 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3714
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3715 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3716 * 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
3717 * 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
3718 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3719 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3720 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
3721 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3722 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3723 qf_list_T *qfl;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3724 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3725 int i, eidx = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3726 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3727
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3728 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
3729 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3730 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3731 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3732 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3733 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3734 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3735
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3736 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
3737 qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3738
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3739 /* 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
3740 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
3741 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3742
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3743 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
3744 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3745 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3746 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3747 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
3748 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3749 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
3750 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3751 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3752 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3753 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3754 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3755 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3756 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3757 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3758 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3759 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3760
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3761 return eidx ? eidx : 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3762 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3763
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3764 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3765 * 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
3766 * 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
3767 * 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
3768 * 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
3769 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3770 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3771 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
3772 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3773 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
3774 qfline_T *qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3775 int i, eidx;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3776 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3777
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3778 /* 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
3779 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
3780 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3781
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
3782 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
3783 i++, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3784 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3785 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3786 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3787 if (fdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3788 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3789 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
3790 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3791 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3792 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3793 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3794 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3795 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3796 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3797 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3798 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3799
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3800 if (eidx == n)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3801 break;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3802 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3803
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3804 if (i <= qfl->qf_count)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3805 return i;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3806 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3807 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3808 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3809
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3810 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3811 * ":cc", ":crewind", ":cfirst" and ":clast".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3812 * ":ll", ":lrewind", ":lfirst" and ":llast".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3813 * ":cdo", ":ldo", ":cfdo" and ":lfdo"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3814 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3815 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3816 ex_cc(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3817 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3818 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
3819 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3820
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3821 if (eap->cmdidx == CMD_ll
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3822 || eap->cmdidx == CMD_lrewind
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3823 || eap->cmdidx == CMD_lfirst
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3824 || eap->cmdidx == CMD_llast
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3825 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3826 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3827 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3828 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3829 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3830 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3831 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3832 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3833 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3834 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3835
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3836 if (eap->addr_count > 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3837 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3838 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3839 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3840 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
3841 errornr = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3842 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
3843 || 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
3844 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3845 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3846 errornr = 32767;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3847 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3848
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3849 /* 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
3850 * 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
3851 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3852 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
3853 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
3854 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
3855 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
3856 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
3857
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3858 qf_jump(qi, 0, errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3861 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3862 * ":cnext", ":cnfile", ":cNext" and ":cprevious".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3863 * ":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
3864 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3866 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3867 ex_cnext(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3868 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3869 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
3870 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3871
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3872 if (eap->cmdidx == CMD_lnext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3873 || eap->cmdidx == CMD_lNext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3874 || eap->cmdidx == CMD_lprevious
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3875 || eap->cmdidx == CMD_lnfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3876 || eap->cmdidx == CMD_lNfile
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3877 || eap->cmdidx == CMD_lpfile
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3878 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3879 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3880 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3881 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3882 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3883 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3884 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3885 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3886 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3887 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3888
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3889 if (eap->addr_count > 0 &&
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3890 (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
3891 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
3892 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3893 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3894 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3895
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3896 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
3897 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3898 ? FORWARD
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3899 : (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
3900 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3901 ? FORWARD_FILE
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3902 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3903 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3904 ? BACKWARD_FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3905 : BACKWARD,
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3906 errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3908
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3909 /*
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3910 * ":cfile"/":cgetfile"/":caddfile" commands.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3911 * ":lfile"/":lgetfile"/":laddfile" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3912 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3913 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3914 ex_cfile(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3915 {
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3916 char_u *enc = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3917 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3918 qf_info_T *qi = &ql_info;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3919 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3920 char_u *au_name = NULL;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3921 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3922
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3923 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3924 || eap->cmdidx == CMD_laddfile)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3925 wp = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3926
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3927 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3928 switch (eap->cmdidx)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3929 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3930 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
3931 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
3932 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
3933 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
3934 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
3935 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
3936 default: break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3937 }
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3938 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3939 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3940 #endif
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3941 #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
3942 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
3943 #endif
2296
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3944 #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
3945 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
3946 {
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3947 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg,
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3948 NULL, NULL, BROWSE_FILTER_ALL_FILES, NULL);
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3949 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
3950 return;
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3951 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
3952 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
3953 }
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3954 else
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3955 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3956 if (*eap->arg != NUL)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 682
diff changeset
3957 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
3958
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3959 /*
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3960 * This function is used by the :cfile, :cgetfile and :caddfile
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3961 * commands.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3962 * :cfile always creates a new quickfix list and jumps to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3963 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3964 * :cgetfile creates a new quickfix list but doesn't jump to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3965 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3966 * :caddfile adds to an existing quickfix list. If there is no
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3967 * quickfix list then a new list is created.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3968 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3969 if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
3970 && eap->cmdidx != CMD_laddfile),
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
3971 *eap->cmdlinep, enc) > 0
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3972 && (eap->cmdidx == CMD_cfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3973 || eap->cmdidx == CMD_lfile))
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3974 {
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3975 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3976 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3977 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3978 #endif
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3979 if (wp != NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3980 qi = GET_LOC_LIST(wp);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3981 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3982 }
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3983
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3984 else
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3985 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3986 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3987 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3988 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3989 #endif
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3990 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3991 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3993 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3994 * ":vimgrep {pattern} file(s)"
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3995 * ":vimgrepadd {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3996 * ":lvimgrep {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3997 * ":lvimgrepadd {pattern} file(s)"
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3998 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3999 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4000 ex_vimgrep(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4001 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4002 regmmatch_T regmatch;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4003 int fcount;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4004 char_u **fnames;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4005 char_u *fname;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4006 char_u *title;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4007 char_u *s;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4008 char_u *p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4009 int fi;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4010 qf_info_T *qi = &ql_info;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4011 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4012 qfline_T *cur_qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4013 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4014 long lnum;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4015 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4016 int duplicate_name = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4017 int using_dummy;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4018 int redraw_for_dummy = FALSE;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4019 int found_match;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4020 buf_T *first_match_buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4021 time_t seconds = 0;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4022 int save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4023 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4024 char_u *save_ei = NULL;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4025 #endif
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4026 aco_save_T aco;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4027 int flags = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4028 colnr_T col;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4029 long tomatch;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4030 char_u *dirname_start = NULL;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4031 char_u *dirname_now = NULL;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4032 char_u *target_dir = NULL;
1683
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4033 #ifdef FEAT_AUTOCMD
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
4034 char_u *au_name = NULL;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4035
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4036 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4037 {
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4038 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4039 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4040 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4041 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break;
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4042 case CMD_grep: au_name = (char_u *)"grep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4043 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4044 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
4045 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4046 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4047 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4048 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
4049 curbuf->b_fname, TRUE, curbuf))
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4050 {
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4051 # ifdef FEAT_EVAL
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4052 if (aborting())
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4053 return;
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
4054 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4055 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
4056 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4057
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4058 if (eap->cmdidx == CMD_lgrep
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4059 || eap->cmdidx == CMD_lvimgrep
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4060 || eap->cmdidx == CMD_lgrepadd
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4061 || eap->cmdidx == CMD_lvimgrepadd)
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4062 {
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4063 qi = ll_get_or_alloc_list(curwin);
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4064 if (qi == NULL)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4065 return;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4066 }
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4067
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4068 if (eap->addr_count > 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4069 tomatch = eap->line2;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4070 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4071 tomatch = MAXLNUM;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4072
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4073 /* Get the search pattern: either white-separated or enclosed in // */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4074 regmatch.regprog = NULL;
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4075 title = vim_strsave(*eap->cmdlinep);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4076 p = skip_vimgrep_pat(eap->arg, &s, &flags);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4077 if (p == NULL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4078 {
282
33d9c918b8ab updated for version 7.0075
vimboss
parents: 277
diff changeset
4079 EMSG(_(e_invalpat));
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
4080 goto theend;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4081 }
4197
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4082
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4083 if (s != NULL && *s == NUL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4084 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4085 /* Pattern is empty, use last search pattern. */
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4086 if (last_search_pat() == NULL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4087 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4088 EMSG(_(e_noprevre));
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4089 goto theend;
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4090 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4091 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4092 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4093 else
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4094 regmatch.regprog = vim_regcomp(s, RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
4095
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4096 if (regmatch.regprog == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4097 goto theend;
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 42
diff changeset
4098 regmatch.rmm_ic = p_ic;
410
c60ba877860b updated for version 7.0107
vimboss
parents: 359
diff changeset
4099 regmatch.rmm_maxcol = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4100
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4101 p = skipwhite(p);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4102 if (*p == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4103 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4104 EMSG(_("E683: File name missing or invalid pattern"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4105 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4106 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4107
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4108 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd &&
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4109 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4110 || qi->qf_curlist == qi->qf_listcount)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4111 /* make place for a new list */
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4112 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4113
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4114 /* parse the list of arguments */
3620
4f1c511e71f8 updated for version 7.3.570
Bram Moolenaar <bram@vim.org>
parents: 3555
diff changeset
4115 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4116 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4117 if (fcount == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4118 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4119 EMSG(_(e_nomatch));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4120 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4121 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4122
7558
9a4c9dccd603 commit https://github.com/vim/vim/commit/b86a343280b08d6701da68ee0651e960a0a7a61c
Christian Brabandt <cb@256bit.org>
parents: 7515
diff changeset
4123 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
4124 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
4125 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
4126 {
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4127 FreeWild(fcount, fnames);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4128 goto theend;
7662
4d34891e98f4 commit https://github.com/vim/vim/commit/61ff4dd6a4d47bd32383fe28087be2b37dec53f4
Christian Brabandt <cb@256bit.org>
parents: 7558
diff changeset
4129 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4130
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4131 /* Remember the current directory, because a BufRead autocommand that does
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4132 * ":lcd %:p:h" changes the meaning of short path names. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4133 mch_dirname(dirname_start, MAXPATHL);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4134
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4135 #ifdef FEAT_AUTOCMD
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4197
diff changeset
4136 /* Remember the value of qf_start, so that we can check for autocommands
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4137 * changing the current quickfix list. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4138 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4139 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4140
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4141 seconds = (time_t)0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4142 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4143 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4144 fname = shorten_fname1(fnames[fi]);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4145 if (time(NULL) > seconds)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4146 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4147 /* 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
4148 * working on it. */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4149 seconds = time(NULL);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4150 msg_start();
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4151 p = msg_strtrunc(fname, TRUE);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4152 if (p == NULL)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4153 msg_outtrans(fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4154 else
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4155 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4156 msg_outtrans(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4157 vim_free(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4158 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4159 msg_clr_eos();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4160 msg_didout = FALSE; /* overwrite this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4161 msg_nowait = TRUE; /* don't wait for this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4162 msg_col = 0;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4163 out_flush();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4164 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4165
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4166 buf = buflist_findname_exp(fnames[fi]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4167 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4168 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4169 /* Remember that a buffer with this name already exists. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4170 duplicate_name = (buf != NULL);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4171 using_dummy = TRUE;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4172 redraw_for_dummy = TRUE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4173
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4174 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4175 /* Don't do Filetype autocommands to avoid loading syntax and
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4176 * indent scripts, a great speed improvement. */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4177 save_ei = au_event_disable(",Filetype");
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4178 #endif
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4179 /* Don't use modelines here, it's useless. */
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4180 save_mls = p_mls;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4181 p_mls = 0;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4182
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4183 /* Load file into a buffer, so that 'fileencoding' is detected,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4184 * autocommands applied, etc. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4185 buf = load_dummy_buffer(fname, dirname_start, dirname_now);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4186
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4187 p_mls = save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4188 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4189 au_event_restore(save_ei);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4190 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4191 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4192 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4193 /* Use existing, loaded buffer. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4194 using_dummy = FALSE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4195
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4196 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4197 if (cur_qf_start != qi->qf_lists[qi->qf_curlist].qf_start)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4198 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4199 int idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4200
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4201 /* Autocommands changed the quickfix list. Find the one we were
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4202 * using and restore it. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4203 for (idx = 0; idx < LISTCOUNT; ++idx)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4204 if (cur_qf_start == qi->qf_lists[idx].qf_start)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4205 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4206 qi->qf_curlist = idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4207 break;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4208 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4209 if (idx == LISTCOUNT)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4210 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4211 /* List cannot be found, create a new one. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4212 qf_new_list(qi, *eap->cmdlinep);
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4213 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4214 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4215 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4216 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4217
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4218 if (buf == NULL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4219 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4220 if (!got_int)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4221 smsg((char_u *)_("Cannot open file \"%s\""), fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4222 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4223 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4224 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4225 /* Try for a match in all lines of the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4226 * For ":1vimgrep" look for first match only. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4227 found_match = FALSE;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4228 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4229 ++lnum)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4230 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4231 col = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4232 while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
1521
cc4fe241baa3 updated for version 7.1-236
vimboss
parents: 1411
diff changeset
4233 col, NULL) > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4234 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4235 /* Pass the buffer number so that it gets used even for a
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4236 * dummy buffer, unless duplicate_name is set, then the
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4237 * buffer will be wiped out below. */
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4238 if (qf_add_entry(qi,
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4239 NULL, /* dir */
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4240 fname,
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4241 duplicate_name ? 0 : buf->b_fnum,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4242 ml_get_buf(buf,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4243 regmatch.startpos[0].lnum + lnum, FALSE),
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4244 regmatch.startpos[0].lnum + lnum,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4245 regmatch.startpos[0].col + 1,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4246 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4247 NULL, /* search pattern */
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4248 0, /* nr */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4249 0, /* type */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
4250 TRUE /* valid */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4251 ) == FAIL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4252 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4253 got_int = TRUE;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4254 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4255 }
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4256 found_match = TRUE;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4257 if (--tomatch == 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
4258 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4259 if ((flags & VGR_GLOBAL) == 0
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4260 || regmatch.endpos[0].lnum > 0)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4261 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4262 col = regmatch.endpos[0].col
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4263 + (col == regmatch.endpos[0].col);
1883
c8f343a465a2 updated for version 7.2-180
vimboss
parents: 1872
diff changeset
4264 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE)))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4265 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4266 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4267 line_breakcheck();
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4268 if (got_int)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4269 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4270 }
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4271 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4272 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
4273 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4274
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4275 if (using_dummy)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4276 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4277 if (found_match && first_match_buf == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4278 first_match_buf = buf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4279 if (duplicate_name)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4280 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4281 /* Never keep a dummy buffer if there is another buffer
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4282 * with the same name. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4283 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4284 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4285 }
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4286 else if (!cmdmod.hide
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4287 || buf->b_p_bh[0] == 'u' /* "unload" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4288 || buf->b_p_bh[0] == 'w' /* "wipe" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4289 || buf->b_p_bh[0] == 'd') /* "delete" */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4290 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4291 /* When no match was found we don't need to remember the
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4292 * buffer, wipe it out. If there was a match and it
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4293 * wasn't the first one or we won't jump there: only
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4294 * unload the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4295 * Ignore 'hidden' here, because it may lead to having too
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4296 * many swap files. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4297 if (!found_match)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4298 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4299 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4300 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4301 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4302 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4303 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4304 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
4305 /* 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
4306 buf->b_flags &= ~BF_DUMMY;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4307 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4308 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4309 }
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4310
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4311 if (buf != NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4312 {
9540
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4313 /* 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
4314 buf->b_flags &= ~BF_DUMMY;
64a791c53418 commit https://github.com/vim/vim/commit/015102e91e978a0bb42a14461c132a85e8f7e1ea
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
4315
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4316 /* If the buffer is still loaded we need to use the
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4317 * directory we jumped to below. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4318 if (buf == first_match_buf
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4319 && target_dir == NULL
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4320 && STRCMP(dirname_start, dirname_now) != 0)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4321 target_dir = vim_strsave(dirname_now);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4322
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4323 /* The buffer is still loaded, the Filetype autocommands
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4324 * need to be done now, in that buffer. And the modelines
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4325 * need to be done (again). But not the window-local
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4326 * options! */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4327 aucmd_prepbuf(&aco, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4328 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4329 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4330 buf->b_fname, TRUE, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
4331 #endif
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
4332 do_modelines(OPT_NOWIN);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4333 aucmd_restbuf(&aco);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
4334 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4335 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4336 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4337 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4338
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4339 FreeWild(fcount, fnames);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4340
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4341 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4342 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
4343 qi->qf_lists[qi->qf_curlist].qf_index = 1;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4344
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4345 #ifdef FEAT_WINDOWS
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4346 qf_update_buffer(qi, NULL);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4347 #endif
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4348
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4349 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4350 if (au_name != NULL)
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4351 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4352 curbuf->b_fname, TRUE, curbuf);
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4353 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
4354
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4355 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4356 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4357 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4358 if ((flags & VGR_NOJUMP) == 0)
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4359 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4360 buf = curbuf;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4361 qf_jump(qi, 0, 0, eap->forceit);
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4362 if (buf != curbuf)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4363 /* If we jumped to another buffer redrawing will already be
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4364 * taken care of. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4365 redraw_for_dummy = FALSE;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4366
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4367 /* Jump to the directory used after loading the buffer. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4368 if (curbuf == first_match_buf && target_dir != NULL)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4369 {
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4370 exarg_T ea;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4371
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4372 ea.arg = target_dir;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4373 ea.cmdidx = CMD_lcd;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4374 ex_cd(&ea);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4375 }
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4376 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4377 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4378 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4379 EMSG2(_(e_nomatch2), s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4380
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4381 /* If we loaded a dummy buffer into the current window, the autocommands
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4382 * may have messed up things, need to redraw and recompute folds. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4383 if (redraw_for_dummy)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4384 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4385 #ifdef FEAT_FOLDING
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4386 foldUpdateAll(curwin);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4387 #else
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4388 redraw_later(NOT_VALID);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4389 #endif
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4390 }
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
4391
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4392 theend:
8603
bfa74b84c41c commit https://github.com/vim/vim/commit/5584df65a0ca2315d1eebc13c54a448bee4d0758
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
4393 vim_free(title);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4394 vim_free(dirname_now);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
4395 vim_free(dirname_start);
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
4396 vim_free(target_dir);
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
4397 vim_regfree(regmatch.regprog);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4398 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4399
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4400 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4401 * 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
4402 * 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
4403 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4404 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4405 restore_start_dir(char_u *dirname_start)
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4406 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4407 char_u *dirname_now = alloc(MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4408
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4409 if (NULL != dirname_now)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4410 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4411 mch_dirname(dirname_now, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4412 if (STRCMP(dirname_start, dirname_now) != 0)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4413 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4414 /* 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
4415 * appropriate ex command and executing it. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4416 exarg_T ea;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4417
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4418 ea.arg = dirname_start;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4419 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
4420 ex_cd(&ea);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4421 }
3974
4d1753f3e85c updated for version 7.3.742
Bram Moolenaar <bram@vim.org>
parents: 3965
diff changeset
4422 vim_free(dirname_now);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4423 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4424 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4425
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4426 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4427 * 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
4428 * 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
4429 * "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
4430 * 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
4431 * 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
4432 *
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4433 * 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
4434 * or wipe_dummy_buffer() later!
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4435 *
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4436 * Returns NULL if it fails.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4437 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4438 static buf_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4439 load_dummy_buffer(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4440 char_u *fname,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4441 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
4442 char_u *resulting_dir) /* out: new directory */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4443 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4444 buf_T *newbuf;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4445 bufref_T newbufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4446 bufref_T newbuf_to_wipe;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4447 int failed = TRUE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4448 aco_save_T aco;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4449
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4450 /* Allocate a buffer without putting it in the buffer list. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4451 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4452 if (newbuf == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4453 return NULL;
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4454 set_bufref(&newbufref, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4455
177
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4456 /* Init the options. */
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4457 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
4458
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4459 /* need to open the memfile before putting the buffer in a window */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4460 if (ml_open(newbuf) == OK)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4461 {
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4462 /* set curwin/curbuf to buf and save a few things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4463 aucmd_prepbuf(&aco, newbuf);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4464
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4465 /* Need to set the filename for autocommands. */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4466 (void)setfname(curbuf, fname, NULL, FALSE);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4467
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4468 /* Create swap file now to avoid the ATTENTION message. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4469 check_need_swap(TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4470
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4471 /* Remove the "dummy" flag, otherwise autocommands may not
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4472 * work. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4473 curbuf->b_flags &= ~BF_DUMMY;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4474
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4475 newbuf_to_wipe.br_buf = NULL;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4476 if (readfile(fname, NULL,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4477 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4478 NULL, READ_NEW | READ_DUMMY) == OK
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4479 && !got_int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4480 && !(curbuf->b_flags & BF_NEW))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4481 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4482 failed = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4483 if (curbuf != newbuf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4484 {
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4485 /* Bloody autocommands changed the buffer! Can happen when
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
4486 * 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
4487 * 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
4488 * window stuff. */
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4489 set_bufref(&newbuf_to_wipe, newbuf);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4490 newbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4491 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4492 }
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4493
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4494 /* restore curwin/curbuf and a few other things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
4495 aucmd_restbuf(&aco);
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4496 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
4497 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
4498
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4499 /* 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
4500 * skip it. */
c16e207dc465 commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Christian Brabandt <cb@256bit.org>
parents: 9475
diff changeset
4501 newbuf->b_flags |= BF_DUMMY;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4502 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4503
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4504 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4505 * When autocommands/'autochdir' option changed directory: go back.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4506 * 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
4507 * important.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4508 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4509 mch_dirname(resulting_dir, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4510 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4511
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9485
diff changeset
4512 if (!bufref_valid(&newbufref))
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4513 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4514 if (failed)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4515 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4516 wipe_dummy_buffer(newbuf, dirname_start);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4517 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4518 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4519 return newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4520 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4521
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4522 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4523 * 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
4524 * 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
4525 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4526 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4527 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4528 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4529 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4530 if (curbuf != buf) /* safety check */
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4531 {
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4532 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4533 cleanup_T cs;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4534
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4535 /* Reset the error/interrupt/exception state here so that aborting()
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4536 * returns FALSE when wiping out the buffer. Otherwise it doesn't
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4537 * work when got_int is set. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4538 enter_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4539 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4540
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4541 wipe_buffer(buf, FALSE);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4542
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4543 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4544 /* Restore the error/interrupt/exception state if not discarded by a
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4545 * new aborting error, interrupt, or uncaught exception. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4546 leave_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4547 #endif
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4548 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4549 restore_start_dir(dirname_start);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
4550 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4551 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4552
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4553 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4554 * 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
4555 * 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
4556 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4557 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4558 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4559 unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4560 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4561 if (curbuf != buf) /* safety check */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4562 {
3365
9ccdc4a69d8f updated for version 7.3.449
Bram Moolenaar <bram@vim.org>
parents: 3269
diff changeset
4563 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4564
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4565 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4566 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
4567 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4568 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4569
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4570 #if defined(FEAT_EVAL) || defined(PROTO)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4571 /*
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4572 * 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
4573 * 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
4574 */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4575 int
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4576 get_errorlist(win_T *wp, int qf_idx, list_T *list)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4577 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4578 qf_info_T *qi = &ql_info;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4579 dict_T *dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4580 char_u buf[2];
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4581 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4582 int i;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4583 int bufnum;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4584
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4585 if (wp != NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4586 {
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4587 qi = GET_LOC_LIST(wp);
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4588 if (qi == NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4589 return FAIL;
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4590 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4591
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4592 if (qf_idx == -1)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4593 qf_idx = qi->qf_curlist;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4594
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4595 if (qf_idx >= qi->qf_listcount
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4596 || qi->qf_lists[qf_idx].qf_count == 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4597 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4598
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4599 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
4600 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
4601 {
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4602 /* Handle entries with a non-existing buffer number. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4603 bufnum = qfp->qf_fnum;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4604 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4605 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4606
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4607 if ((dict = dict_alloc()) == NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4608 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4609 if (list_append_dict(list, dict) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4610 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4611
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4612 buf[0] = qfp->qf_type;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4613 buf[1] = NUL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4614 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4615 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4616 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4617 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4618 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
960
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4619 || dict_add_nr_str(dict, "pattern", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4620 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4621 || dict_add_nr_str(dict, "text", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4622 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4623 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4624 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4625 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4626
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4627 qfp = qfp->qf_next;
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4628 if (qfp == NULL)
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4629 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4630 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4631 return OK;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4632 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4633
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4634 /*
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4635 * 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
4636 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4637 enum {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4638 QF_GETLIST_NONE = 0x0,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4639 QF_GETLIST_TITLE = 0x1,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4640 QF_GETLIST_ITEMS = 0x2,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4641 QF_GETLIST_NR = 0x4,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4642 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
4643 QF_GETLIST_CONTEXT = 0x10,
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4644 QF_GETLIST_ALL = 0xFF
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4645 };
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4646
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4647 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4648 * Return quickfix/location list details (title) as a
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4649 * dictionary. 'what' contains the details to return. If 'list_idx' is -1,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4650 * then current list is used. Otherwise the specified list is used.
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4651 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4652 int
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4653 get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4654 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4655 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4656 int status = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4657 int qf_idx;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4658 dictitem_T *di;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4659 int flags = QF_GETLIST_NONE;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4660
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4661 if (wp != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4662 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4663 qi = GET_LOC_LIST(wp);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4664 if (qi == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4665 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4666 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4667
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4668 qf_idx = qi->qf_curlist; /* default is the current list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4669 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
4670 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4671 /* Use the specified quickfix/location list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4672 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
4673 {
10237
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4674 /* for zero use the current list */
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4675 if (di->di_tv.vval.v_number != 0)
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4676 {
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4677 qf_idx = di->di_tv.vval.v_number - 1;
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4678 if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4679 return FAIL;
197795e3530d commit https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1
Christian Brabandt <cb@256bit.org>
parents: 10226
diff changeset
4680 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4681 flags |= QF_GETLIST_NR;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4682 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4683 else
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4684 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4685 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4686
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4687 if (dict_find(what, (char_u *)"all", -1) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4688 flags |= QF_GETLIST_ALL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4689
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4690 if (dict_find(what, (char_u *)"title", -1) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4691 flags |= QF_GETLIST_TITLE;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4692
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4693 if (dict_find(what, (char_u *)"winid", -1) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4694 flags |= QF_GETLIST_WINID;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4695
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4696 if (dict_find(what, (char_u *)"context", -1) != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4697 flags |= QF_GETLIST_CONTEXT;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4698
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4699 if (flags & QF_GETLIST_TITLE)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4700 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4701 char_u *t;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4702 t = qi->qf_lists[qf_idx].qf_title;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4703 if (t == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4704 t = (char_u *)"";
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4705 status = dict_add_nr_str(retdict, "title", 0L, t);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4706 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4707 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
4708 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
4709 if ((status == OK) && (flags & QF_GETLIST_WINID))
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4710 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4711 win_T *win;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4712 win = qf_find_win(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4713 if (win != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4714 status = dict_add_nr_str(retdict, "winid", win->w_id, NULL);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4715 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4716
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4717 if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4718 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4719 if (qi->qf_lists[qf_idx].qf_ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4720 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4721 di = dictitem_alloc((char_u *)"context");
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4722 if (di != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4723 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4724 copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4725 dict_add(retdict, di);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4726 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4727 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4728 else
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4729 status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4730 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4731
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4732 return status;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4733 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4734
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4735 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4736 * 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
4737 * a dictionary with item information.
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4738 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4739 static int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4740 qf_add_entries(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4741 qf_info_T *qi,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4742 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4743 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4744 int action)
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4745 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4746 listitem_T *li;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4747 dict_T *d;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4748 char_u *filename, *pattern, *text, *type;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4749 int bufnum;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4750 long lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4751 int col, nr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4752 int vcol;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4753 #ifdef FEAT_WINDOWS
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4754 qfline_T *old_last = NULL;
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4755 #endif
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4756 int valid, status;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4757 int retval = OK;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4758 int did_bufnr_emsg = FALSE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4759
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4760 if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4761 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
4762 qf_new_list(qi, title);
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4763 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4764 else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4765 /* Adding to existing list, use last entry. */
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4766 old_last = qi->qf_lists[qi->qf_curlist].qf_last;
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
4767 #endif
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4768 else if (action == 'r')
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
4769 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4770 qf_free(qi, qi->qf_curlist);
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
4771 qf_store_title(qi, title);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
4772 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4773
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4774 for (li = list->lv_first; li != NULL; li = li->li_next)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4775 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4776 if (li->li_tv.v_type != VAR_DICT)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4777 continue; /* Skip non-dict items */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4778
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4779 d = li->li_tv.vval.v_dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4780 if (d == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4781 continue;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4782
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4783 filename = get_dict_string(d, (char_u *)"filename", TRUE);
9389
32e34e574716 commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
4784 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
4785 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
4786 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
4787 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
4788 nr = (int)get_dict_number(d, (char_u *)"nr");
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4789 type = get_dict_string(d, (char_u *)"type", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4790 pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4791 text = get_dict_string(d, (char_u *)"text", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4792 if (text == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4793 text = vim_strsave((char_u *)"");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4794
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4795 valid = TRUE;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4796 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4797 valid = FALSE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4798
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4799 /* Mark entries with non-existing buffer number as not valid. Give the
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4800 * error message only once. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4801 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4802 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4803 if (!did_bufnr_emsg)
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4804 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4805 did_bufnr_emsg = TRUE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4806 EMSGN(_("E92: Buffer %ld not found"), bufnum);
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4807 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4808 valid = FALSE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4809 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4810 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4811
11390
73cfcf11d983 patch 8.0.0580: cannot set the valid flag with setqflist()
Christian Brabandt <cb@256bit.org>
parents: 11378
diff changeset
4812 /* 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
4813 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
4814 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
4815
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
4816 status = qf_add_entry(qi,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4817 NULL, /* dir */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4818 filename,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4819 bufnum,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4820 text,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4821 lnum,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4822 col,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4823 vcol, /* vis_col */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4824 pattern, /* search pattern */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4825 nr,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4826 type == NULL ? NUL : *type,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4827 valid);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4828
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4829 vim_free(filename);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4830 vim_free(pattern);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4831 vim_free(text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4832 vim_free(type);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4833
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4834 if (status == FAIL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4835 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4836 retval = FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4837 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4838 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4839 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4840
2146
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4841 if (qi->qf_lists[qi->qf_curlist].qf_index == 0)
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
4842 /* no valid entry */
2146
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4843 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4844 else
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4845 qi->qf_lists[qi->qf_curlist].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
4846 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
4847 {
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
4848 qi->qf_lists[qi->qf_curlist].qf_ptr =
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
4849 qi->qf_lists[qi->qf_curlist].qf_start;
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
4850 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
4851 qi->qf_lists[qi->qf_curlist].qf_index = 1;
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
4852 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4853
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4854 #ifdef FEAT_WINDOWS
8932
25c2031e9f9f commit https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
Christian Brabandt <cb@256bit.org>
parents: 8751
diff changeset
4855 /* 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
4856 qf_update_buffer(qi, old_last);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4857 #endif
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4858
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4859 return retval;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4860 }
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4861
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4862 static int
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4863 qf_set_properties(qf_info_T *qi, dict_T *what, int action)
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4864 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4865 dictitem_T *di;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4866 int retval = FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4867 int qf_idx;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4868 int newlist = FALSE;
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4869
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4870 if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4871 newlist = TRUE;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4872
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4873 qf_idx = qi->qf_curlist; /* default is the current list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4874 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
4875 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4876 /* Use the specified quickfix/location list */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4877 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
4878 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4879 qf_idx = di->di_tv.vval.v_number - 1;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4880 if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4881 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4882 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4883 else
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4884 return FAIL;
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4885 newlist = FALSE; /* use the specified list */
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4886 }
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4887
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4888 if (newlist)
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4889 {
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4890 qf_new_list(qi, NULL);
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
4891 qf_idx = qi->qf_curlist;
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4892 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4893
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4894 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4895 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4896 if (di->di_tv.v_type == VAR_STRING)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4897 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4898 vim_free(qi->qf_lists[qf_idx].qf_title);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4899 qi->qf_lists[qf_idx].qf_title =
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4900 get_dict_string(what, (char_u *)"title", TRUE);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4901 if (qf_idx == qi->qf_curlist)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4902 qf_update_win_titlevar(qi);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4903 retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4904 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4905 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4906
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4907 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4908 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4909 typval_T *ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4910 free_tv(qi->qf_lists[qi->qf_curlist].qf_ctx);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4911 ctx = alloc_tv();
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4912 if (ctx != NULL)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4913 copy_tv(&di->di_tv, ctx);
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4914 qi->qf_lists[qi->qf_curlist].qf_ctx = ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4915 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
4916
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4917 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4918 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4919
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4920 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4921 * 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
4922 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4923 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
4924 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
4925 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4926 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
4927
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4928 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
4929 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
4930 return wp;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4931
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4932 return NULL;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4933 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4934
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4935 /*
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4936 * 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
4937 * 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
4938 */
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4939 static void
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4940 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
4941 {
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4942 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
4943 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
4944 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
4945
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4946 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
4947 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4948 /* 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
4949 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
4950 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
4951 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
4952 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4953
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4954 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
4955 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4956 /* 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
4957 * 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
4958 */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4959 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
4960 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
4961 wp = llwin;
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4962 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4963
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4964 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
4965 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
4966 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4967 /* quickfix list */
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4968 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
4969 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
4970 }
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4971 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
4972 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4973 /* 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
4974 * location list */
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4975 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
4976
11398
30af33f4d353 patch 8.0.0584: memory leak when executing quickfix tests
Christian Brabandt <cb@256bit.org>
parents: 11390
diff changeset
4977 /* 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
4978 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
4979
11301
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4980 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
4981 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
4982 {
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4983 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
4984 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
4985 }
cc8ece2aa389 patch 8.0.0536: quickfix window not updated when freeing quickfix stack
Christian Brabandt <cb@256bit.org>
parents: 11263
diff changeset
4986 }
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4987 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
4988
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4989 /*
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4990 * 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
4991 * 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
4992 * "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
4993 */
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4994 int
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4995 set_errorlist(
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4996 win_T *wp,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4997 list_T *list,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4998 int action,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
4999 char_u *title,
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5000 dict_T *what)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5001 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5002 qf_info_T *qi = &ql_info;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5003 int retval = OK;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5004
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5005 if (wp != NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5006 {
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5007 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
5008 if (qi == NULL)
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5009 return FAIL;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5010 }
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5011
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5012 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
5013 {
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5014 /* 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
5015 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
5016 }
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5017 else if (what != NULL)
9982
e24aa20d815c commit https://github.com/vim/vim/commit/2b529bb6260b52246e92429375d995b9b5ce76b6
Christian Brabandt <cb@256bit.org>
parents: 9931
diff changeset
5018 retval = qf_set_properties(qi, what, action);
9850
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5019 else
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5020 retval = qf_add_entries(qi, list, title, action);
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5021
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5022 return retval;
67781bb0a61a commit https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
Christian Brabandt <cb@256bit.org>
parents: 9738
diff changeset
5023 }
11412
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5024
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5025 static int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5026 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
5027 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5028 int i;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5029 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5030 typval_T *ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5031
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5032 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
5033 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5034 ctx = qi->qf_lists[i].qf_ctx;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5035 if (ctx != NULL && ctx->v_type != VAR_NUMBER &&
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5036 ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5037 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
5038 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5039
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5040 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5041 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5042
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5043 /*
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5044 * Mark the context of the quickfix list and the location lists (if present) as
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5045 * "in use". So that garabage collection doesn't free the context.
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5046 */
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5047 int
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5048 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
5049 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5050 int abort = FALSE;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5051 tabpage_T *tp;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5052 win_T *win;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5053
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5054 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
5055 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5056 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5057
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5058 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
5059 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5060 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
5061 {
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5062 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
5063 if (abort)
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5064 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5065 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5066 }
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5067
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5068 return abort;
84baca75b7f2 patch 8.0.0590: cannot add a context to locations
Christian Brabandt <cb@256bit.org>
parents: 11398
diff changeset
5069 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5070 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5071
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5072 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5073 * ":[range]cbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
5074 * ":[range]caddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5075 * ":[range]cgetbuffer [bufnr]" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5076 * ":[range]lbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
5077 * ":[range]laddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5078 * ":[range]lgetbuffer [bufnr]" command.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5079 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5080 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5081 ex_cbuffer(exarg_T *eap)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5082 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5083 buf_T *buf = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5084 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
5085 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5086 char_u *au_name = NULL;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5087 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5088
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5089 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5090 || eap->cmdidx == CMD_laddbuffer)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5091 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5092 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5093 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5094 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5095 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5096
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5097 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5098 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5099 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5100 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
5101 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
5102 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
5103 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
5104 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
5105 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
5106 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5107 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5108 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
5109 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5110 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5111 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5112 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5113 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5114 # endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5115 }
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5116 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5117
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5118 if (*eap->arg == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5119 buf = curbuf;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5120 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5121 buf = buflist_findnr(atoi((char *)eap->arg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5122 if (buf == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5123 EMSG(_(e_invarg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5124 else if (buf->b_ml.ml_mfp == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5125 EMSG(_("E681: Buffer is not loaded"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5126 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5127 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5128 if (eap->addr_count == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5129 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5130 eap->line1 = 1;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5131 eap->line2 = buf->b_ml.ml_line_count;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5132 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5133 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5134 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5135 EMSG(_(e_invrange));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5136 else
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5137 {
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5138 char_u *qf_title = *eap->cmdlinep;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5139
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5140 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
5141 {
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5142 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
5143 (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
5144 qf_title = IObuff;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5145 }
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
5146
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5147 if (qf_init_ext(qi, NULL, buf, NULL, p_efm,
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5148 (eap->cmdidx != CMD_caddbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5149 && 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
5150 eap->line1, eap->line2,
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
5151 qf_title, NULL) > 0)
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5152 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5153 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5154 if (au_name != NULL)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5155 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5156 curbuf->b_fname, TRUE, curbuf);
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5157 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5158 if (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5159 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5160 }
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
5161 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5162 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5163 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5164
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
5165 #if defined(FEAT_EVAL) || defined(PROTO)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
5166 /*
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5167 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command.
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5168 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command.
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5169 */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5170 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5171 ex_cexpr(exarg_T *eap)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5172 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5173 typval_T *tv;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5174 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
5175 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5176 char_u *au_name = NULL;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5177 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5178
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5179 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5180 || eap->cmdidx == CMD_laddexpr)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5181 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5182 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5183 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5184 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5185 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5186
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5187 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5188 switch (eap->cmdidx)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5189 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5190 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
5191 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
5192 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
5193 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
5194 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
5195 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
5196 default: break;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5197 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5198 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
5199 curbuf->b_fname, TRUE, curbuf))
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5200 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5201 # ifdef FEAT_EVAL
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5202 if (aborting())
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5203 return;
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5204 # endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5205 }
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5206 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5207
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5208 /* 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
5209 * use it to fill the errorlist. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5210 tv = eval_expr(eap->arg, NULL);
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5211 if (tv != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5212 {
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5213 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5214 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5215 {
7701
075810b0cb6c commit https://github.com/vim/vim/commit/d6357e8f93c50f984ffd69c3a0d247d8603f86c3
Christian Brabandt <cb@256bit.org>
parents: 7662
diff changeset
5216 if (qf_init_ext(qi, NULL, NULL, tv, p_efm,
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5217 (eap->cmdidx != CMD_caddexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
5218 && eap->cmdidx != CMD_laddexpr),
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
5219 (linenr_T)0, (linenr_T)0, *eap->cmdlinep,
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10379
diff changeset
5220 NULL) > 0)
10056
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5221 {
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5222 #ifdef FEAT_AUTOCMD
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5223 if (au_name != NULL)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5224 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5225 curbuf->b_fname, TRUE, curbuf);
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5226 #endif
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5227 if (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr)
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5228 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
21f685af3fc1 commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5229 }
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5230 }
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5231 else
626
732c7ae5743e updated for version 7.0180
vimboss
parents: 625
diff changeset
5232 EMSG(_("E777: String or List expected"));
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5233 free_tv(tv);
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
5234 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5235 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
5236 #endif
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5237
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
5238 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5239 * ":helpgrep {pattern}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5242 ex_helpgrep(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 char_u *save_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5246 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5247 int fcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5248 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5249 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5250 int fi;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 long lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5252 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5253 char_u *lang;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5254 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5255 qf_info_T *qi = &ql_info;
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5256 qf_info_T *save_qi;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5257 int new_qi = FALSE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5258 win_T *wp;
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5259 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5260 char_u *au_name = NULL;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5261 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5262
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5263 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5264 /* Check for a specified language */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5265 lang = check_help_lang(eap->arg);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5266 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5267
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5268 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5269 switch (eap->cmdidx)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5270 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5271 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
5272 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
5273 default: break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5274 }
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5275 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
5276 curbuf->b_fname, TRUE, curbuf))
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5277 {
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5278 # ifdef FEAT_EVAL
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5279 if (aborting())
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5280 return;
10346
d52d97bf675e commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents: 10281
diff changeset
5281 # endif
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5282 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5283 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5284
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5285 /* 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
5286 save_cpo = p_cpo;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5287 p_cpo = empty_option;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5288
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5289 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5290 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5291 /* Find an existing help window */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5292 FOR_ALL_WINDOWS(wp)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5293 if (wp->w_buffer != NULL && wp->w_buffer->b_help)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5294 break;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5295
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5296 if (wp == NULL) /* Help window not found */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5297 qi = NULL;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5298 else
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5299 qi = wp->w_llist;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5300
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5301 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5302 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5303 /* Allocate a new location list for help text matches */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5304 if ((qi = ll_new_list()) == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5305 return;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5306 new_qi = TRUE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5307 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5308 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5309
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5310 /* Autocommands may change the list. Save it for later comparison */
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5311 save_qi = qi;
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5312
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314 regmatch.rm_ic = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315 if (regmatch.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5317 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5318 vimconv_T vc;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5319
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5320 /* Help files are in utf-8 or latin1, convert lines when 'encoding'
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5321 * differs. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5322 vc.vc_type = CONV_NONE;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5323 if (!enc_utf8)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5324 convert_setup(&vc, (char_u *)"utf-8", p_enc);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5325 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5326
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 /* create a new quickfix list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
5328 qf_new_list(qi, *eap->cmdlinep);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 /* Go through all directories in 'runtimepath' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 p = p_rtp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 while (*p != NUL && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 copy_option_part(&p, NameBuff, MAXPATHL, ",");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5336 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337 add_pathsep(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 if (gen_expand_wildcards(1, &NameBuff, &fcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 &fnames, EW_FILE|EW_SILENT) == OK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341 && fcount > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5342 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5343 for (fi = 0; fi < fcount && !got_int; ++fi)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5344 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5345 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5346 /* Skip files for a different language. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5347 if (lang != NULL
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5348 && STRNICMP(lang, fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5349 + STRLEN(fnames[fi]) - 3, 2) != 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5350 && !(STRNICMP(lang, "en", 2) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5351 && STRNICMP("txt", fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5352 + STRLEN(fnames[fi]) - 3, 3) == 0))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5353 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5354 #endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 514
diff changeset
5355 fd = mch_fopen((char *)fnames[fi], "r");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5359 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5360 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5361 char_u *line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5362 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5363 /* Convert a line if 'encoding' is not utf-8 and
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5364 * the line contains a non-ASCII character. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5365 if (vc.vc_type != CONV_NONE
11263
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5366 && has_non_ascii(IObuff))
ae5f9f26f81c patch 8.0.0517: there is no way to remove quickfix lists
Christian Brabandt <cb@256bit.org>
parents: 11195
diff changeset
5367 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5368 line = string_convert(&vc, IObuff, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5369 if (line == NULL)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5370 line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5371 }
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5372 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5373
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5374 if (vim_regexec(&regmatch, line, (colnr_T)0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5375 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5376 int l = (int)STRLEN(line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5378 /* remove trailing CR, LF, spaces, etc. */
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5379 while (l > 0 && line[l - 1] <= ' ')
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5380 line[--l] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381
9195
543f068f3706 commit https://github.com/vim/vim/commit/83e6d7ac6a1c2a0cb5ee6c8420a5dc792f1d5ffa
Christian Brabandt <cb@256bit.org>
parents: 9175
diff changeset
5382 if (qf_add_entry(qi,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5383 NULL, /* dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5384 fnames[fi],
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
5385 0,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5386 line,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387 lnum,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5388 (int)(regmatch.startp[0] - line)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
5389 + 1, /* col */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
5390 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
5391 NULL, /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5392 0, /* nr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393 1, /* type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394 TRUE /* valid */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 ) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397 got_int = TRUE;
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5398 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5399 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5400 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5401 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5402 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5404 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5405 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5406 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5407 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5408 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5409 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5410 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5412 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5413 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 FreeWild(fcount, fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5418
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
5419 vim_regfree(regmatch.regprog);
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5420 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5421 if (vc.vc_type != CONV_NONE)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5422 convert_setup(&vc, NULL, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
5423 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5425 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5426 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5427 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5428 qi->qf_lists[qi->qf_curlist].qf_index = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430
1672
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5431 if (p_cpo == empty_option)
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5432 p_cpo = save_cpo;
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5433 else
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5434 /* Darn, some plugin changed the value. */
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
5435 free_string_option(save_cpo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 #ifdef FEAT_WINDOWS
9175
d415c079f84e commit https://github.com/vim/vim/commit/864293abb72d62604d8d6b458addfb43c14230c3
Christian Brabandt <cb@256bit.org>
parents: 9114
diff changeset
5438 qf_update_buffer(qi, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5441 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5442 if (au_name != NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5443 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5444 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5445 curbuf->b_fname, TRUE, curbuf);
11195
13c660bd07b2 patch 8.0.0484: :lhelpgrep does not fail after a successful one
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
5446 if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL)
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5447 /* autocommands made "qi" invalid */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5448 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5449 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5450 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
5451
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5452 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
5453 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5454 qf_jump(qi, 0, 0, FALSE);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5455 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5456 EMSG2(_(e_nomatch2), eap->arg);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5457
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5458 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5459 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5460 /* 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
5461 * correct location list, then free the new location list. */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5462 if (!curwin->w_buffer->b_help || curwin->w_llist == qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5463 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5464 if (new_qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5465 ll_free_all(&qi);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5466 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5467 else if (curwin->w_llist == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5468 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
5469 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5472 #endif /* FEAT_QUICKFIX */