Mercurial > vim
diff src/ex_getln.c @ 1586:fe7db192c7cc v7.1.299
updated for version 7.1-299
author | vimboss |
---|---|
date | Wed, 28 May 2008 14:49:58 +0000 |
parents | 50e0337c25ca |
children | 3a6ba07b3b9f |
line wrap: on
line diff
--- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -3656,22 +3656,7 @@ ExpandEscape(xp, str, numfiles, files, o #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, o } /* + * 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