summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.3.465
blob: c4a857ac92dc551ae94b05054c29e0a68246fe22 (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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
To: vim_dev@googlegroups.com
Subject: Patch 7.3.465
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.465
Problem:    Cannot get file name with newline from glob().
Solution:   Add argument to glob() and expand() to indicate they must return a
	    list. (Christian Brabandt)
Files:	    runtime/doc/eval.txt, src/eval.c, src/ex_getln.c, src/vim.h


*** ../vim-7.3.464/runtime/doc/eval.txt	2011-12-14 15:32:44.000000000 +0100
--- runtime/doc/eval.txt	2012-03-07 18:49:26.000000000 +0100
***************
*** 1738,1744 ****
  extend( {expr1}, {expr2} [, {expr3}])
  				List/Dict insert items of {expr2} into {expr1}
  exp( {expr})			Float	exponential of {expr}
! expand( {expr} [, {flag}])	String	expand special keywords in {expr}
  feedkeys( {string} [, {mode}])	Number	add key sequence to typeahead buffer
  filereadable( {file})		Number	TRUE if {file} is a readable file
  filewritable( {file})		Number	TRUE if {file} is a writable file
--- 1746,1753 ----
  extend( {expr1}, {expr2} [, {expr3}])
  				List/Dict insert items of {expr2} into {expr1}
  exp( {expr})			Float	exponential of {expr}
! expand( {expr} [, {nosuf} [, {list}]])
! 				any	expand special keywords in {expr}
  feedkeys( {string} [, {mode}])	Number	add key sequence to typeahead buffer
  filereadable( {file})		Number	TRUE if {file} is a readable file
  filewritable( {file})		Number	TRUE if {file} is a writable file
***************
*** 1792,1798 ****
  getwinposx()			Number	X coord in pixels of GUI Vim window
  getwinposy()			Number	Y coord in pixels of GUI Vim window
  getwinvar( {nr}, {varname})	any	variable {varname} in window {nr}
! glob( {expr} [, {flag}])	String	expand file wildcards in {expr}
  globpath( {path}, {expr} [, {flag}])
  				String	do glob({expr}) for all dirs in {path}
  has( {feature})			Number	TRUE if feature {feature} supported
--- 1801,1808 ----
  getwinposx()			Number	X coord in pixels of GUI Vim window
  getwinposy()			Number	Y coord in pixels of GUI Vim window
  getwinvar( {nr}, {varname})	any	variable {varname} in window {nr}
! glob( {expr} [, {nosuf} [, {list}]])
! 				any	expand file wildcards in {expr}
  globpath( {path}, {expr} [, {flag}])
  				String	do glob({expr}) for all dirs in {path}
  has( {feature})			Number	TRUE if feature {feature} supported
***************
*** 2731,2743 ****
  		{only available when compiled with the |+float| feature}
  
  
! expand({expr} [, {flag}])				*expand()*
  		Expand wildcards and the following special keywords in {expr}.
! 		The result is a String.
  
! 		When there are several matches, they are separated by <NL>
! 		characters.  [Note: in version 5.0 a space was used, which
! 		caused problems when a file name contains a space]
  
  		If the expansion fails, the result is an empty string.	A name
  		for a non-existing file is not included.
--- 2744,2758 ----
  		{only available when compiled with the |+float| feature}
  
  
! expand({expr} [, {nosuf} [, {list}]])				*expand()*
  		Expand wildcards and the following special keywords in {expr}.
! 		'wildignorecase' applies.
  
! 		If {list} is given and it is non-zero, a List will be returned.
! 		Otherwise the result is a String and when there are several
! 		matches, they are separated by <NL> characters.  [Note: in
! 		version 5.0 a space was used, which caused problems when a
! 		file name contains a space]
  
  		If the expansion fails, the result is an empty string.	A name
  		for a non-existing file is not included.
***************
*** 2754,2759 ****
--- 2769,2775 ----
  			<abuf>		autocmd buffer number (as a String!)
  			<amatch>	autocmd matched name
  			<sfile>		sourced script file name
+ 			<slnum>		sourced script file line number
  			<cword>		word under the cursor
  			<cWORD>		WORD under the cursor
  			<client>	the {clientid} of the last received
***************
*** 2790,2799 ****
  		When {expr} does not start with '%', '#' or '<', it is
  		expanded like a file name is expanded on the command line.
  		'suffixes' and 'wildignore' are used, unless the optional
! 		{flag} argument is given and it is non-zero.  Names for
! 		non-existing files are included.  The "**" item can be used to
! 		search in a directory tree.  For example, to find all "README"
! 		files in the current directory and below: >
  			:echo expand("**/README")
  <
  		Expand() can also be used to expand variables and environment
--- 2806,2815 ----
  		When {expr} does not start with '%', '#' or '<', it is
  		expanded like a file name is expanded on the command line.
  		'suffixes' and 'wildignore' are used, unless the optional
! 		{nosuf} argument is given and it is non-zero.
! 		Names for non-existing files are included.  The "**" item can
! 		be used to search in a directory tree.  For example, to find
! 		all "README" files in the current directory and below: >
  			:echo expand("**/README")
  <
  		Expand() can also be used to expand variables and environment
***************
*** 3437,3453 ****
  			:let list_is_on = getwinvar(2, '&list')
  			:echo "myvar = " . getwinvar(1, 'myvar')
  <
! glob({expr} [, {flag}])					*glob()*
  		Expand the file wildcards in {expr}.  See |wildcards| for the
  		use of special characters.
! 		The result is a String.
! 		When there are several matches, they are separated by <NL>
! 		characters.
! 		Unless the optional {flag} argument is given and is non-zero,
  		the 'suffixes' and 'wildignore' options apply: Names matching
  		one of the patterns in 'wildignore' will be skipped and
  		'suffixes' affect the ordering of matches.
! 		If the expansion fails, the result is an empty string.
  		A name for a non-existing file is not included.
  
  		For most systems backticks can be used to get files names from
--- 3456,3478 ----
  			:let list_is_on = getwinvar(2, '&list')
  			:echo "myvar = " . getwinvar(1, 'myvar')
  <
! glob({expr} [, {nosuf} [, {list}]])				*glob()*
  		Expand the file wildcards in {expr}.  See |wildcards| for the
  		use of special characters.
! 
! 		Unless the optional {nosuf} argument is given and is non-zero,
  		the 'suffixes' and 'wildignore' options apply: Names matching
  		one of the patterns in 'wildignore' will be skipped and
  		'suffixes' affect the ordering of matches.
! 		'wildignorecase' always applies.
! 
! 		When {list} is present and it is non-zero the result is a List
! 		with all matching files. The advantage of using a List is,
! 		you also get filenames containing newlines correctly.
! 		Otherwise the result is a String and when there are several
! 		matches, they are separated by <NL> characters.
! 
! 		If the expansion fails, the result is an empty String or List.
  		A name for a non-existing file is not included.
  
  		For most systems backticks can be used to get files names from
*** ../vim-7.3.464/src/eval.c	2012-02-11 20:44:01.000000000 +0100
--- src/eval.c	2012-03-07 19:08:36.000000000 +0100
***************
*** 7852,7858 ****
  #ifdef FEAT_FLOAT
      {"exp",		1, 1, f_exp},
  #endif
!     {"expand",		1, 2, f_expand},
      {"extend",		2, 3, f_extend},
      {"feedkeys",	1, 2, f_feedkeys},
      {"file_readable",	1, 1, f_filereadable},	/* obsolete */
--- 7852,7858 ----
  #ifdef FEAT_FLOAT
      {"exp",		1, 1, f_exp},
  #endif
!     {"expand",		1, 3, f_expand},
      {"extend",		2, 3, f_extend},
      {"feedkeys",	1, 2, f_feedkeys},
      {"file_readable",	1, 1, f_filereadable},	/* obsolete */
***************
*** 7903,7909 ****
      {"getwinposx",	0, 0, f_getwinposx},
      {"getwinposy",	0, 0, f_getwinposy},
      {"getwinvar",	2, 2, f_getwinvar},
!     {"glob",		1, 2, f_glob},
      {"globpath",	2, 3, f_globpath},
      {"has",		1, 1, f_has},
      {"has_key",		2, 2, f_has_key},
--- 7903,7909 ----
      {"getwinposx",	0, 0, f_getwinposx},
      {"getwinposy",	0, 0, f_getwinposy},
      {"getwinvar",	2, 2, f_getwinvar},
!     {"glob",		1, 3, f_glob},
      {"globpath",	2, 3, f_globpath},
      {"has",		1, 1, f_has},
      {"has_key",		2, 2, f_has_key},
***************
*** 10019,10032 ****
      int		options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
      expand_T	xpc;
      int		error = FALSE;
  
      rettv->v_type = VAR_STRING;
      s = get_tv_string(&argvars[0]);
      if (*s == '%' || *s == '#' || *s == '<')
      {
  	++emsg_off;
! 	rettv->vval.v_string = eval_vars(s, s, &len, NULL, &errormsg, NULL);
  	--emsg_off;
      }
      else
      {
--- 10019,10051 ----
      int		options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
      expand_T	xpc;
      int		error = FALSE;
+     char_u	*result;
  
      rettv->v_type = VAR_STRING;
+     if (argvars[1].v_type != VAR_UNKNOWN
+ 	    && argvars[2].v_type != VAR_UNKNOWN
+ 	    && get_tv_number_chk(&argvars[2], &error)
+ 	    && !error)
+     {
+ 	rettv->v_type = VAR_LIST;
+ 	rettv->vval.v_list = NULL;
+     }
+ 
      s = get_tv_string(&argvars[0]);
      if (*s == '%' || *s == '#' || *s == '<')
      {
  	++emsg_off;
! 	result = eval_vars(s, s, &len, NULL, &errormsg, NULL);
  	--emsg_off;
+ 	if (rettv->v_type == VAR_LIST)
+ 	{
+ 	    if (rettv_list_alloc(rettv) != FAIL && result != NULL)
+ 		list_append_string(rettv->vval.v_list, result, -1);
+ 	    else
+ 		vim_free(result);
+ 	}
+ 	else
+ 	    rettv->vval.v_string = result;
      }
      else
      {
***************
*** 10041,10047 ****
  	    xpc.xp_context = EXPAND_FILES;
  	    if (p_wic)
  		options += WILD_ICASE;
! 	    rettv->vval.v_string = ExpandOne(&xpc, s, NULL, options, WILD_ALL);
  	}
  	else
  	    rettv->vval.v_string = NULL;
--- 10060,10077 ----
  	    xpc.xp_context = EXPAND_FILES;
  	    if (p_wic)
  		options += WILD_ICASE;
! 	    if (rettv->v_type == VAR_STRING)
! 		rettv->vval.v_string = ExpandOne(&xpc, s, NULL,
! 							   options, WILD_ALL);
! 	    else if (rettv_list_alloc(rettv) != FAIL)
! 	    {
! 		int i;
! 
! 		ExpandOne(&xpc, s, NULL, options, WILD_ALL_KEEP);
! 		for (i = 0; i < xpc.xp_numfiles; i++)
! 		    list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1);
! 		ExpandCleanup(&xpc);
! 	    }
  	}
  	else
  	    rettv->vval.v_string = NULL;
