summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2008-05-28 14:49:58 +0000
committerBram Moolenaar <Bram@vim.org>2008-05-28 14:49:58 +0000
commitaebaf89fd4626e52dee4a6bb4cdec8dbf2556bd2 (patch)
tree2afe10fdf37a9f22f6f948a7ca56c35cbdc01bb6 /src
parent7a9892558776b37077b4a889364cef1c7902cba2 (diff)
downloadvim-git-aebaf89fd4626e52dee4a6bb4cdec8dbf2556bd2.tar.gz
updated for version 7.1-299v7.1.299
Diffstat (limited to 'src')
-rw-r--r--src/eval.c15
-rw-r--r--src/ex_getln.c42
-rw-r--r--src/proto/ex_getln.pro1
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h6
5 files changed, 47 insertions, 19 deletions
diff --git a/src/eval.c b/src/eval.c
index e008df24a..34263544c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -507,6 +507,7 @@ static void f_filewritable __ARGS((typval_T *argvars, typval_T *rettv));
static void f_filter __ARGS((typval_T *argvars, typval_T *rettv));
static void f_finddir __ARGS((typval_T *argvars, typval_T *rettv));
static void f_findfile __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_fnameescape __ARGS((typval_T *argvars, typval_T *rettv));
static void f_fnamemodify __ARGS((typval_T *argvars, typval_T *rettv));
static void f_foldclosed __ARGS((typval_T *argvars, typval_T *rettv));
static void f_foldclosedend __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7107,6 +7108,7 @@ static struct fst
{"filter", 2, 2, f_filter},
{"finddir", 1, 3, f_finddir},
{"findfile", 1, 3, f_findfile},
+ {"fnameescape", 1, 1, f_fnameescape},
{"fnamemodify", 2, 2, f_fnamemodify},
{"foldclosed", 1, 1, f_foldclosed},
{"foldclosedend", 1, 1, f_foldclosedend},
@@ -9465,6 +9467,19 @@ f_findfile(argvars, rettv)
}
/*
+ * "fnameescape({string})" function
+ */
+ static void
+f_fnameescape(argvars, rettv)
+ typval_T *argvars;
+ typval_T *rettv;
+{
+ rettv->vval.v_string = vim_strsave_fnameescape(
+ get_tv_string(&argvars[0]), FALSE);
+ rettv->v_type = VAR_STRING;
+}
+
+/*
* "fnamemodify({fname}, {mods})" function
*/
static void
diff --git a/src/ex_getln.c b/src/ex_getln.c
index e7f8c1b1c..b575e2998 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3656,22 +3656,7 @@ ExpandEscape(xp, str, numfiles, files, options)
#endif
}
}
-#ifdef BACKSLASH_IN_FILENAME
- {
- char_u buf[20];
- int j = 0;
-
- /* Don't escape '[' and '{' if they are in 'isfname'. */
- for (p = PATH_ESC_CHARS; *p != NUL; ++p)
- if ((*p != '[' && *p != '{') || !vim_isfilec(*p))
- buf[j++] = *p;
- buf[j] = NUL;
- p = vim_strsave_escaped(files[i], buf);
- }
-#else
- p = vim_strsave_escaped(files[i],
- xp->xp_shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
-#endif
+ p = vim_strsave_fnameescape(files[i], xp->xp_shell);
if (p != NULL)
{
vim_free(files[i]);
@@ -3710,6 +3695,31 @@ ExpandEscape(xp, str, numfiles, files, options)
}
/*
+ * Escape special characters in "fname" for when used as a file name argument
+ * after a Vim command, or, when "shell" is non-zero, a shell command.
+ * Returns the result in allocated memory.
+ */
+ char_u *
+vim_strsave_fnameescape(fname, shell)
+ char_u *fname;
+ int shell;
+{
+#ifdef BACKSLASH_IN_FILENAME
+ char_u buf[20];
+ int j = 0;
+
+ /* Don't escape '[' and '{' if they are in 'isfname'. */
+ for (p = PATH_ESC_CHARS; *p != NUL; ++p)
+ if ((*p != '[' && *p != '{') || !vim_isfilec(*p))
+ buf[j++] = *p;
+ buf[j] = NUL;
+ return vim_strsave_escaped(fname, buf);
+#else
+ return vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
+#endif
+}
+
+/*
* Put a backslash before the file name in "pp", which is in allocated memory.
*/
static void
diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro
index f5feb201f..b4a501814 100644
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -24,6 +24,7 @@ char_u *ExpandOne __ARGS((expand_T *xp, char_u *str, char_u *orig, int options,
void ExpandInit __ARGS((expand_T *xp));
void ExpandCleanup __ARGS((expand_T *xp));
void ExpandEscape __ARGS((expand_T *xp, char_u *str, int numfiles, char_u **files, int options));
+char_u *vim_strsave_fnameescape __ARGS((char_u *fname, int shell));
void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files));
char_u *sm_gettail __ARGS((char_u *s));
char_u *addstar __ARGS((char_u *fname, int len, int context));
diff --git a/src/version.c b/src/version.c
index 45b003e1d..7b7bdcd03 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 299,
+/**/
298,
/**/
297,
diff --git a/src/vim.h b/src/vim.h
index d93bec154..71dd3ae2d 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -336,10 +336,10 @@
# endif
#endif
#ifdef BACKSLASH_IN_FILENAME
-# define PATH_ESC_CHARS ((char_u *)" \t*?[{`%#")
+# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`%#'\"|!<")
#else
-# define PATH_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|")
-# define SHELL_ESC_CHARS ((char_u *)" \t*?[{`$\\%#'\"|<>();&!")
+# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
+# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
#endif
#define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */