summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2008-07-04 09:44:11 +0000
committerBram Moolenaar <Bram@vim.org>2008-07-04 09:44:11 +0000
commit05bb95391f2dc99574650d3ce5932c035a46bded (patch)
treeada4aa08aa92635e97a36c7997e1dc9bf5b465d3 /src
parent47b46d7c470dab0823e03ec671b2bde543456c73 (diff)
downloadvim-git-05bb95391f2dc99574650d3ce5932c035a46bded.tar.gz
updated for version 7.2a-013v7.2a.013
Diffstat (limited to 'src')
-rw-r--r--src/eval.c31
-rw-r--r--src/ex_docmd.c93
-rw-r--r--src/misc2.c28
-rw-r--r--src/proto/ex_docmd.pro1
-rw-r--r--src/proto/misc2.pro2
-rw-r--r--src/version.c2
6 files changed, 103 insertions, 54 deletions
diff --git a/src/eval.c b/src/eval.c
index e4024986e..a41411a25 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -462,6 +462,7 @@ static char_u *deref_func_name __ARGS((char_u *name, int *lenp));
static int get_func_tv __ARGS((char_u *name, int len, typval_T *rettv, char_u **arg, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, dict_T *selfdict));
static int call_func __ARGS((char_u *name, int len, typval_T *rettv, int argcount, typval_T *argvars, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate, dict_T *selfdict));
static void emsg_funcname __ARGS((char *ermsg, char_u *name));
+static int non_zero_arg __ARGS((typval_T *argvars));
#ifdef FEAT_FLOAT
static void f_abs __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7611,7 +7612,7 @@ static struct fst
{"setreg", 2, 3, f_setreg},
{"settabwinvar", 4, 4, f_settabwinvar},
{"setwinvar", 3, 3, f_setwinvar},
- {"shellescape", 1, 1, f_shellescape},
+ {"shellescape", 1, 2, f_shellescape},
{"simplify", 1, 1, f_simplify},
#ifdef FEAT_FLOAT
{"sin", 1, 1, f_sin},
@@ -8094,6 +8095,20 @@ emsg_funcname(ermsg, name)
vim_free(p);
}
+/*
+ * Return TRUE for a non-zero Number and a non-empty String.
+ */
+ static int
+non_zero_arg(argvars)
+ typval_T *argvars;
+{
+ return ((argvars[0].v_type == VAR_NUMBER
+ && argvars[0].vval.v_number != 0)
+ || (argvars[0].v_type == VAR_STRING
+ && argvars[0].vval.v_string != NULL
+ && *argvars[0].vval.v_string != NUL));
+}
+
/*********************************************
* Implementation of the built-in functions
*/
@@ -13480,10 +13495,9 @@ f_mode(argvars, rettv)
buf[1] = 'o';
}
- /* A zero number or empty string argument: return only major mode. */
- if (!(argvars[0].v_type == VAR_NUMBER && argvars[0].vval.v_number != 0)
- && !(argvars[0].v_type == VAR_STRING
- && *get_tv_string(&argvars[0]) != NUL))
+ /* Clear out the minor mode when the argument is not a non-zero number or
+ * non-empty string. */
+ if (!non_zero_arg(&argvars[0]))
buf[1] = NUL;
rettv->vval.v_string = vim_strsave(buf);
@@ -15684,7 +15698,8 @@ f_shellescape(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
- rettv->vval.v_string = vim_strsave_shellescape(get_tv_string(&argvars[0]));
+ rettv->vval.v_string = vim_strsave_shellescape(
+ get_tv_string(&argvars[0]), non_zero_arg(&argvars[1]));
rettv->v_type = VAR_STRING;
}
@@ -17273,9 +17288,7 @@ f_visualmode(argvars, rettv)
rettv->vval.v_string = vim_strsave(str);
/* A non-zero number or non-empty string argument: reset mode. */
- if ((argvars[0].v_type == VAR_NUMBER && argvars[0].vval.v_number != 0)
- || (argvars[0].v_type == VAR_STRING
- && *get_tv_string(&argvars[0]) != NUL))
+ if (non_zero_arg(&argvars[0]))
curbuf->b_visual_mode_eval = NUL;
#else
rettv->vval.v_number = 0; /* return anything, it won't work anyway */
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 460fc2a39..83cffc1fc 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7059,8 +7059,8 @@ ex_splitview(eap)
# ifdef FEAT_QUICKFIX
/* A ":split" in the quickfix window works like ":new". Don't want two
- * quickfix windows. */
- if (bt_quickfix(curbuf))
+ * quickfix windows. But it's OK when doing ":tab split". */
+ if (bt_quickfix(curbuf) && cmdmod.tab == 0)
{
if (eap->cmdidx == CMD_split)
eap->cmdidx = CMD_new;
@@ -9321,6 +9321,58 @@ ex_tag_cmd(eap, name)
}
/*
+ * Check "str" for starting with a special cmdline variable.
+ * If found return one of the SPEC_ values and set "*usedlen" to the length of
+ * the variable. Otherwise return -1 and "*usedlen" is unchanged.
+ */
+ int
+find_cmdline_var(src, usedlen)
+ char_u *src;
+ int *usedlen;
+{
+ int len;
+ int i;
+ static char *(spec_str[]) = {
+ "%",
+#define SPEC_PERC 0
+ "#",
+#define SPEC_HASH 1
+ "<cword>", /* cursor word */
+#define SPEC_CWORD 2
+ "<cWORD>", /* cursor WORD */
+#define SPEC_CCWORD 3
+ "<cfile>", /* cursor path name */
+#define SPEC_CFILE 4
+ "<sfile>", /* ":so" file name */
+#define SPEC_SFILE 5
+#ifdef FEAT_AUTOCMD
+ "<afile>", /* autocommand file name */
+# define SPEC_AFILE 6
+ "<abuf>", /* autocommand buffer number */
+# define SPEC_ABUF 7
+ "<amatch>", /* autocommand match name */
+# define SPEC_AMATCH 8
+#endif
+#ifdef FEAT_CLIENTSERVER
+ "<client>"
+# define SPEC_CLIENT 9
+#endif
+ };
+#define SPEC_COUNT (sizeof(spec_str) / sizeof(char *))
+
+ for (i = 0; i < SPEC_COUNT; ++i)
+ {
+ len = (int)STRLEN(spec_str[i]);
+ if (STRNCMP(src, spec_str[i], len) == 0)
+ {
+ *usedlen = len;
+ return i;
+ }
+ }
+ return -1;
+}
+
+/*
* Evaluate cmdline variables.
*
* change '%' to curbuf->b_ffname
@@ -9360,34 +9412,6 @@ eval_vars(src, srcstart, usedlen, lnump, errormsg, escaped)
#ifdef FEAT_MODIFY_FNAME
int skip_mod = FALSE;
#endif
- static char *(spec_str[]) =
- {
- "%",
-#define SPEC_PERC 0
- "#",
-#define SPEC_HASH 1
- "<cword>", /* cursor word */
-#define SPEC_CWORD 2
- "<cWORD>", /* cursor WORD */
-#define SPEC_CCWORD 3
- "<cfile>", /* cursor path name */
-#define SPEC_CFILE 4
- "<sfile>", /* ":so" file name */
-#define SPEC_SFILE 5
-#ifdef FEAT_AUTOCMD
- "<afile>", /* autocommand file name */
-# define SPEC_AFILE 6
- "<abuf>", /* autocommand buffer number */
-# define SPEC_ABUF 7
- "<amatch>", /* autocommand match name */
-# define SPEC_AMATCH 8
-#endif
-#ifdef FEAT_CLIENTSERVER
- "<client>"
-# define SPEC_CLIENT 9
-#endif
- };
-#define SPEC_COUNT (sizeof(spec_str) / sizeof(char *))
#if defined(FEAT_AUTOCMD) || defined(FEAT_CLIENTSERVER)
char_u strbuf[30];
@@ -9400,13 +9424,8 @@ eval_vars(src, srcstart, usedlen, lnump, errormsg, escaped)
/*
* Check if there is something to do.
*/
- for (spec_idx = 0; spec_idx < SPEC_COUNT; ++spec_idx)
- {
- *usedlen = (int)STRLEN(spec_str[spec_idx]);
- if (STRNCMP(src, spec_str[spec_idx], *usedlen) == 0)
- break;
- }
- if (spec_idx == SPEC_COUNT) /* no match */
+ spec_idx = find_cmdline_var(src, usedlen);
+ if (spec_idx < 0) /* no match */
{
*usedlen = 1;
return NULL;
diff --git a/src/misc2.c b/src/misc2.c
index 62a8cda14..04f038b9a 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1262,16 +1262,19 @@ vim_strsave_escaped_ext(string, esc_chars, cc, bsl)
* 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).
+ * Also replace "%", "#" and things like "<cfile>" when "do_special" is TRUE.
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
-vim_strsave_shellescape(string)
+vim_strsave_shellescape(string, do_special)
char_u *string;
+ int do_special;
{
unsigned length;
char_u *p;
char_u *d;
char_u *escaped_string;
+ int l;
/* First count the number of extra bytes required. */
length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */
@@ -1287,6 +1290,11 @@ vim_strsave_shellescape(string)
# endif
if (*p == '\'')
length += 3; /* ' => '\'' */
+ if (do_special && find_cmdline_var(p, &l) >= 0)
+ {
+ ++length; /* insert backslash */
+ p += l - 1;
+ }
}
/* Allocate memory for the result and fill it. */
@@ -1320,13 +1328,19 @@ vim_strsave_shellescape(string)
# endif
if (*p == '\'')
{
- *d++='\'';
- *d++='\\';
- *d++='\'';
- *d++='\'';
+ *d++ = '\'';
+ *d++ = '\\';
+ *d++ = '\'';
+ *d++ = '\'';
++p;
continue;
}
+ if (do_special && find_cmdline_var(p, &l) >= 0)
+ {
+ *d++ = '\\'; /* insert backslash */
+ while (--l >= 0) /* copy the var */
+ *d++ = *p++;
+ }
MB_COPY_CHAR(p, d);
}
@@ -2776,7 +2790,7 @@ get_special_key_code(name)
return 0;
}
-#ifdef FEAT_CMDL_COMPL
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
char_u *
get_key_name(i)
int i;
@@ -2787,7 +2801,7 @@ get_key_name(i)
}
#endif
-#ifdef FEAT_MOUSE
+#if defined(FEAT_MOUSE) || defined(PROTO)
/*
* Look up the given mouse code to return the relevant information in the other
* arguments. Return which button is down or was released.
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
index 5835db096..e267acfd8 100644
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -46,6 +46,7 @@ int vim_mkdir_emsg __ARGS((char_u *name, int prot));
FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode));
void update_topline_cursor __ARGS((void));
void exec_normal_cmd __ARGS((char_u *cmd, int remap, int silent));
+int find_cmdline_var __ARGS((char_u *src, int *usedlen));
char_u *eval_vars __ARGS((char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char_u **errormsg, int *escaped));
char_u *expand_sfile __ARGS((char_u *arg));
int put_eol __ARGS((FILE *fd));
diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro
index ce5632ee0..397a09a25 100644
--- a/src/proto/misc2.pro
+++ b/src/proto/misc2.pro
@@ -29,7 +29,7 @@ char_u *vim_strsave __ARGS((char_u *string));
char_u *vim_strnsave __ARGS((char_u *string, int len));
char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl));
-char_u *vim_strsave_shellescape __ARGS((char_u *string));
+char_u *vim_strsave_shellescape __ARGS((char_u *string, int do_special));
char_u *vim_strsave_up __ARGS((char_u *string));
char_u *vim_strnsave_up __ARGS((char_u *string, int len));
void vim_strup __ARGS((char_u *p));
diff --git a/src/version.c b/src/version.c
index f46ebda2c..49f41f50e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -677,6 +677,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 13,
+/**/
12,
/**/
11,