***************
*** 11833,11851 ****
      int		error = FALSE;
  
      /* When the optional second argument is non-zero, don't remove matches
!     * for 'wildignore' and don't put matches for 'suffixes' at the end. */
!     if (argvars[1].v_type != VAR_UNKNOWN
! 				&& get_tv_number_chk(&argvars[1], &error))
! 	options |= WILD_KEEP_ALL;
      rettv->v_type = VAR_STRING;
      if (!error)
      {
  	ExpandInit(&xpc);
  	xpc.xp_context = EXPAND_FILES;
  	if (p_wic)
  	    options += WILD_ICASE;
! 	rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
  						     NULL, options, WILD_ALL);
      }
      else
  	rettv->vval.v_string = NULL;
--- 11863,11901 ----
      int		error = FALSE;
  
      /* When the optional second argument is non-zero, don't remove matches
!      * for 'wildignore' and don't put matches for 'suffixes' at the end. */
      rettv->v_type = VAR_STRING;
+     if (argvars[1].v_type != VAR_UNKNOWN)
+     {
+ 	if (get_tv_number_chk(&argvars[1], &error))
+ 	    options |= WILD_KEEP_ALL;
+ 	if (argvars[2].v_type != VAR_UNKNOWN
+ 				    && get_tv_number_chk(&argvars[2], &error))
+ 	{
+ 	    rettv->v_type = VAR_LIST;
+ 	    rettv->vval.v_list = NULL;
+ 	}
+     }
      if (!error)
      {
  	ExpandInit(&xpc);
  	xpc.xp_context = EXPAND_FILES;
  	if (p_wic)
  	    options += WILD_ICASE;
! 	if (rettv->v_type == VAR_STRING)
! 	    rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
  						     NULL, options, WILD_ALL);
