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
This commit is contained in:
oni-link
2014-04-12 23:04:49 +02:00
committed by Thiago de Arruda
parent 644ccdafe0
commit a881273dad
8 changed files with 95 additions and 14 deletions

View File

@@ -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++ = '\\';