summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0434
blob: 4fd7d739439c342990da2efc91b7da145c396ad2 (plain)
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0434
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.0434
Problem:    copy_loclist() is too long.
Solution:   Split in multiple functions. (Yegappan Lakshmanan)
Files:	    src/proto/quickfix.pro, src/quickfix.c, src/window.c


*** ../vim-8.1.0433/src/proto/quickfix.pro	2018-07-25 22:36:48.987518583 +0200
--- src/proto/quickfix.pro	2018-09-25 22:06:03.183095511 +0200
***************
*** 1,7 ****
  /* quickfix.c */
  int qf_init(win_T *wp, char_u *efile, char_u *errorformat, int newlist, char_u *qf_title, char_u *enc);
  void qf_free_all(win_T *wp);
! void copy_loclist(win_T *from, win_T *to);
  void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit);
  void qf_list(exarg_T *eap);
  void qf_age(exarg_T *eap);
--- 1,7 ----
  /* quickfix.c */
  int qf_init(win_T *wp, char_u *efile, char_u *errorformat, int newlist, char_u *qf_title, char_u *enc);
  void qf_free_all(win_T *wp);
! void copy_loclist_stack(win_T *from, win_T *to);
  void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit);
  void qf_list(exarg_T *eap);
  void qf_age(exarg_T *eap);
*** ../vim-8.1.0433/src/quickfix.c	2018-09-24 21:50:08.932086794 +0200
--- src/quickfix.c	2018-09-25 22:06:03.187095471 +0200
***************
*** 2044,2165 ****
  }
  
  /*
!  * Copy the location list from window "from" to window "to".
   */
      void
