• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisión656853d9c014add434086291b7af40ad828f126a (tree)
Tiempo2006-10-03 21:44:42
Autorvimboss
Commitervimboss

Log Message

updated for version 7.0-111

Cambiar Resumen

Diferencia incremental

diff -r fa9ee618000f -r 656853d9c014 runtime/autoload/gzip.vim
--- a/runtime/autoload/gzip.vim Tue Sep 26 11:48:34 2006 +0000
+++ b/runtime/autoload/gzip.vim Tue Oct 03 12:44:42 2006 +0000
@@ -1,6 +1,6 @@
11 " Vim autoload file for editing compressed files.
22 " Maintainer: Bram Moolenaar <Bram@vim.org>
3-" Last Change: 2006 Jul 19
3+" Last Change: 2006 Oct 03
44
55 " These functions are used by the gzip plugin.
66
@@ -68,9 +68,9 @@
6868 let tmp = tempname()
6969 let tmpe = tmp . "." . expand("<afile>:e")
7070 " write the just read lines to a temp file "'[,']w tmp.gz"
71- execute "silent '[,']w " . tmpe
71+ execute "silent '[,']w " . escape(tmpe, ' ')
7272 " uncompress the temp file: call system("gzip -dn tmp.gz")
73- call system(a:cmd . " " . tmpe)
73+ call system(a:cmd . " " . s:escape(tmpe))
7474 if !filereadable(tmp)
7575 " uncompress didn't work! Keep the compressed file then.
7676 echoerr "Error: Could not read uncompressed file"
@@ -127,9 +127,9 @@
127127 let nmt = s:tempname(nm)
128128 if rename(nm, nmt) == 0
129129 if exists("b:gzip_comp_arg")
130- call system(a:cmd . " " . b:gzip_comp_arg . " '" . nmt . "'")
130+ call system(a:cmd . " " . b:gzip_comp_arg . " " . s:escape(nmt))
131131 else
132- call system(a:cmd . " '" . nmt . "'")
132+ call system(a:cmd . " " . s:escape(nmt))
133133 endif
134134 call rename(nmt . "." . expand("<afile>:e"), nm)
135135 endif
@@ -154,10 +154,10 @@
154154 if rename(nm, nmte) == 0
155155 if &patchmode != "" && getfsize(nm . &patchmode) == -1
156156 " Create patchmode file by creating the decompressed file new
157- call system(a:cmd . " -c " . nmte . " > " . nmt)
157+ call system(a:cmd . " -c " . s:escape(nmte) . " > " . s:escape(nmt))
158158 call rename(nmte, nm . &patchmode)
159159 else
160- call system(a:cmd . " " . nmte)
160+ call system(a:cmd . " " . s:escape(nmte))
161161 endif
162162 call rename(nmt, nm)
163163 endif
@@ -175,4 +175,12 @@
175175 return fnamemodify(a:name, ":p:h") . "/X~=@l9q5"
176176 endfun
177177
178+fun s:escape(name)
179+ " shellescape() was added by patch 7.0.111
180+ if v:version > 700 || (v:version == 700 && has('patch111'))
181+ return shellescape(a:name)
182+ endif
183+ return "'" . a:name . "'"
184+endfun
185+
178186 " vim: set sw=2 :
diff -r fa9ee618000f -r 656853d9c014 runtime/doc/eval.txt
--- a/runtime/doc/eval.txt Tue Sep 26 11:48:34 2006 +0000
+++ b/runtime/doc/eval.txt Tue Oct 03 12:44:42 2006 +0000
@@ -1,4 +1,4 @@
1-*eval.txt* For Vim version 7.0. Last change: 2006 May 06
1+*eval.txt* For Vim version 7.0. Last change: 2006 Sep 22
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1709,6 +1709,8 @@
17091709 settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window
17101710 {winnr} in tab page {tabnr} to {val}
17111711 setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val}
1712+shellescape( {string}) String escape {string} for use as shell
1713+ command argument
17121714 simplify( {filename}) String simplify filename as much as possible
17131715 sort( {list} [, {func}]) List sort {list}, using {func} to compare
17141716 soundfold( {word}) String sound-fold {word}
@@ -4434,6 +4436,21 @@
44344436 :call setwinvar(1, "&list", 0)
44354437 :call setwinvar(2, "myvar", "foobar")
44364438
4439+shellescape({string}) *shellescape()*
4440+ Escape {string} for use as shell command argument.
4441+ On MS-Windows and MS-DOS, when 'shellslash' is not set, it
4442+ will enclose {string} double quotes and double all double
4443+ quotes within {string}.
4444+ For other systems, it will enclose {string} in single quotes
4445+ and replace all "'" with "'\''".
4446+ Example: >
4447+ :echo shellescape('c:\program files\vim')
4448+< results in:
4449+ "c:\program files\vim" ~
4450+ Example usage: >
4451+ :call system("chmod +x -- " . shellescape(expand("%")))
4452+
4453+
44374454 simplify({filename}) *simplify()*
44384455 Simplify the file name as much as possible without changing
44394456 the meaning. Shortcuts (on MS-Windows) or symbolic links (on
diff -r fa9ee618000f -r 656853d9c014 src/eval.c
--- a/src/eval.c Tue Sep 26 11:48:34 2006 +0000
+++ b/src/eval.c Tue Oct 03 12:44:42 2006 +0000
@@ -622,6 +622,7 @@
622622 static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
623623 static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
624624 static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
625+static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
625626 static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
626627 static void f_sort __ARGS((typval_T *argvars, typval_T *rettv));
627628 static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7146,6 +7147,7 @@
71467147 {"setreg", 2, 3, f_setreg},
71477148 {"settabwinvar", 4, 4, f_settabwinvar},
71487149 {"setwinvar", 3, 3, f_setwinvar},
7150+ {"shellescape", 1, 1, f_shellescape},
71497151 {"simplify", 1, 1, f_simplify},
71507152 {"sort", 1, 2, f_sort},
71517153 {"soundfold", 1, 1, f_soundfold},
@@ -14605,6 +14607,18 @@
1460514607 }
1460614608
1460714609 /*
14610+ * "shellescape({string})" function
14611+ */
14612+ static void
14613+f_shellescape(argvars, rettv)
14614+ typval_T *argvars;
14615+ typval_T *rettv;
14616+{
14617+ rettv->vval.v_string = vim_strsave_shellescape(get_tv_string(&argvars[0]));
14618+ rettv->v_type = VAR_STRING;
14619+}
14620+
14621+/*
1460814622 * "simplify()" function
1460914623 */
1461014624 static void
diff -r fa9ee618000f -r 656853d9c014 src/misc2.c
--- a/src/misc2.c Tue Sep 26 11:48:34 2006 +0000
+++ b/src/misc2.c Tue Oct 03 12:44:42 2006 +0000
@@ -1229,6 +1229,94 @@
12291229 return escaped_string;
12301230 }
12311231
1232+#if defined(FEAT_EVAL) || defined(PROTO)
1233+/*
1234+ * Escape "string" for use as a shell argument with system().
1235+ * This uses single quotes, except when we know we need to use double qoutes
1236+ * (MS-DOS and MS-Windows without 'shellslash' set).
1237+ * Returns the result in allocated memory, NULL if we have run out.
1238+ */
1239+ char_u *
1240+vim_strsave_shellescape(string)
1241+ char_u *string;
1242+{
1243+ unsigned length;
1244+ char_u *p;
1245+ char_u *d;
1246+ char_u *escaped_string;
1247+
1248+ /* First count the number of extra bytes required. */
1249+ length = STRLEN(string) + 3; /* two quotes and the trailing NUL */
1250+ for (p = string; *p != NUL; mb_ptr_adv(p))
1251+ {
1252+# if defined(WIN32) || defined(WIN16) || defined(DOS)
1253+ if (!p_ssl)
1254+ {
1255+ if (*p == '"')
1256+ ++length; /* " -> "" */
1257+ }
1258+ else
1259+# endif
1260+ if (*p == '\'')
1261+ length += 3; /* ' => '\'' */
1262+ }
1263+
1264+ /* Allocate memory for the result and fill it. */
1265+ escaped_string = alloc(length);
1266+ if (escaped_string != NULL)
1267+ {
1268+ d = escaped_string;
1269+
1270+ /* add opening quote */
1271+# if defined(WIN32) || defined(WIN16) || defined(DOS)
1272+ if (!p_ssl)
1273+ *d++ = '"';
1274+ else
1275+# endif
1276+ *d++ = '\'';
1277+
1278+ for (p = string; *p != NUL; )
1279+ {
1280+# if defined(WIN32) || defined(WIN16) || defined(DOS)
1281+ if (!p_ssl)
1282+ {
1283+ if (*p == '"')
1284+ {
1285+ *d++ = '"';
1286+ *d++ = '"';
1287+ ++p;
1288+ continue;
1289+ }
1290+ }
1291+ else
1292+# endif
1293+ if (*p == '\'')
1294+ {
1295+ *d++='\'';
1296+ *d++='\\';
1297+ *d++='\'';
1298+ *d++='\'';
1299+ ++p;
1300+ continue;
1301+ }
1302+
1303+ MB_COPY_CHAR(p, d);
1304+ }
1305+
1306+ /* add terminating quote and finish with a NUL */
1307+# if defined(WIN32) || defined(WIN16) || defined(DOS)
1308+ if (!p_ssl)
1309+ *d++ = '"';
1310+ else
1311+# endif
1312+ *d++ = '\'';
1313+ *d = NUL;
1314+ }
1315+
1316+ return escaped_string;
1317+}
1318+#endif
1319+
12321320 /*
12331321 * Like vim_strsave(), but make all characters uppercase.
12341322 * This uses ASCII lower-to-upper case translation, language independent.
diff -r fa9ee618000f -r 656853d9c014 src/proto/misc2.pro
--- a/src/proto/misc2.pro Tue Sep 26 11:48:34 2006 +0000
+++ b/src/proto/misc2.pro Tue Oct 03 12:44:42 2006 +0000
@@ -29,6 +29,7 @@
2929 extern char_u *vim_strnsave __ARGS((char_u *string, int len));
3030 extern char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
3131 extern char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl));
32+extern char_u *vim_strsave_shellescape __ARGS((char_u *string));
3233 extern char_u *vim_strsave_up __ARGS((char_u *string));
3334 extern char_u *vim_strnsave_up __ARGS((char_u *string, int len));
3435 extern void vim_strup __ARGS((char_u *p));
diff -r fa9ee618000f -r 656853d9c014 src/version.c
--- a/src/version.c Tue Sep 26 11:48:34 2006 +0000
+++ b/src/version.c Tue Oct 03 12:44:42 2006 +0000
@@ -667,6 +667,8 @@
667667 static int included_patches[] =
668668 { /* Add new patch number below this line */
669669 /**/
670+ 111,
671+/**/
670672 110,
671673 /**/
672674 109,
Show on old repository browser