diff options
author | Bram Moolenaar <Bram@vim.org> | 2008-05-28 14:49:58 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2008-05-28 14:49:58 +0000 |
commit | aebaf89fd4626e52dee4a6bb4cdec8dbf2556bd2 (patch) | |
tree | 2afe10fdf37a9f22f6f948a7ca56c35cbdc01bb6 /src/ex_getln.c | |
parent | 7a9892558776b37077b4a889364cef1c7902cba2 (diff) | |
download | vim-git-aebaf89fd4626e52dee4a6bb4cdec8dbf2556bd2.tar.gz |
updated for version 7.1-299v7.1.299
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 42 |
1 files changed, 26 insertions, 16 deletions
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 |