diff options
author | oni-link <knil.ino@gmail.com> | 2014-04-12 23:04:49 +0200 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-14 09:54:40 -0300 |
commit | a881273dad5eb5d1f5efa8da79704c9cf9abf0e0 (patch) | |
tree | 4c4fc1aeb736aae65758d0cce609f719c7042d37 /src/misc2.c | |
parent | 644ccdafe01df76c47f2a6c74a4a55f64602e3db (diff) | |
download | rneovim-a881273dad5eb5d1f5efa8da79704c9cf9abf0e0.tar.gz rneovim-a881273dad5eb5d1f5efa8da79704c9cf9abf0e0.tar.bz2 rneovim-a881273dad5eb5d1f5efa8da79704c9cf9abf0e0.zip |
vim-patch:7.4.191
Problem: Escaping a file name for shell commands can't be done without a
function.
Solution: Add the :S file name modifier.
https://code.google.com/p/vim/source/detail?r=40f18a1c1592c8b4047f6f2a413557f48a99c55f
Diffstat (limited to 'src/misc2.c')
-rw-r--r-- | src/misc2.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/misc2.c b/src/misc2.c index 997fafc7ff..7b471a5811 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -691,11 +691,12 @@ int csh_like_shell(void) * This uses single quotes, except when we know we need to use double quotes * (MS-DOS and MS-Windows without 'shellslash' set). * Escape a newline, depending on the 'shell' option. - * When "do_special" is TRUE also replace "!", "%", "#" and things starting + * When "do_special" is true also replace "!", "%", "#" and things starting * with "<" like "<cfile>". - * Returns the result in allocated memory, NULL if we have run out. + * When "do_newline" is false do not escape newline unless it is csh shell. + * Returns the result in allocated memory. */ -char_u *vim_strsave_shellescape(char_u *string, int do_special) +char_u *vim_strsave_shellescape(char_u *string, bool do_special, bool do_newline) { unsigned length; char_u *p; @@ -715,7 +716,8 @@ char_u *vim_strsave_shellescape(char_u *string, int do_special) for (p = string; *p != NUL; mb_ptr_adv(p)) { if (*p == '\'') length += 3; /* ' => '\'' */ - if (*p == '\n' || (*p == '!' && (csh_like || do_special))) { + if ((*p == '\n' && (csh_like || do_newline)) + || (*p == '!' && (csh_like || do_special))) { ++length; /* insert backslash */ if (csh_like && do_special) ++length; /* insert backslash */ @@ -742,7 +744,8 @@ char_u *vim_strsave_shellescape(char_u *string, int do_special) ++p; continue; } - if (*p == '\n' || (*p == '!' && (csh_like || do_special))) { + if ((*p == '\n' && (csh_like || do_newline)) + || (*p == '!' && (csh_like || do_special))) { *d++ = '\\'; if (csh_like && do_special) *d++ = '\\'; |