+ 	else if (rettv_list_alloc(rettv) != FAIL)
+ 	{
+ 	  int i;
+ 
+ 	  ExpandOne(&xpc, get_tv_string(&argvars[0]),
+ 						NULL, options, WILD_ALL_KEEP);
+ 	  for (i = 0; i < xpc.xp_numfiles; i++)
+ 	      list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1);
+ 
+ 	  ExpandCleanup(&xpc);
+ 	}
      }
      else
  	rettv->vval.v_string = NULL;
*** ../vim-7.3.464/src/ex_getln.c	2012-02-22 17:58:00.000000000 +0100
--- src/ex_getln.c	2012-03-07 19:07:01.000000000 +0100
***************
*** 3461,3466 ****
--- 3461,3467 ----
   * mode = WILD_PREV:	    use previous match in multiple match, wrap to first
   * mode = WILD_ALL:	    return all matches concatenated
   * mode = WILD_LONGEST:	    return longest matched part
+  * mode = WILD_ALL_KEEP:    get all matches, keep matches
   *
   * options = WILD_LIST_NOTFOUND:    list entries without a match
   * options = WILD_HOME_REPLACE:	    do home_replace() for buffer names
***************
*** 3584,3590 ****
  	    /*
  	     * Check for matching suffixes in file names.
  	     */
