summaryrefslogtreecommitdiffstats
path: root/src/ex_getln.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-10-17 17:20:23 +0100
committerBram Moolenaar <Bram@vim.org>2021-10-17 17:20:23 +0100
commit21c1a0c2f10575dbb72fa873d33f0c1f6e170aa7 (patch)
treeab2a99240a83610e85c5d2632553266406d983ef /src/ex_getln.c
parent34a364877f0c726cdc0779e6999fded9ba959ebe (diff)
patch 8.2.3530: ":buf \{a}" fails while ":edit \{a}" worksv8.2.3530
Problem: ":buf \{a}" fails while ":edit \{a}" works. Solution: Unescape "\{". (closes #8917)
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r--src/ex_getln.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 07eac90863..258548ed8a 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3894,27 +3894,32 @@ ccheck_abbr(int c)
}
/*
- * 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.
+ * Escape special characters in "fname", depending on "what":
+ * VSE_NONE: for when used as a file name argument after a Vim command.
+ * VSE_SHELL: for a shell command.
+ * VSE_BUFFER: for the ":buffer" command.
* Returns the result in allocated memory.
*/
char_u *
-vim_strsave_fnameescape(char_u *fname, int shell UNUSED)
+vim_strsave_fnameescape(char_u *fname, int what)
{
char_u *p;
#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)
+ // Don't escape '[', '{' and '!' if they are in 'isfname' and for the
+ // ":buffer" command.
+ for (p = what == VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS;
+ *p != NUL; ++p)
if ((*p != '[' && *p != '{' && *p != '!') || !vim_isfilec(*p))
buf[j++] = *p;
buf[j] = NUL;
p = vim_strsave_escaped(fname, buf);
#else
- p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
- if (shell && csh_like_shell() && p != NULL)
+ p = vim_strsave_escaped(fname, what == VSE_SHELL ? SHELL_ESC_CHARS
+ : what == VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS);
+ if (what == VSE_SHELL && csh_like_shell() && p != NULL)
{
char_u *s;