! copy_loclist(win_T *from, win_T *to)
  {
      qf_info_T	*qi;
      int		idx;
-     int		i;
  
!     /*
!      * When copying from a location list window, copy the referenced
!      * location list. For other windows, copy the location list for
!      * that window.
!      */
      if (IS_LL_WINDOW(from))
  	qi = from->w_llist_ref;
      else
  	qi = from->w_llist;
  
!     if (qi == NULL)		    /* no location list to copy */
  	return;
  
!     /* allocate a new location list */
      if ((to->w_llist = ll_new_list()) == NULL)
  	return;
  
      to->w_llist->qf_listcount = qi->qf_listcount;
  
!     /* Copy the location lists one at a time */
      for (idx = 0; idx < qi->qf_listcount; ++idx)
      {
- 	qf_list_T   *from_qfl;
- 	qf_list_T   *to_qfl;
- 
  	to->w_llist->qf_curlist = idx;
  
! 	from_qfl = &qi->qf_lists[idx];
! 	to_qfl = &to->w_llist->qf_lists[idx];
! 
! 	/* Some of the fields are populated by qf_add_entry() */
! 	to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
! 	to_qfl->qf_count = 0;
! 	to_qfl->qf_index = 0;
! 	to_qfl->qf_start = NULL;
! 	to_qfl->qf_last = NULL;
! 	to_qfl->qf_ptr = NULL;
! 	if (from_qfl->qf_title != NULL)
! 	    to_qfl->qf_title = vim_strsave(from_qfl->qf_title);
! 	else
! 	    to_qfl->qf_title = NULL;
! 	if (from_qfl->qf_ctx != NULL)
! 	{
! 	    to_qfl->qf_ctx = alloc_tv();
! 	    if (to_qfl->qf_ctx != NULL)
! 		copy_tv(from_qfl->qf_ctx, to_qfl->qf_ctx);
! 	}
! 	else
! 	    to_qfl->qf_ctx = NULL;
! 
! 	if (from_qfl->qf_count)
! 	{
! 	    qfline_T    *from_qfp;
! 	    qfline_T    *prevp;
! 
! 	    /* copy all the location entries in this list */
! 	    for (i = 0, from_qfp = from_qfl->qf_start;
! 		    i < from_qfl->qf_count && from_qfp != NULL;
! 		    ++i, from_qfp = from_qfp->qf_next)
! 	    {
! 		if (qf_add_entry(to->w_llist,
! 				 to->w_llist->qf_curlist,
! 				 NULL,
! 				 NULL,
! 				 from_qfp->qf_module,
! 				 0,
! 				 from_qfp->qf_text,
! 				 from_qfp->qf_lnum,
! 				 from_qfp->qf_col,
! 				 from_qfp->qf_viscol,
! 				 from_qfp->qf_pattern,
! 				 from_qfp->qf_nr,
! 				 0,
! 				 from_qfp->qf_valid) == FAIL)
! 		{
! 		    qf_free_all(to);
! 		    return;
! 		}
! 		/*
! 		 * qf_add_entry() will not set the qf_num field, as the
! 		 * directory and file names are not supplied. So the qf_fnum
! 		 * field is copied here.
! 		 */
! 		prevp = to->w_llist->qf_lists[to->w_llist->qf_curlist].qf_last;
! 		prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
! 		prevp->qf_type = from_qfp->qf_type; /* error type */
! 		if (from_qfl->qf_ptr == from_qfp)
! 		    to_qfl->qf_ptr = prevp;	    /* current location */
! 	    }
! 	}
! 
! 	to_qfl->qf_index = from_qfl->qf_index;	/* current index in the list */
! 
! 	/* Assign a new ID for the location list */
! 	to_qfl->qf_id = ++last_qf_id;
! 	to_qfl->qf_changedtick = 0L;
! 
! 	/* When no valid entries are present in the list, qf_ptr points to
! 	 * the first item in the list */
! 	if (to_qfl->qf_nonevalid)
  	{
! 	    to_qfl->qf_ptr = to_qfl->qf_start;
! 	    to_qfl->qf_index = 1;
  	}
      }
  
!     to->w_llist->qf_curlist = qi->qf_curlist;	/* current list */
  }
  
  /*
--- 2044,2179 ----
  }
  
  /*
!  * Copy location list entries from 'from_qfl' to 'to_qfl'.
!  */
!     static int
! copy_loclist_entries(qf_list_T *from_qfl, qf_list_T *to_qfl, qf_info_T *to_qi)
! {
!     int		i;
!     qfline_T    *from_qfp;
!     qfline_T    *prevp;
! 
!     // copy all the location entries in this list
!     for (i = 0, from_qfp = from_qfl->qf_start;
! 	    i < from_qfl->qf_count && from_qfp != NULL;
! 	    ++i, from_qfp = from_qfp->qf_next)
!     {
! 	if (qf_add_entry(to_qi,
! 		    to_qi->qf_curlist,
! 		    NULL,
! 		    NULL,
! 		    from_qfp->qf_module,
! 		    0,
! 		    from_qfp->qf_text,
! 		    from_qfp->qf_lnum,
! 		    from_qfp->qf_col,
! 		    from_qfp->qf_viscol,
! 		    from_qfp->qf_pattern,
! 		    from_qfp->qf_nr,
! 		    0,
! 		    from_qfp->qf_valid) == FAIL)
! 	    return FAIL;
! 
! 	// qf_add_entry() will not set the qf_num field, as the
! 	// directory and file names are not supplied. So the qf_fnum
! 	// field is copied here.
! 	prevp = to_qfl->qf_last;
! 	prevp->qf_fnum = from_qfp->qf_fnum;	// file number
! 	prevp->qf_type = from_qfp->qf_type;	// error type
! 	if (from_qfl->qf_ptr == from_qfp)
! 	    to_qfl->qf_ptr = prevp;		// current location
!     }
! 
!     return OK;
! }
! 
! /*
!  * Copy the specified location list 'from_qfl' to 'to_qfl'.
!  */
!     static int
! copy_loclist(qf_list_T *from_qfl, qf_list_T *to_qfl, qf_info_T *to_qi)
! {
!     // Some of the fields are populated by qf_add_entry()
!     to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
!     to_qfl->qf_count = 0;
!     to_qfl->qf_index = 0;
!     to_qfl->qf_start = NULL;
!     to_qfl->qf_last = NULL;
!     to_qfl->qf_ptr = NULL;
!     if (from_qfl->qf_title != NULL)
! 	to_qfl->qf_title = vim_strsave(from_qfl->qf_title);
!     else
! 	to_qfl->qf_title = NULL;
!     if (from_qfl->qf_ctx != NULL)
!     {
! 	to_qfl->qf_ctx = alloc_tv();
! 	if (to_qfl->qf_ctx != NULL)
! 	    copy_tv(from_qfl->qf_ctx, to_qfl->qf_ctx);
!     }
!     else
! 	to_qfl->qf_ctx = NULL;
! 
!     if (from_qfl->qf_count)
! 	if (copy_loclist_entries(from_qfl, to_qfl, to_qi) == FAIL)
! 	    return FAIL;
! 
!     to_qfl->qf_index = from_qfl->qf_index;	// current index in the list
! 
!     // Assign a new ID for the location list
!     to_qfl->qf_id = ++last_qf_id;
!     to_qfl->qf_changedtick = 0L;
! 
!     // When no valid entries are present in the list, qf_ptr points to
!     // the first item in the list
!     if (to_qfl->qf_nonevalid)
!     {
! 	to_qfl->qf_ptr = to_qfl->qf_start;
! 	to_qfl->qf_index = 1;
!     }
! 
!     return OK;
! }
! 
! /*
!  * Copy the location list stack 'from' window to 'to' window.
   */
      void
