]> granicus.if.org Git - vim/commitdiff
patch 8.0.0847: :argadd without argument can't handle space in file name v8.0.0847
authorBram Moolenaar <Bram@vim.org>
Thu, 3 Aug 2017 12:29:14 +0000 (14:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 3 Aug 2017 12:29:14 +0000 (14:29 +0200)
Problem:    :argadd without argument can't handle space in file name. (Harm te
            Hennepe)
Solution:   Escape the space. (Yasuhiro Matsumoto, closes #1917)

src/ex_cmds2.c
src/proto/ex_cmds2.pro
src/testdir/test_arglist.vim
src/version.c

index 687bbaecfb609f95675bd974cd782ae20f665cd8..381c5d1c25be7094dec140638064691d42c6870e 100644 (file)
@@ -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
index c8730393d3aed8dc978c9aac1ddc34b5f0ea2889..10277e81b655e2a18c4427498fdc46479b575477 100644 (file)
@@ -52,7 +52,6 @@ int can_abandon(buf_T *buf, int forceit);
 int check_changed_any(int hidden, int unload);
 int check_fname(void);
 int buf_write_all(buf_T *buf, int forceit);
-int get_arglist(garray_T *gap, char_u *str);
 int get_arglist_exp(char_u *str, int *fcountp, char_u ***fnamesp, int wig);
 void set_arglist(char_u *str);
 void check_arg_idx(win_T *win);
index f75bad1c0989613f73ad64c73854f57c27937388..2a2425a93f998c07e9e5effd9390145258e3151a 100644 (file)
@@ -65,13 +65,19 @@ func Test_argadd()
   %argd
   edit d
   arga
-  call assert_equal(len(argv()), 1)
-  call assert_equal(get(argv(), 0, ''), 'd')
+  call assert_equal(1, len(argv()))
+  call assert_equal('d', get(argv(), 0, ''))
+
+  %argd
+  edit some\ file
+  arga
+  call assert_equal(1, len(argv()))
+  call assert_equal('some file', get(argv(), 0, ''))
 
   %argd
   new
   arga
-  call assert_equal(len(argv()), 0)
+  call assert_equal(0, len(argv()))
 endfunc
 
 func Init_abc()
index 9eb8b1a91929109b37aa30179cf29335f9421df0..0d144bb76970b07a76a7deffe4a5c8efb79f2024 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    847,
 /**/
     846,
 /**/