0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.1-299

This commit is contained in:
Bram Moolenaar
2008-05-28 14:49:58 +00:00
parent 7a98925587
commit aebaf89fd4
7 changed files with 70 additions and 25 deletions

View File

@@ -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]);
@@ -3709,6 +3694,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.
*/