1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0455
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0455
Problem: Checking for empty quickfix stack is not consistent.
Solution: Use qf_stack_empty(). (Yegappan Lakshmanan)
Files: src/quickfix.c
*** ../vim-8.1.0454/src/quickfix.c 2018-09-28 23:09:50.558463030 +0200
--- src/quickfix.c 2018-10-07 14:34:59.832140408 +0200
***************
*** 1499,1504 ****
--- 1499,1513 ----
}
/*
+ * Returns TRUE if the specified quickfix/location stack is empty
+ */
+ static int
+ qf_stack_empty(qf_info_T *qi)
+ {
+ return qi == NULL || qi->qf_listcount <= 0;
+ }
+
+ /*
* Returns TRUE if the specified quickfix/location list is empty.
*/
static int
***************
*** 3220,3227 ****
if (qi == NULL)
qi = &ql_info;
! if (qi->qf_curlist >= qi->qf_listcount
! || qf_list_empty(qi, qi->qf_curlist))
{
EMSG(_(e_quickfix));
return;
--- 3229,3235 ----
if (qi == NULL)
qi = &ql_info;
! if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist))
{
EMSG(_(e_quickfix));
return;
***************
*** 3412,3419 ****
}
}
! if (qi->qf_curlist >= qi->qf_listcount
! || qf_list_empty(qi, qi->qf_curlist))
{
EMSG(_(e_quickfix));
return;
--- 3420,3426 ----
}
}
! if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist))
{
EMSG(_(e_quickfix));
return;
***************
*** 3601,3608 ****
if (is_loclist_cmd(eap->cmdidx))
qi = GET_LOC_LIST(curwin);
! if (qi == NULL || (qi->qf_listcount == 0
! && qf_list_empty(qi, qi->qf_curlist)))
MSG(_("No entries"));
else
for (i = 0; i < qi->qf_listcount; ++i)
--- 3608,3614 ----
if (is_loclist_cmd(eap->cmdidx))
qi = GET_LOC_LIST(curwin);
! if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist))
MSG(_("No entries"));
else
for (i = 0; i < qi->qf_listcount; ++i)
***************
*** 3830,3838 ****
* close the window. If a quickfix window is not open, then open
* it if we have errors; otherwise, leave it closed.
*/
! if (qi->qf_lists[qi->qf_curlist].qf_nonevalid
! || qf_list_empty(qi, qi->qf_curlist)
! || qi->qf_curlist >= qi->qf_listcount)
{
if (win != NULL)
ex_cclose(eap);
--- 3836,3844 ----
* close the window. If a quickfix window is not open, then open
* it if we have errors; otherwise, leave it closed.
*/
! if (qf_stack_empty(qi)
! || qi->qf_lists[qi->qf_curlist].qf_nonevalid
! || qf_list_empty(qi, qi->qf_curlist))
{
if (win != NULL)
ex_cclose(eap);
***************
*** 4342,4348 ****
}
/* Check if there is anything to display */
! if (qi->qf_curlist < qi->qf_listcount)
{
char_u dirname[MAXPATHL];
--- 4348,4354 ----
}
/* Check if there is anything to display */
! if (!qf_stack_empty(qi))
{
char_u dirname[MAXPATHL];
***************
*** 5333,5339 ****
if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd
&& eap->cmdidx != CMD_vimgrepadd
&& eap->cmdidx != CMD_lvimgrepadd)
! || qi->qf_curlist == qi->qf_listcount)
/* make place for a new list */
qf_new_list(qi, title != NULL ? title : qf_cmdtitle(*eap->cmdlinep));
--- 5339,5345 ----
if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd
&& eap->cmdidx != CMD_vimgrepadd
&& eap->cmdidx != CMD_lvimgrepadd)
! || qf_stack_empty(qi))
/* make place for a new list */
qf_new_list(qi, title != NULL ? title : qf_cmdtitle(*eap->cmdlinep));
***************
*** 6107,6117 ****
flags = qf_getprop_keys2flags(what, (wp != NULL));
! if (qi != NULL && qi->qf_listcount != 0)
qf_idx = qf_getprop_qfidx(qi, what);
/* List is not present or is empty */
! if (qi == NULL || qi->qf_listcount == 0 || qf_idx == INVALID_QFIDX)
return qf_getprop_defaults(qi, flags, retdict);
qfl = &qi->qf_lists[qf_idx];
--- 6113,6123 ----
flags = qf_getprop_keys2flags(what, (wp != NULL));
! if (!qf_stack_empty(qi))
qf_idx = qf_getprop_qfidx(qi, what);
/* List is not present or is empty */
! if (qf_stack_empty(qi) || qf_idx == INVALID_QFIDX)
return qf_getprop_defaults(qi, flags, retdict);
qfl = &qi->qf_lists[qf_idx];
***************
*** 6313,6319 ****
* stack.
*/
*newlist = TRUE;
! qf_idx = qi->qf_listcount > 0 ? qi->qf_listcount - 1 : 0;
}
else if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
return INVALID_QFIDX;
--- 6319,6325 ----
* stack.
*/
*newlist = TRUE;
! qf_idx = qf_stack_empty(qi) ? 0 : qi->qf_listcount - 1;
}
else if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
return INVALID_QFIDX;
***************
*** 6324,6330 ****
&& di->di_tv.vval.v_string != NULL
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
{
! if (qi->qf_listcount > 0)
qf_idx = qi->qf_listcount - 1;
else if (*newlist)
qf_idx = 0;
--- 6330,6336 ----
&& di->di_tv.vval.v_string != NULL
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
{
! if (!qf_stack_empty(qi))
qf_idx = qi->qf_listcount - 1;
else if (*newlist)
qf_idx = 0;
***************
*** 6452,6458 ****
int qf_idx;
int newlist = FALSE;
! if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
newlist = TRUE;
qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist);
--- 6458,6464 ----
int qf_idx;
int newlist = FALSE;
! if (action == ' ' || qf_stack_empty(qi))
newlist = TRUE;
qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist);
*** ../vim-8.1.0454/src/version.c 2018-10-06 15:43:13.062876189 +0200
--- src/version.c 2018-10-07 14:36:35.659323843 +0200
***************
*** 794,795 ****
--- 794,797 ----
{ /* Add new patch number below this line */
+ /**/
+ 455,
/**/
--
hundred-and-one symptoms of being an internet addict:
165. You have a web page burned into your glasses
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|