]> git.pld-linux.org Git - packages/vim.git/blob - 7.0.111
- new
[packages/vim.git] / 7.0.111
1 To: vim-dev@vim.org
2 Subject: Patch 7.0.111
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.0.111
11 Problem:    The gzip plugin can't handle filenames with single quotes.
12 Solution:   Add and use the shellescape() function. (partly by Alexey Froloff)
13 Files:      runtime/autoload/gzip.vim, runtime/doc/eval.txt, src/eval.c,
14             src/mbyte.c, src/misc2.c, src/proto/misc2.pro
15
16
17 *** ../vim-7.0.110/runtime/autoload/gzip.vim    Tue Aug  8 19:55:06 2006
18 --- runtime/autoload/gzip.vim   Tue Oct  3 14:39:29 2006
19 ***************
20 *** 1,6 ****
21   " Vim autoload file for editing compressed files.
22   " Maintainer: Bram Moolenaar <Bram@vim.org>
23 ! " Last Change: 2006 Jul 19
24   
25   " These functions are used by the gzip plugin.
26   
27 --- 1,6 ----
28   " Vim autoload file for editing compressed files.
29   " Maintainer: Bram Moolenaar <Bram@vim.org>
30 ! " Last Change: 2006 Oct 03
31   
32   " These functions are used by the gzip plugin.
33   
34 ***************
35 *** 68,76 ****
36     let tmp = tempname()
37     let tmpe = tmp . "." . expand("<afile>:e")
38     " write the just read lines to a temp file "'[,']w tmp.gz"
39 !   execute "silent '[,']w " . tmpe
40     " uncompress the temp file: call system("gzip -dn tmp.gz")
41 !   call system(a:cmd . " " . tmpe)
42     if !filereadable(tmp)
43       " uncompress didn't work!  Keep the compressed file then.
44       echoerr "Error: Could not read uncompressed file"
45 --- 68,76 ----
46     let tmp = tempname()
47     let tmpe = tmp . "." . expand("<afile>:e")
48     " write the just read lines to a temp file "'[,']w tmp.gz"
49 !   execute "silent '[,']w " . escape(tmpe, ' ')
50     " uncompress the temp file: call system("gzip -dn tmp.gz")
51 !   call system(a:cmd . " " . s:escape(tmpe))
52     if !filereadable(tmp)
53       " uncompress didn't work!  Keep the compressed file then.
54       echoerr "Error: Could not read uncompressed file"
55 ***************
56 *** 127,135 ****
57       let nmt = s:tempname(nm)
58       if rename(nm, nmt) == 0
59         if exists("b:gzip_comp_arg")
60 !       call system(a:cmd . " " . b:gzip_comp_arg . " '" . nmt . "'")
61         else
62 !       call system(a:cmd . " '" . nmt . "'")
63         endif
64         call rename(nmt . "." . expand("<afile>:e"), nm)
65       endif
66 --- 127,135 ----
67       let nmt = s:tempname(nm)
68       if rename(nm, nmt) == 0
69         if exists("b:gzip_comp_arg")
70 !       call system(a:cmd . " " . b:gzip_comp_arg . " " . s:escape(nmt))
71         else
72 !       call system(a:cmd . " " . s:escape(nmt))
73         endif
74         call rename(nmt . "." . expand("<afile>:e"), nm)
75       endif
76 ***************
77 *** 154,163 ****
78       if rename(nm, nmte) == 0
79         if &patchmode != "" && getfsize(nm . &patchmode) == -1
80         " Create patchmode file by creating the decompressed file new
81 !       call system(a:cmd . " -c " . nmte . " > " . nmt)
82         call rename(nmte, nm . &patchmode)
83         else
84 !       call system(a:cmd . " " . nmte)
85         endif
86         call rename(nmt, nm)
87       endif
88 --- 154,163 ----
89       if rename(nm, nmte) == 0
90         if &patchmode != "" && getfsize(nm . &patchmode) == -1
91         " Create patchmode file by creating the decompressed file new
92 !       call system(a:cmd . " -c " . s:escape(nmte) . " > " . s:escape(nmt))
93         call rename(nmte, nm . &patchmode)
94         else
95 !       call system(a:cmd . " " . s:escape(nmte))
96         endif
97         call rename(nmt, nm)
98       endif
99 ***************
100 *** 173,178 ****
101 --- 173,186 ----
102       return fn
103     endif
104     return fnamemodify(a:name, ":p:h") . "/X~=@l9q5"
105 + endfun
106
107 + fun s:escape(name)
108 +   " shellescape() was added by patch 7.0.111
109 +   if v:version > 700 || (v:version == 700 && has('patch111'))
110 +     return shellescape(a:name)
111 +   endif
112 +   return "'" . a:name . "'"
113   endfun
114   
115   " vim: set sw=2 :
116 *** ../vim-7.0.110/runtime/doc/eval.txt Sun May  7 17:08:32 2006
117 --- runtime/doc/eval.txt        Fri Sep 22 19:43:18 2006
118 ***************
119 *** 1,4 ****
120 ! *eval.txt*      For Vim version 7.0.  Last change: 2006 May 06
121   
122   
123                   VIM REFERENCE MANUAL    by Bram Moolenaar
124 --- 1,4 ----
125 ! *eval.txt*      For Vim version 7.0.  Last change: 2006 Sep 22
126   
127   
128                   VIM REFERENCE MANUAL    by Bram Moolenaar
129 ***************
130 *** 1709,1714 ****
131 --- 1715,1722 ----
132   settabwinvar( {tabnr}, {winnr}, {varname}, {val})    set {varname} in window
133                                         {winnr} in tab page {tabnr} to {val}
134   setwinvar( {nr}, {varname}, {val})    set {varname} in window {nr} to {val}
135 + shellescape( {string})                String  escape {string} for use as shell
136 +                                       command argument
137   simplify( {filename})         String  simplify filename as much as possible
138   sort( {list} [, {func}])      List    sort {list}, using {func} to compare
139   soundfold( {word})            String  sound-fold {word}
140 ***************
141 *** 4434,4439 ****
142 --- 4457,4477 ----
143                         :call setwinvar(1, "&list", 0)
144                         :call setwinvar(2, "myvar", "foobar")
145   
146 + shellescape({string})                                 *shellescape()*
147 +               Escape {string} for use as shell command argument.
148 +               On MS-Windows and MS-DOS, when 'shellslash' is not set, it
149 +               will enclose {string} double quotes and double all double
150 +               quotes within {string}.
151 +               For other systems, it will enclose {string} in single quotes
152 +               and replace all "'" with "'\''".
153 +               Example: >
154 +                       :echo shellescape('c:\program files\vim')
155 + <             results in:
156 +                       "c:\program files\vim" ~
157 +               Example usage: >
158 +                       :call system("chmod +x -- " . shellescape(expand("%")))
159
160
161   simplify({filename})                                  *simplify()*
162                 Simplify the file name as much as possible without changing
163                 the meaning.  Shortcuts (on MS-Windows) or symbolic links (on
164 *** ../vim-7.0.110/src/eval.c   Sat Sep  9 12:05:39 2006
165 --- src/eval.c  Thu Sep 14 17:44:41 2006
166 ***************
167 *** 622,627 ****
168 --- 622,628 ----
169   static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
170   static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
171   static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
172 + static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
173   static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
174   static void f_sort __ARGS((typval_T *argvars, typval_T *rettv));
175   static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv));
176 ***************
177 *** 7146,7151 ****
178 --- 7147,7153 ----
179       {"setreg",                2, 3, f_setreg},
180       {"settabwinvar",  4, 4, f_settabwinvar},
181       {"setwinvar",     3, 3, f_setwinvar},
182 +     {"shellescape",   1, 1, f_shellescape},
183       {"simplify",      1, 1, f_simplify},
184       {"sort",          1, 2, f_sort},
185       {"soundfold",     1, 1, f_soundfold},
186 ***************
187 *** 14602,14607 ****
188 --- 14604,14621 ----
189         }
190   #endif
191       }
192 + }
193
194 + /*
195 +  * "shellescape({string})" function
196 +  */
197 +     static void
198 + f_shellescape(argvars, rettv)
199 +     typval_T  *argvars;
200 +     typval_T  *rettv;
201 + {
202 +     rettv->vval.v_string = vim_strsave_shellescape(get_tv_string(&argvars[0]));
203 +     rettv->v_type = VAR_STRING;
204   }
205   
206   /*
207 *** ../vim-7.0.110/src/misc2.c  Thu May  4 23:50:56 2006
208 --- src/misc2.c Tue Sep 26 23:13:57 2006
209 ***************
210 *** 1229,1234 ****
211 --- 1229,1322 ----
212       return escaped_string;
213   }
214   
215 + #if defined(FEAT_EVAL) || defined(PROTO)
216 + /*
217 +  * Escape "string" for use as a shell argument with system().
218 +  * This uses single quotes, except when we know we need to use double qoutes
219 +  * (MS-DOS and MS-Windows without 'shellslash' set).
220 +  * Returns the result in allocated memory, NULL if we have run out.
221 +  */
222 +     char_u *
223 + vim_strsave_shellescape(string)
224 +     char_u    *string;
225 + {
226 +     unsigned  length;
227 +     char_u    *p;
228 +     char_u    *d;
229 +     char_u    *escaped_string;
230
231 +     /* First count the number of extra bytes required. */
232 +     length = STRLEN(string) + 3;      /* two quotes and the trailing NUL */
233 +     for (p = string; *p != NUL; mb_ptr_adv(p))
234 +     {
235 + # if defined(WIN32) || defined(WIN16) || defined(DOS)
236 +       if (!p_ssl)
237 +       {
238 +           if (*p == '"')
239 +               ++length;               /* " -> "" */
240 +       }
241 +       else
242 + # endif
243 +       if (*p == '\'')
244 +           length += 3;                /* ' => '\'' */
245 +     }
246
247 +     /* Allocate memory for the result and fill it. */
248 +     escaped_string = alloc(length);
249 +     if (escaped_string != NULL)
250 +     {
251 +       d = escaped_string;
252
253 +       /* add opening quote */
254 + # if defined(WIN32) || defined(WIN16) || defined(DOS)
255 +       if (!p_ssl)
256 +           *d++ = '"';
257 +       else
258 + # endif
259 +           *d++ = '\'';
260
261 +       for (p = string; *p != NUL; )
262 +       {
263 + # if defined(WIN32) || defined(WIN16) || defined(DOS)
264 +           if (!p_ssl)
265 +           {
266 +               if (*p == '"')
267 +               {
268 +                   *d++ = '"';
269 +                   *d++ = '"';
270 +                   ++p;
271 +                   continue;
272 +               }
273 +           }
274 +           else
275 + # endif
276 +           if (*p == '\'')
277 +           {
278 +               *d++='\'';
279 +               *d++='\\';
280 +               *d++='\'';
281 +               *d++='\'';
282 +               ++p;
283 +               continue;
284 +           }
285
286 +           MB_COPY_CHAR(p, d);
287 +       }
288
289 +       /* add terminating quote and finish with a NUL */
290 + # if defined(WIN32) || defined(WIN16) || defined(DOS)
291 +       if (!p_ssl)
292 +           *d++ = '"';
293 +       else
294 + # endif
295 +           *d++ = '\'';
296 +       *d = NUL;
297 +     }
298
299 +     return escaped_string;
300 + }
301 + #endif
302
303   /*
304    * Like vim_strsave(), but make all characters uppercase.
305    * This uses ASCII lower-to-upper case translation, language independent.
306 *** ../vim-7.0.110/src/proto/misc2.pro  Fri Mar 24 23:42:55 2006
307 --- src/proto/misc2.pro Thu Sep 14 18:28:43 2006
308 ***************
309 *** 29,34 ****
310 --- 29,35 ----
311   extern char_u *vim_strnsave __ARGS((char_u *string, int len));
312   extern char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
313   extern char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl));
314 + extern char_u *vim_strsave_shellescape __ARGS((char_u *string));
315   extern char_u *vim_strsave_up __ARGS((char_u *string));
316   extern char_u *vim_strnsave_up __ARGS((char_u *string, int len));
317   extern void vim_strup __ARGS((char_u *p));
318 *** ../vim-7.0.110/src/version.c        Tue Sep 26 13:49:41 2006
319 --- src/version.c       Tue Oct  3 14:36:40 2006
320 ***************
321 *** 668,669 ****
322 --- 668,671 ----
323   {   /* Add new patch number below this line */
324 + /**/
325 +     111,
326   /**/
327
328 -- 
329 The only way the average employee can speak to an executive is by taking a
330 second job as a golf caddie.
331                                 (Scott Adams - The Dilbert principle)
332
333  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
334 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
335 \\\        download, build and distribute -- http://www.A-A-P.org        ///
336  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.049031 seconds and 3 git commands to generate.