summaryrefslogtreecommitdiff
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-03 14:29:14 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-03 14:29:14 +0200
commit398ee7326b78b892a5c8380dfe3f2521a64b4fa7 (patch)
tree8384cc670e56f2178474c5062b85d0c97b1cc87b /src/ex_cmds2.c
parent7c9aec4ac86ccc455c0859d9393253141e3f77b6 (diff)
downloadvim-git-398ee7326b78b892a5c8380dfe3f2521a64b4fa7.tar.gz
patch 8.0.0847: :argadd without argument can't handle space in file namev8.0.0847
Problem: :argadd without argument can't handle space in file name. (Harm te Hennepe) Solution: Escape the space. (Yasuhiro Matsumoto, closes #1917)
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 687bbaecf..381c5d1c2 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2320,8 +2320,8 @@ do_one_arg(char_u *str)
* Separate the arguments in "str" and return a list of pointers in the
* growarray "gap".
*/
- int
-get_arglist(garray_T *gap, char_u *str)
+ static int
+get_arglist(garray_T *gap, char_u *str, int escaped)
{
ga_init2(gap, (int)sizeof(char_u *), 20);
while (*str != NUL)
@@ -2333,6 +2333,10 @@ get_arglist(garray_T *gap, char_u *str)
}
((char_u **)gap->ga_data)[gap->ga_len++] = str;
+ /* If str is escaped, don't handle backslashes or spaces */
+ if (!escaped)
+ return OK;
+
/* Isolate one argument, change it in-place, put a NUL after it. */
str = do_one_arg(str);
}
@@ -2355,7 +2359,7 @@ get_arglist_exp(
garray_T ga;
int i;
- if (get_arglist(&ga, str) == FAIL)
+ if (get_arglist(&ga, str, TRUE) == FAIL)
return FAIL;
if (wig == TRUE)
i = expand_wildcards(ga.ga_len, (char_u **)ga.ga_data,
@@ -2401,6 +2405,7 @@ do_arglist(
char_u *p;
int match;
#endif
+ int arg_escaped = TRUE;
/*
* Set default argument for ":argadd" command.
@@ -2410,12 +2415,13 @@ do_arglist(
if (curbuf->b_ffname == NULL)
return FAIL;
str = curbuf->b_fname;
+ arg_escaped = FALSE;
}
/*
* Collect all file name arguments in "new_ga".
*/
- if (get_arglist(&new_ga, str) == FAIL)
+ if (get_arglist(&new_ga, str, arg_escaped) == FAIL)
return FAIL;
#ifdef FEAT_LISTCMDS