Patch 8.2.2941
Problem:    Vim9: using `=expr` does not handle a list of strings.
Solution:   Convert a list to a string and escape each item. (closes #8310)
Files:      src/vim9execute.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.2940/src/vim9execute.c   2021-06-04 21:00:27.958234335 +0200
--- src/vim9execute.c   2021-06-05 17:08:09.606394715 +0200
***************
*** 999,1013 ****
                case VAR_LIST:
                                if (tolerant)
                                {
!                                   char_u *p;
  
                                    str = typval2string(tv, TRUE);
                                    clear_tv(tv);
                                    tv->v_type = VAR_STRING;
!                                   tv->vval.v_string = str;
!                                   // TODO: escaping
!                                   while ((p = vim_strchr(str, '\n')) != NULL)
!                                       *p = ' ';
                                    return OK;
                                }
                                // FALLTHROUGH
--- 999,1032 ----
                case VAR_LIST:
                                if (tolerant)
                                {
!                                   char_u      *s, *e, *p;
!                                   garray_T    ga;
  
+                                   ga_init2(&ga, sizeof(char_u *), 1);
+ 
+                                   // Convert to NL separated items, then
+                                   // escape the items and replace the NL with
+                                   // a space.
                                    str = typval2string(tv, TRUE);
+                                   if (str == NULL)
+                                       return FAIL;
+                                   s = str;
+                                   while ((e = vim_strchr(s, '\n')) != NULL)
+                                   {
+                                       *e = NUL;
+                                       p = vim_strsave_fnameescape(s, FALSE);
+                                       if (p != NULL)
+                                       {
+                                           ga_concat(&ga, p);
+                                           ga_concat(&ga, (char_u *)" ");
+                                           vim_free(p);
+                                       }
+                                       s = e + 1;
+                                   }
+                                   vim_free(str);
                                    clear_tv(tv);
                                    tv->v_type = VAR_STRING;
!                                   tv->vval.v_string = ga.ga_data;
                                    return OK;
                                }
                                // FALLTHROUGH
*** ../vim-8.2.2940/src/testdir/test_vim9_cmd.vim       2021-05-09 
23:19:17.093003109 +0200
--- src/testdir/test_vim9_cmd.vim       2021-06-05 17:01:13.367479644 +0200
***************
*** 34,39 ****
--- 34,43 ----
  
    CheckDefFailure(['edit `=xxx`'], 'E1001:')
    CheckDefFailure(['edit `="foo"'], 'E1083:')
+ 
+   var files = ['file 1', 'file%2', 'file# 3']
+   args `=files`
+   assert_equal(files, argv())
  enddef
  
  def Test_expand_alternate_file()
*** ../vim-8.2.2940/src/version.c       2021-06-05 16:25:29.189758206 +0200
--- src/version.c       2021-06-05 17:08:48.814295986 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2941,
  /**/

-- 
   [The rest of the ARMY stand around looking at a loss.]
INSPECTOR END OF FILM: (picks up megaphone) All right!  Clear off!  Go on!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202106051511.155FBMt8063606%40masaka.moolenaar.net.

Raspunde prin e-mail lui