mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
updated for version 7.2b-005
This commit is contained in:
25
src/misc2.c
25
src/misc2.c
@@ -1262,7 +1262,9 @@ vim_strsave_escaped_ext(string, esc_chars, cc, bsl)
|
|||||||
* Escape "string" for use as a shell argument with system().
|
* Escape "string" for use as a shell argument with system().
|
||||||
* This uses single quotes, except when we know we need to use double qoutes
|
* This uses single quotes, except when we know we need to use double qoutes
|
||||||
* (MS-DOS and MS-Windows without 'shellslash' set).
|
* (MS-DOS and MS-Windows without 'shellslash' set).
|
||||||
* Also replace "%", "#" and things like "<cfile>" when "do_special" is TRUE.
|
* Escape a newline, depending on the 'shell' option.
|
||||||
|
* 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.
|
* Returns the result in allocated memory, NULL if we have run out.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
@@ -1275,6 +1277,13 @@ vim_strsave_shellescape(string, do_special)
|
|||||||
char_u *d;
|
char_u *d;
|
||||||
char_u *escaped_string;
|
char_u *escaped_string;
|
||||||
int l;
|
int l;
|
||||||
|
int csh_like;
|
||||||
|
|
||||||
|
/* Only csh and similar shells expand '!' within single quotes. For sh and
|
||||||
|
* the like we must not put a backslash before it, it will be taken
|
||||||
|
* literally. If do_special is set the '!' will be escaped twice.
|
||||||
|
* Csh also needs to have "\n" escaped twice when do_special is set. */
|
||||||
|
csh_like = (strstr((char *)gettail(p_sh), "csh") != NULL);
|
||||||
|
|
||||||
/* First count the number of extra bytes required. */
|
/* First count the number of extra bytes required. */
|
||||||
length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */
|
length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */
|
||||||
@@ -1290,6 +1299,12 @@ vim_strsave_shellescape(string, do_special)
|
|||||||
# endif
|
# endif
|
||||||
if (*p == '\'')
|
if (*p == '\'')
|
||||||
length += 3; /* ' => '\'' */
|
length += 3; /* ' => '\'' */
|
||||||
|
if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
|
||||||
|
{
|
||||||
|
++length; /* insert backslash */
|
||||||
|
if (csh_like && do_special)
|
||||||
|
++length; /* insert backslash */
|
||||||
|
}
|
||||||
if (do_special && find_cmdline_var(p, &l) >= 0)
|
if (do_special && find_cmdline_var(p, &l) >= 0)
|
||||||
{
|
{
|
||||||
++length; /* insert backslash */
|
++length; /* insert backslash */
|
||||||
@@ -1335,6 +1350,14 @@ vim_strsave_shellescape(string, do_special)
|
|||||||
++p;
|
++p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
|
||||||
|
{
|
||||||
|
*d++ = '\\';
|
||||||
|
if (csh_like && do_special)
|
||||||
|
*d++ = '\\';
|
||||||
|
*d++ = *p++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (do_special && find_cmdline_var(p, &l) >= 0)
|
if (do_special && find_cmdline_var(p, &l) >= 0)
|
||||||
{
|
{
|
||||||
*d++ = '\\'; /* insert backslash */
|
*d++ = '\\'; /* insert backslash */
|
||||||
|
@@ -676,6 +676,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
5,
|
||||||
/**/
|
/**/
|
||||||
4,
|
4,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user