! copy_loclist_stack(win_T *from, win_T *to)
  {
      qf_info_T	*qi;
      int		idx;
  
!     // When copying from a location list window, copy the referenced
!     // location list. For other windows, copy the location list for
!     // that window.
      if (IS_LL_WINDOW(from))
  	qi = from->w_llist_ref;
      else
  	qi = from->w_llist;
  
!     if (qi == NULL)		    // no location list to copy
  	return;
  
!     // allocate a new location list
      if ((to->w_llist = ll_new_list()) == NULL)
  	return;
  
      to->w_llist->qf_listcount = qi->qf_listcount;
  
!     // Copy the location lists one at a time
      for (idx = 0; idx < qi->qf_listcount; ++idx)
      {
  	to->w_llist->qf_curlist = idx;
  
! 	if (copy_loclist(&qi->qf_lists[idx],
! 			&to->w_llist->qf_lists[idx], to->w_llist) == FAIL)
  	{
! 	    qf_free_all(to);
! 	    return;
  	}
      }
  
!     to->w_llist->qf_curlist = qi->qf_curlist;	// current list
  }
  
  /*
*** ../vim-8.1.0433/src/window.c	2018-09-13 15:33:39.609712174 +0200
--- src/window.c	2018-09-25 22:06:03.187095471 +0200
***************
*** 1308,1314 ****
  	newp->w_llist_ref = NULL;
      }
      else
! 	copy_loclist(oldp, newp);
  #endif
      newp->w_localdir = (oldp->w_localdir == NULL)
  				    ? NULL : vim_strsave(oldp->w_localdir);
--- 1308,1314 ----
  	newp->w_llist_ref = NULL;
      }
      else
! 	copy_loclist_stack(oldp, newp);
  #endif
      newp->w_localdir = (oldp->w_localdir == NULL)
  				    ? NULL : vim_strsave(oldp->w_localdir);
*** ../vim-8.1.0433/src/version.c	2018-09-25 20:48:53.882887698 +0200
--- src/version.c	2018-09-25 22:07:03.802483924 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     434,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
100. The most exciting sporting events you noticed during summer 1996
    was Netscape vs. Microsoft.

 /// 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    ///