]> git.pld-linux.org Git - packages/vim.git/blob - 7.1.299
- typo
[packages/vim.git] / 7.1.299
1 To: vim-dev@vim.org
2 Subject: Patch 7.1.299
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.1.299
11 Problem:    Filetype detection doesn't work properly for file names ending in
12             a part that is ignored and contain a space or other special
13             characters.
14 Solution:   Escape the special characters using the new fnameescape function.
15 Files:      runtime/doc/eval.txt, runtime/filetype.vim, src/eval.c,
16             src/ex_getln.c, src/proto/ex_getln.pro, src/vim.h
17
18
19 *** ../vim-7.1.298/runtime/doc/eval.txt Wed Feb 20 20:09:44 2008
20 --- runtime/doc/eval.txt        Wed May 28 16:42:42 2008
21 ***************
22 *** 1,4 ****
23 ! *eval.txt*      For Vim version 7.1.  Last change: 2008 Feb 20
24   
25   
26                   VIM REFERENCE MANUAL    by Bram Moolenaar
27 --- 1,4 ----
28 ! *eval.txt*      For Vim version 7.1.  Last change: 2008 May 28
29   
30   
31                   VIM REFERENCE MANUAL    by Bram Moolenaar
32 ***************
33 *** 1609,1614 ****
34 --- 1652,1658 ----
35                                 String  find directory {name} in {path}
36   findfile( {name}[, {path}[, {count}]])
37                                 String  find file {name} in {path}
38 + fnameescape( {fname})         String  escape special characters in {fname}
39   fnamemodify( {fname}, {mods}) String  modify file name
40   foldclosed( {lnum})           Number  first line of fold at {lnum} if closed
41   foldclosedend( {lnum})                Number  last line of fold at {lnum} if closed
42 ***************
43 *** 2620,2625 ****
44 --- 2669,2687 ----
45   <             Searches from the directory of the current file upwards until
46                 it finds the file "tags.vim".
47   
48 + fnameescape({string})                                 *fnameescape()*
49 +               Escape {string} for use as file name command argument.  All
50 +               characters that have a special meaning, such as '%' and '|'
51 +               are escaped with a backslash.
52 +               For most systems the characters escaped are "".  For systems
53 +               where a backslash appears in a filename, it depends on the
54 +               value of 'isfname'.
55 +               Example: >
56 +                       :let fname = 'some str%nge|name'
57 +                       :exe "edit " . fnameescape(fname)
58 + <             results in executing: >
59 +                       edit some\ str\%nge\|name
60
61   fnamemodify({fname}, {mods})                          *fnamemodify()*
62                 Modify file name {fname} according to {mods}.  {mods} is a
63                 string of characters like it is used for file names on the
64 *** ../vim-7.1.298/runtime/filetype.vim Tue May 15 09:14:33 2007
65 --- runtime/filetype.vim        Wed May 28 16:39:09 2008
66 ***************
67 *** 16,35 ****
68   augroup filetypedetect
69   
70   " Ignored extensions
71   au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
72 !       \ exe "doau filetypedetect BufRead " . expand("<afile>:r")
73   au BufNewFile,BufRead *~
74         \ let s:name = expand("<afile>") |
75         \ let s:short = substitute(s:name, '\~$', '', '') |
76         \ if s:name != s:short && s:short != "" |
77 !       \   exe "doau filetypedetect BufRead " . s:short |
78         \ endif |
79 !       \ unlet s:name |
80 !       \ unlet s:short
81   au BufNewFile,BufRead ?\+.in
82         \ if expand("<afile>:t") != "configure.in" |
83 !       \   exe "doau filetypedetect BufRead " . expand("<afile>:r") |
84         \ endif
85   
86   " Pattern used to match file names which should not be inspected.
87   " Currently finds compressed files.
88 --- 16,38 ----
89   augroup filetypedetect
90   
91   " Ignored extensions
92 + if exists("*fnameescape")
93   au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
94 !       \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
95   au BufNewFile,BufRead *~
96         \ let s:name = expand("<afile>") |
97         \ let s:short = substitute(s:name, '\~$', '', '') |
98         \ if s:name != s:short && s:short != "" |
99 !       \   exe "doau filetypedetect BufRead " . fnameescape(s:short) |
100         \ endif |
101 !       \ unlet s:name s:short
102   au BufNewFile,BufRead ?\+.in
103         \ if expand("<afile>:t") != "configure.in" |
104 !       \   exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) |
105         \ endif
106 + elseif &verbose > 0
107 +   echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
108 + endif
109   
110   " Pattern used to match file names which should not be inspected.
111   " Currently finds compressed files.
112 *** ../vim-7.1.298/src/eval.c   Tue Apr  1 13:10:45 2008
113 --- src/eval.c  Wed May 28 16:35:51 2008
114 ***************
115 *** 507,512 ****
116 --- 516,522 ----
117   static void f_filter __ARGS((typval_T *argvars, typval_T *rettv));
118   static void f_finddir __ARGS((typval_T *argvars, typval_T *rettv));
119   static void f_findfile __ARGS((typval_T *argvars, typval_T *rettv));
120 + static void f_fnameescape __ARGS((typval_T *argvars, typval_T *rettv));
121   static void f_fnamemodify __ARGS((typval_T *argvars, typval_T *rettv));
122   static void f_foldclosed __ARGS((typval_T *argvars, typval_T *rettv));
123   static void f_foldclosedend __ARGS((typval_T *argvars, typval_T *rettv));
124 ***************
125 *** 7107,7112 ****
126 --- 7437,7443 ----
127       {"filter",                2, 2, f_filter},
128       {"finddir",               1, 3, f_finddir},
129       {"findfile",      1, 3, f_findfile},
130 +     {"fnameescape",   1, 1, f_fnameescape},
131       {"fnamemodify",   2, 2, f_fnamemodify},
132       {"foldclosed",    1, 1, f_foldclosed},
133       {"foldclosedend", 1, 1, f_foldclosedend},
134 ***************
135 *** 9465,9470 ****
136 --- 9804,9822 ----
137   }
138   
139   /*
140 +  * "fnameescape({string})" function
141 +  */
142 +     static void
143 + f_fnameescape(argvars, rettv)
144 +     typval_T  *argvars;
145 +     typval_T  *rettv;
146 + {
147 +     rettv->vval.v_string = vim_strsave_fnameescape(
148 +                                          get_tv_string(&argvars[0]), FALSE);
149 +     rettv->v_type = VAR_STRING;
150 + }
151
152 + /*
153    * "fnamemodify({fname}, {mods})" function
154    */
155       static void
156 *** ../vim-7.1.298/src/ex_getln.c       Tue Jan 22 12:44:03 2008
157 --- src/ex_getln.c      Mon May 26 22:14:51 2008
158 ***************
159 *** 3656,3677 ****
160   #endif
161                     }
162                 }
163 ! #ifdef BACKSLASH_IN_FILENAME
164 !               {
165 !                   char_u      buf[20];
166 !                   int         j = 0;
167
168 !                   /* Don't escape '[' and '{' if they are in 'isfname'. */
169 !                   for (p = PATH_ESC_CHARS; *p != NUL; ++p)
170 !                       if ((*p != '[' && *p != '{') || !vim_isfilec(*p))
171 !                           buf[j++] = *p;
172 !                   buf[j] = NUL;
173 !                   p = vim_strsave_escaped(files[i], buf);
174 !               }
175 ! #else
176 !               p = vim_strsave_escaped(files[i],
177 !                            xp->xp_shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
178 ! #endif
179                 if (p != NULL)
180                 {
181                     vim_free(files[i]);
182 --- 3656,3662 ----
183   #endif
184                     }
185                 }
186 !               p = vim_strsave_fnameescape(files[i], xp->xp_shell);
187                 if (p != NULL)
188                 {
189                     vim_free(files[i]);
190 ***************
191 *** 3710,3715 ****
192 --- 3695,3725 ----
193   }
194   
195   /*
196 +  * Escape special characters in "fname" for when used as a file name argument
197 +  * after a Vim command, or, when "shell" is non-zero, a shell command.
198 +  * Returns the result in allocated memory.
199 +  */
200 +     char_u *
201 + vim_strsave_fnameescape(fname, shell)
202 +     char_u *fname;
203 +     int    shell;
204 + {
205 + #ifdef BACKSLASH_IN_FILENAME
206 +     char_u    buf[20];
207 +     int               j = 0;
208
209 +     /* Don't escape '[' and '{' if they are in 'isfname'. */
210 +     for (p = PATH_ESC_CHARS; *p != NUL; ++p)
211 +       if ((*p != '[' && *p != '{') || !vim_isfilec(*p))
212 +           buf[j++] = *p;
213 +     buf[j] = NUL;
214 +     return vim_strsave_escaped(fname, buf);
215 + #else
216 +     return vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
217 + #endif
218 + }
219
220 + /*
221    * Put a backslash before the file name in "pp", which is in allocated memory.
222    */
223       static void
224 *** ../vim-7.1.298/src/proto/ex_getln.pro       Sat May  5 19:24:48 2007
225 --- src/proto/ex_getln.pro      Mon May 26 22:14:41 2008
226 ***************
227 *** 24,29 ****
228 --- 24,30 ----
229   void ExpandInit __ARGS((expand_T *xp));
230   void ExpandCleanup __ARGS((expand_T *xp));
231   void ExpandEscape __ARGS((expand_T *xp, char_u *str, int numfiles, char_u **files, int options));
232 + char_u *vim_strsave_fnameescape __ARGS((char_u *fname, int shell));
233   void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files));
234   char_u *sm_gettail __ARGS((char_u *s));
235   char_u *addstar __ARGS((char_u *fname, int len, int context));
236 *** ../vim-7.1.298/src/vim.h    Sun Mar 16 16:02:47 2008
237 --- src/vim.h   Wed May 28 16:37:50 2008
238 ***************
239 *** 336,345 ****
240   # endif
241   #endif
242   #ifdef BACKSLASH_IN_FILENAME
243 ! # define PATH_ESC_CHARS ((char_u *)" \t*?[{`%#")
244   #else
245 ! # define PATH_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|")
246 ! # define SHELL_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|<>();&!")
247   #endif
248   
249   #define NUMBUFLEN 30      /* length of a buffer to store a number in ASCII */
250 --- 336,345 ----
251   # endif
252   #endif
253   #ifdef BACKSLASH_IN_FILENAME
254 ! # define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`%#'\"|!<")
255   #else
256 ! # define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
257 ! # define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
258   #endif
259   
260   #define NUMBUFLEN 30      /* length of a buffer to store a number in ASCII */
261 *** ../vim-7.1.298/src/version.c        Sat May 10 21:37:56 2008
262 --- src/version.c       Wed May 28 16:40:11 2008
263 ***************
264 *** 668,669 ****
265 --- 673,676 ----
266   {   /* Add new patch number below this line */
267 + /**/
268 +     299,
269   /**/
270
271 -- 
272 FIRST SOLDIER:  So they wouldn't be able to bring a coconut back anyway.
273 SECOND SOLDIER: Wait a minute! Suppose two swallows carried it together?
274 FIRST SOLDIER:  No, they'd have to have it on a line.
275                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
276
277  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
278 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
279 \\\        download, build and distribute -- http://www.A-A-P.org        ///
280  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.476458 seconds and 3 git commands to generate.