1
0
forked from aniani/vim

updated for version 7.0-111

This commit is contained in:
Bram Moolenaar
2006-10-03 12:44:42 +00:00
parent 89f3727bd9
commit 60a495f02e
6 changed files with 138 additions and 8 deletions

View File

@@ -622,6 +622,7 @@ static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv));
static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
static void f_sort __ARGS((typval_T *argvars, typval_T *rettv));
static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7146,6 +7147,7 @@ static struct fst
{"setreg", 2, 3, f_setreg},
{"settabwinvar", 4, 4, f_settabwinvar},
{"setwinvar", 3, 3, f_setwinvar},
{"shellescape", 1, 1, f_shellescape},
{"simplify", 1, 1, f_simplify},
{"sort", 1, 2, f_sort},
{"soundfold", 1, 1, f_soundfold},
@@ -14604,6 +14606,18 @@ setwinvar(argvars, rettv, off)
}
}
/*
* "shellescape({string})" function
*/
static void
f_shellescape(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
rettv->vval.v_string = vim_strsave_shellescape(get_tv_string(&argvars[0]));
rettv->v_type = VAR_STRING;
}
/*
* "simplify()" function
*/

View File

@@ -1229,6 +1229,94 @@ vim_strsave_escaped_ext(string, esc_chars, cc, bsl)
return escaped_string;
}
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Escape "string" for use as a shell argument with system().
* This uses single quotes, except when we know we need to use double qoutes
* (MS-DOS and MS-Windows without 'shellslash' set).
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
vim_strsave_shellescape(string)
char_u *string;
{
unsigned length;
char_u *p;
char_u *d;
char_u *escaped_string;
/* First count the number of extra bytes required. */
length = STRLEN(string) + 3; /* two quotes and the trailing NUL */
for (p = string; *p != NUL; mb_ptr_adv(p))
{
# if defined(WIN32) || defined(WIN16) || defined(DOS)
if (!p_ssl)
{
if (*p == '"')
++length; /* " -> "" */
}
else
# endif
if (*p == '\'')
length += 3; /* ' => '\'' */
}
/* Allocate memory for the result and fill it. */
escaped_string = alloc(length);
if (escaped_string != NULL)
{
d = escaped_string;
/* add opening quote */
# if defined(WIN32) || defined(WIN16) || defined(DOS)
if (!p_ssl)
*d++ = '"';
else
# endif
*d++ = '\'';
for (p = string; *p != NUL; )
{
# if defined(WIN32) || defined(WIN16) || defined(DOS)
if (!p_ssl)
{
if (*p == '"')
{
*d++ = '"';
*d++ = '"';
++p;
continue;
}
}
else
# endif
if (*p == '\'')
{
*d++='\'';
*d++='\\';
*d++='\'';
*d++='\'';
++p;
continue;
}
MB_COPY_CHAR(p, d);
}
/* add terminating quote and finish with a NUL */
# if defined(WIN32) || defined(WIN16) || defined(DOS)
if (!p_ssl)
*d++ = '"';
else
# endif
*d++ = '\'';
*d = NUL;
}
return escaped_string;
}
#endif
/*
* Like vim_strsave(), but make all characters uppercase.
* This uses ASCII lower-to-upper case translation, language independent.

View File

@@ -29,6 +29,7 @@ extern char_u *vim_strsave __ARGS((char_u *string));
extern char_u *vim_strnsave __ARGS((char_u *string, int len));
extern char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
extern char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl));
extern char_u *vim_strsave_shellescape __ARGS((char_u *string));
extern char_u *vim_strsave_up __ARGS((char_u *string));
extern char_u *vim_strnsave_up __ARGS((char_u *string, int len));
extern void vim_strup __ARGS((char_u *p));

View File

@@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
111,
/**/
110,
/**/