From 21c1a0c2f10575dbb72fa873d33f0c1f6e170aa7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Oct 2021 17:20:23 +0100 Subject: patch 8.2.3530: ":buf \{a}" fails while ":edit \{a}" works Problem: ":buf \{a}" fails while ":edit \{a}" works. Solution: Unescape "\{". (closes #8917) --- src/ex_getln.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/ex_getln.c') diff --git a/src/ex_getln.c b/src/ex_getln.c index 07eac9086..258548ed8 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; -- cgit v1.2.1