]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.465
- up to 7.3.600
[packages/vim.git] / 7.3.465
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.465
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.465
11 Problem:    Cannot get file name with newline from glob().
12 Solution:   Add argument to glob() and expand() to indicate they must return a
13             list. (Christian Brabandt)
14 Files:      runtime/doc/eval.txt, src/eval.c, src/ex_getln.c, src/vim.h
15
16
17 *** ../vim-7.3.464/runtime/doc/eval.txt 2011-12-14 15:32:44.000000000 +0100
18 --- runtime/doc/eval.txt        2012-03-07 18:49:26.000000000 +0100
19 ***************
20 *** 1738,1744 ****
21   extend( {expr1}, {expr2} [, {expr3}])
22                                 List/Dict insert items of {expr2} into {expr1}
23   exp( {expr})                  Float   exponential of {expr}
24 ! expand( {expr} [, {flag}])    String  expand special keywords in {expr}
25   feedkeys( {string} [, {mode}])        Number  add key sequence to typeahead buffer
26   filereadable( {file})         Number  TRUE if {file} is a readable file
27   filewritable( {file})         Number  TRUE if {file} is a writable file
28 --- 1746,1753 ----
29   extend( {expr1}, {expr2} [, {expr3}])
30                                 List/Dict insert items of {expr2} into {expr1}
31   exp( {expr})                  Float   exponential of {expr}
32 ! expand( {expr} [, {nosuf} [, {list}]])
33 !                               any     expand special keywords in {expr}
34   feedkeys( {string} [, {mode}])        Number  add key sequence to typeahead buffer
35   filereadable( {file})         Number  TRUE if {file} is a readable file
36   filewritable( {file})         Number  TRUE if {file} is a writable file
37 ***************
38 *** 1792,1798 ****
39   getwinposx()                  Number  X coord in pixels of GUI Vim window
40   getwinposy()                  Number  Y coord in pixels of GUI Vim window
41   getwinvar( {nr}, {varname})   any     variable {varname} in window {nr}
42 ! glob( {expr} [, {flag}])      String  expand file wildcards in {expr}
43   globpath( {path}, {expr} [, {flag}])
44                                 String  do glob({expr}) for all dirs in {path}
45   has( {feature})                       Number  TRUE if feature {feature} supported
46 --- 1801,1808 ----
47   getwinposx()                  Number  X coord in pixels of GUI Vim window
48   getwinposy()                  Number  Y coord in pixels of GUI Vim window
49   getwinvar( {nr}, {varname})   any     variable {varname} in window {nr}
50 ! glob( {expr} [, {nosuf} [, {list}]])
51 !                               any     expand file wildcards in {expr}
52   globpath( {path}, {expr} [, {flag}])
53                                 String  do glob({expr}) for all dirs in {path}
54   has( {feature})                       Number  TRUE if feature {feature} supported
55 ***************
56 *** 2731,2743 ****
57                 {only available when compiled with the |+float| feature}
58   
59   
60 ! expand({expr} [, {flag}])                             *expand()*
61                 Expand wildcards and the following special keywords in {expr}.
62 !               The result is a String.
63   
64 !               When there are several matches, they are separated by <NL>
65 !               characters.  [Note: in version 5.0 a space was used, which
66 !               caused problems when a file name contains a space]
67   
68                 If the expansion fails, the result is an empty string.  A name
69                 for a non-existing file is not included.
70 --- 2744,2758 ----
71                 {only available when compiled with the |+float| feature}
72   
73   
74 ! expand({expr} [, {nosuf} [, {list}]])                         *expand()*
75                 Expand wildcards and the following special keywords in {expr}.
76 !               'wildignorecase' applies.
77   
78 !               If {list} is given and it is non-zero, a List will be returned.
79 !               Otherwise the result is a String and when there are several
80 !               matches, they are separated by <NL> characters.  [Note: in
81 !               version 5.0 a space was used, which caused problems when a
82 !               file name contains a space]
83   
84                 If the expansion fails, the result is an empty string.  A name
85                 for a non-existing file is not included.
86 ***************
87 *** 2754,2759 ****
88 --- 2769,2775 ----
89                         <abuf>          autocmd buffer number (as a String!)
90                         <amatch>        autocmd matched name
91                         <sfile>         sourced script file name
92 +                       <slnum>         sourced script file line number
93                         <cword>         word under the cursor
94                         <cWORD>         WORD under the cursor
95                         <client>        the {clientid} of the last received
96 ***************
97 *** 2790,2799 ****
98                 When {expr} does not start with '%', '#' or '<', it is
99                 expanded like a file name is expanded on the command line.
100                 'suffixes' and 'wildignore' are used, unless the optional
101 !               {flag} argument is given and it is non-zero.  Names for
102 !               non-existing files are included.  The "**" item can be used to
103 !               search in a directory tree.  For example, to find all "README"
104 !               files in the current directory and below: >
105                         :echo expand("**/README")
106   <
107                 Expand() can also be used to expand variables and environment
108 --- 2806,2815 ----
109                 When {expr} does not start with '%', '#' or '<', it is
110                 expanded like a file name is expanded on the command line.
111                 'suffixes' and 'wildignore' are used, unless the optional
112 !               {nosuf} argument is given and it is non-zero.
113 !               Names for non-existing files are included.  The "**" item can
114 !               be used to search in a directory tree.  For example, to find
115 !               all "README" files in the current directory and below: >
116                         :echo expand("**/README")
117   <
118                 Expand() can also be used to expand variables and environment
119 ***************
120 *** 3437,3453 ****
121                         :let list_is_on = getwinvar(2, '&list')
122                         :echo "myvar = " . getwinvar(1, 'myvar')
123   <
124 ! glob({expr} [, {flag}])                                       *glob()*
125                 Expand the file wildcards in {expr}.  See |wildcards| for the
126                 use of special characters.
127 !               The result is a String.
128 !               When there are several matches, they are separated by <NL>
129 !               characters.
130 !               Unless the optional {flag} argument is given and is non-zero,
131                 the 'suffixes' and 'wildignore' options apply: Names matching
132                 one of the patterns in 'wildignore' will be skipped and
133                 'suffixes' affect the ordering of matches.
134 !               If the expansion fails, the result is an empty string.
135                 A name for a non-existing file is not included.
136   
137                 For most systems backticks can be used to get files names from
138 --- 3456,3478 ----
139                         :let list_is_on = getwinvar(2, '&list')
140                         :echo "myvar = " . getwinvar(1, 'myvar')
141   <
142 ! glob({expr} [, {nosuf} [, {list}]])                           *glob()*
143                 Expand the file wildcards in {expr}.  See |wildcards| for the
144                 use of special characters.
145
146 !               Unless the optional {nosuf} argument is given and is non-zero,
147                 the 'suffixes' and 'wildignore' options apply: Names matching
148                 one of the patterns in 'wildignore' will be skipped and
149                 'suffixes' affect the ordering of matches.
150 !               'wildignorecase' always applies.
151
152 !               When {list} is present and it is non-zero the result is a List
153 !               with all matching files. The advantage of using a List is,
154 !               you also get filenames containing newlines correctly.
155 !               Otherwise the result is a String and when there are several
156 !               matches, they are separated by <NL> characters.
157
158 !               If the expansion fails, the result is an empty String or List.
159                 A name for a non-existing file is not included.
160   
161                 For most systems backticks can be used to get files names from
162 *** ../vim-7.3.464/src/eval.c   2012-02-11 20:44:01.000000000 +0100
163 --- src/eval.c  2012-03-07 19:08:36.000000000 +0100
164 ***************
165 *** 7852,7858 ****
166   #ifdef FEAT_FLOAT
167       {"exp",           1, 1, f_exp},
168   #endif
169 !     {"expand",                1, 2, f_expand},
170       {"extend",                2, 3, f_extend},
171       {"feedkeys",      1, 2, f_feedkeys},
172       {"file_readable", 1, 1, f_filereadable},  /* obsolete */
173 --- 7852,7858 ----
174   #ifdef FEAT_FLOAT
175       {"exp",           1, 1, f_exp},
176   #endif
177 !     {"expand",                1, 3, f_expand},
178       {"extend",                2, 3, f_extend},
179       {"feedkeys",      1, 2, f_feedkeys},
180       {"file_readable", 1, 1, f_filereadable},  /* obsolete */
181 ***************
182 *** 7903,7909 ****
183       {"getwinposx",    0, 0, f_getwinposx},
184       {"getwinposy",    0, 0, f_getwinposy},
185       {"getwinvar",     2, 2, f_getwinvar},
186 !     {"glob",          1, 2, f_glob},
187       {"globpath",      2, 3, f_globpath},
188       {"has",           1, 1, f_has},
189       {"has_key",               2, 2, f_has_key},
190 --- 7903,7909 ----
191       {"getwinposx",    0, 0, f_getwinposx},
192       {"getwinposy",    0, 0, f_getwinposy},
193       {"getwinvar",     2, 2, f_getwinvar},
194 !     {"glob",          1, 3, f_glob},
195       {"globpath",      2, 3, f_globpath},
196       {"has",           1, 1, f_has},
197       {"has_key",               2, 2, f_has_key},
198 ***************
199 *** 10019,10032 ****
200       int               options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
201       expand_T  xpc;
202       int               error = FALSE;
203   
204       rettv->v_type = VAR_STRING;
205       s = get_tv_string(&argvars[0]);
206       if (*s == '%' || *s == '#' || *s == '<')
207       {
208         ++emsg_off;
209 !       rettv->vval.v_string = eval_vars(s, s, &len, NULL, &errormsg, NULL);
210         --emsg_off;
211       }
212       else
213       {
214 --- 10019,10051 ----
215       int               options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
216       expand_T  xpc;
217       int               error = FALSE;
218 +     char_u    *result;
219   
220       rettv->v_type = VAR_STRING;
221 +     if (argvars[1].v_type != VAR_UNKNOWN
222 +           && argvars[2].v_type != VAR_UNKNOWN
223 +           && get_tv_number_chk(&argvars[2], &error)
224 +           && !error)
225 +     {
226 +       rettv->v_type = VAR_LIST;
227 +       rettv->vval.v_list = NULL;
228 +     }
229
230       s = get_tv_string(&argvars[0]);
231       if (*s == '%' || *s == '#' || *s == '<')
232       {
233         ++emsg_off;
234 !       result = eval_vars(s, s, &len, NULL, &errormsg, NULL);
235         --emsg_off;
236 +       if (rettv->v_type == VAR_LIST)
237 +       {
238 +           if (rettv_list_alloc(rettv) != FAIL && result != NULL)
239 +               list_append_string(rettv->vval.v_list, result, -1);
240 +           else
241 +               vim_free(result);
242 +       }
243 +       else
244 +           rettv->vval.v_string = result;
245       }
246       else
247       {
248 ***************
249 *** 10041,10047 ****
250             xpc.xp_context = EXPAND_FILES;
251             if (p_wic)
252                 options += WILD_ICASE;
253 !           rettv->vval.v_string = ExpandOne(&xpc, s, NULL, options, WILD_ALL);
254         }
255         else
256             rettv->vval.v_string = NULL;
257 --- 10060,10077 ----
258             xpc.xp_context = EXPAND_FILES;
259             if (p_wic)
260                 options += WILD_ICASE;
261 !           if (rettv->v_type == VAR_STRING)
262 !               rettv->vval.v_string = ExpandOne(&xpc, s, NULL,
263 !                                                          options, WILD_ALL);
264 !           else if (rettv_list_alloc(rettv) != FAIL)
265 !           {
266 !               int i;
267
268 !               ExpandOne(&xpc, s, NULL, options, WILD_ALL_KEEP);
269 !               for (i = 0; i < xpc.xp_numfiles; i++)
270 !                   list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1);
271 !               ExpandCleanup(&xpc);
272 !           }
273         }
274         else
275             rettv->vval.v_string = NULL;
276 ***************
277 *** 11833,11851 ****
278       int               error = FALSE;
279   
280       /* When the optional second argument is non-zero, don't remove matches
281 !     * for 'wildignore' and don't put matches for 'suffixes' at the end. */
282 !     if (argvars[1].v_type != VAR_UNKNOWN
283 !                               && get_tv_number_chk(&argvars[1], &error))
284 !       options |= WILD_KEEP_ALL;
285       rettv->v_type = VAR_STRING;
286       if (!error)
287       {
288         ExpandInit(&xpc);
289         xpc.xp_context = EXPAND_FILES;
290         if (p_wic)
291             options += WILD_ICASE;
292 !       rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
293                                                      NULL, options, WILD_ALL);
294       }
295       else
296         rettv->vval.v_string = NULL;
297 --- 11863,11901 ----
298       int               error = FALSE;
299   
300       /* When the optional second argument is non-zero, don't remove matches
301 !      * for 'wildignore' and don't put matches for 'suffixes' at the end. */
302       rettv->v_type = VAR_STRING;
303 +     if (argvars[1].v_type != VAR_UNKNOWN)
304 +     {
305 +       if (get_tv_number_chk(&argvars[1], &error))
306 +           options |= WILD_KEEP_ALL;
307 +       if (argvars[2].v_type != VAR_UNKNOWN
308 +                                   && get_tv_number_chk(&argvars[2], &error))
309 +       {
310 +           rettv->v_type = VAR_LIST;
311 +           rettv->vval.v_list = NULL;
312 +       }
313 +     }
314       if (!error)
315       {
316         ExpandInit(&xpc);
317         xpc.xp_context = EXPAND_FILES;
318         if (p_wic)
319             options += WILD_ICASE;
320 !       if (rettv->v_type == VAR_STRING)
321 !           rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
322                                                      NULL, options, WILD_ALL);
323 +       else if (rettv_list_alloc(rettv) != FAIL)
324 +       {
325 +         int i;
326
327 +         ExpandOne(&xpc, get_tv_string(&argvars[0]),
328 +                                               NULL, options, WILD_ALL_KEEP);
329 +         for (i = 0; i < xpc.xp_numfiles; i++)
330 +             list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1);
331
332 +         ExpandCleanup(&xpc);
333 +       }
334       }
335       else
336         rettv->vval.v_string = NULL;
337 *** ../vim-7.3.464/src/ex_getln.c       2012-02-22 17:58:00.000000000 +0100
338 --- src/ex_getln.c      2012-03-07 19:07:01.000000000 +0100
339 ***************
340 *** 3461,3466 ****
341 --- 3461,3467 ----
342    * mode = WILD_PREV:      use previous match in multiple match, wrap to first
343    * mode = WILD_ALL:       return all matches concatenated
344    * mode = WILD_LONGEST:           return longest matched part
345 +  * mode = WILD_ALL_KEEP:    get all matches, keep matches
346    *
347    * options = WILD_LIST_NOTFOUND:    list entries without a match
348    * options = WILD_HOME_REPLACE:           do home_replace() for buffer names
349 ***************
350 *** 3584,3590 ****
351             /*
352              * Check for matching suffixes in file names.
353              */
354 !           if (mode != WILD_ALL && mode != WILD_LONGEST)
355             {
356                 if (xp->xp_numfiles)
357                     non_suf_match = xp->xp_numfiles;
358 --- 3585,3592 ----
359             /*
360              * Check for matching suffixes in file names.
361              */
362 !           if (mode != WILD_ALL && mode != WILD_ALL_KEEP
363 !                                                     && mode != WILD_LONGEST)
364             {
365                 if (xp->xp_numfiles)
366                     non_suf_match = xp->xp_numfiles;
367 *** ../vim-7.3.464/src/vim.h    2011-07-27 17:31:42.000000000 +0200
368 --- src/vim.h   2012-03-07 19:03:43.000000000 +0100
369 ***************
370 *** 794,799 ****
371 --- 794,800 ----
372   #define WILD_PREV             5
373   #define WILD_ALL              6
374   #define WILD_LONGEST          7
375 + #define WILD_ALL_KEEP         8
376   
377   #define WILD_LIST_NOTFOUND    1
378   #define WILD_HOME_REPLACE     2
379 *** ../vim-7.3.464/src/version.c        2012-03-07 18:04:00.000000000 +0100
380 --- src/version.c       2012-03-07 19:14:39.000000000 +0100
381 ***************
382 *** 716,717 ****
383 --- 716,719 ----
384   {   /* Add new patch number below this line */
385 + /**/
386 +     465,
387   /**/
388
389 -- 
390 Although the scythe isn't pre-eminent among the weapons of war, anyone who
391 has been on the wrong end of, say, a peasants' revolt will know that in
392 skilled hands it is fearsome.
393                                         -- (Terry Pratchett, Mort)
394
395  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
396 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
397 \\\  an exciting new programming language -- http://www.Zimbu.org        ///
398  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.050761 seconds and 3 git commands to generate.