! 	    if (mode != WILD_ALL && mode != WILD_LONGEST)
  	    {
  		if (xp->xp_numfiles)
  		    non_suf_match = xp->xp_numfiles;
--- 3585,3592 ----
  	    /*
  	     * Check for matching suffixes in file names.
  	     */
! 	    if (mode != WILD_ALL && mode != WILD_ALL_KEEP
! 						      && mode != WILD_LONGEST)
  	    {
  		if (xp->xp_numfiles)
  		    non_suf_match = xp->xp_numfiles;
*** ../vim-7.3.464/src/vim.h	2011-07-27 17:31:42.000000000 +0200
--- src/vim.h	2012-03-07 19:03:43.000000000 +0100
***************
*** 794,799 ****
--- 794,800 ----
  #define WILD_PREV		5
  #define WILD_ALL		6
  #define WILD_LONGEST		7
+ #define WILD_ALL_KEEP		8
  
  #define WILD_LIST_NOTFOUND	1
  #define WILD_HOME_REPLACE	2
*** ../vim-7.3.464/src/version.c	2012-03-07 18:04:00.000000000 +0100
--- src/version.c	2012-03-07 19:14:39.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     465,
  /**/

-- 
Although the scythe isn't pre-eminent among the weapons of war, anyone who
has been on the wrong end of, say, a peasants' revolt will know that in
skilled hands it is fearsome.
					-- (Terry Pratchett, Mort)

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