Patch 8.0.1747
Problem:    MS-Windows: term_start() does not set job_info() cmd.
Solution:   Share the code from job_start() to set jv_argv.
Files:      src/testdir/test_terminal.vim, src/channel.c, src/misc2.c,
            src/proto/misc2.pro, src/terminal.c


*** ../vim-8.0.1746/src/testdir/test_terminal.vim       2018-04-21 
20:02:32.738539943 +0200
--- src/testdir/test_terminal.vim       2018-04-21 22:35:59.997972267 +0200
***************
*** 786,791 ****
--- 786,797 ----
    let g:job = term_getjob(buf)
    call term_wait(buf, 50)
  
+   if has('win32')
+     call assert_equal('cmd', job_info(g:job).cmd[0])
+   else
+     call assert_equal(&shell, job_info(g:job).cmd[0])
+   endif
+ 
    " ascii + composing
    let txt = "a\u0308bc"
    call term_sendkeys(buf, "echo " . txt . "\r")
*** ../vim-8.0.1746/src/channel.c       2018-04-21 23:00:22.913439572 +0200
--- src/channel.c       2018-04-21 23:29:49.036123757 +0200
***************
*** 5563,5570 ****
  #endif
      if (argvars[0].v_type == VAR_STRING)
      {
-       char_u  *cmd_copy;
- 
        /* Command is a string. */
        cmd = argvars[0].vval.v_string;
        if (cmd == NULL || *cmd == NUL)
--- 5563,5568 ----
***************
*** 5572,5589 ****
            EMSG(_(e_invarg));
            goto theend;
        }
!       /* Make a copy, parsing will modify "cmd". */
!       cmd_copy = vim_strsave(cmd);
!       if (cmd_copy == NULL
!               || mch_parse_cmd(cmd_copy, FALSE, &argv, &argc) == FAIL)
!       {
!           vim_free(cmd_copy);
            goto theend;
-       }
-       for (i = 0; i < argc; i++)
-           argv[i] = (char *)vim_strsave((char_u *)argv[i]);
-       argv[argc] = NULL;
-       vim_free(cmd_copy);
      }
      else if (argvars[0].v_type != VAR_LIST
            || argvars[0].vval.v_list == NULL
--- 5570,5578 ----
            EMSG(_(e_invarg));
            goto theend;
        }
! 
!       if (build_argv_from_string(cmd, &argv, &argc) == FAIL)
            goto theend;
      }
      else if (argvars[0].v_type != VAR_LIST
            || argvars[0].vval.v_list == NULL
***************
*** 5594,5620 ****
      }
      else
      {
!       list_T      *l = argvars[0].vval.v_list;
!       listitem_T  *li;
!       char_u      *s;
  
!       /* Pass argv[] to mch_call_shell(). */
!       argv = (char **)alloc(sizeof(char *) * (l->lv_len + 1));
!       if (argv == NULL)
            goto theend;
-       for (li = l->lv_first; li != NULL; li = li->li_next)
-       {
-           s = get_tv_string_chk(&li->li_tv);
-           if (s == NULL)
-           {
-               for (i = 0; i < argc; ++i)
-                   vim_free(argv[i]);
-               goto theend;
-           }
-           argv[argc++] = (char *)vim_strsave(s);
-       }
-       argv[argc] = NULL;
- 
  #ifndef USE_ARGV
        if (win32_build_cmd(l, &ga) == FAIL)
            goto theend;
--- 5583,5592 ----
      }
      else
      {
!       list_T *l = argvars[0].vval.v_list;
  
!       if (build_argv_from_list(l, &argv, &argc) == FAIL)
            goto theend;
  #ifndef USE_ARGV
        if (win32_build_cmd(l, &ga) == FAIL)
            goto theend;
*** ../vim-8.0.1746/src/misc2.c 2018-04-21 22:30:04.712058412 +0200
--- src/misc2.c 2018-04-21 23:24:12.929917296 +0200
***************
*** 6513,6516 ****
--- 6513,6578 ----
      }
      return OK;
  }
+ 
+ # if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
+ /*
+  * Build "argv[argc]" from the string "cmd".
+  * "argv[argc]" is set to NULL;
+  * Return FAIL when out of memory.
+  */
+     int
+ build_argv_from_string(char_u *cmd, char ***argv, int *argc)
+ {
+     char_u    *cmd_copy;
+     int               i;
+ 
+     /* Make a copy, parsing will modify "cmd". */
+     cmd_copy = vim_strsave(cmd);
+     if (cmd_copy == NULL
+           || mch_parse_cmd(cmd_copy, FALSE, argv, argc) == FAIL)
+     {
+       vim_free(cmd_copy);
+       return FAIL;
+     }
+     for (i = 0; i < *argc; i++)
+       (*argv)[i] = (char *)vim_strsave((char_u *)(*argv)[i]);
+     (*argv)[*argc] = NULL;
+     vim_free(cmd_copy);
+     return OK;
+ }
+ 
+ /*
+  * Build "argv[argc]" from the list "l".
+  * "argv[argc]" is set to NULL;
+  * Return FAIL when out of memory.
+  */
+     int
+ build_argv_from_list(list_T *l, char ***argv, int *argc)
+ {
+     listitem_T  *li;
+     char_u    *s;
+ 
+     /* Pass argv[] to mch_call_shell(). */
+     *argv = (char **)alloc(sizeof(char *) * (l->lv_len + 1));
+     if (*argv == NULL)
+       return FAIL;
+     *argc = 0;
+     for (li = l->lv_first; li != NULL; li = li->li_next)
+     {
+       s = get_tv_string_chk(&li->li_tv);
+       if (s == NULL)
+       {
+           int i;
+ 
+           for (i = 0; i < *argc; ++i)
+               vim_free((*argv)[i]);
+           return FAIL;
+       }
+       (*argv)[*argc] = (char *)vim_strsave(s);
+       *argc += 1;
+     }
+     (*argv)[*argc] = NULL;
+     return OK;
+ }
+ # endif
  #endif
*** ../vim-8.0.1746/src/proto/misc2.pro 2018-04-21 22:30:04.712058412 +0200
--- src/proto/misc2.pro 2018-04-21 23:15:54.720239795 +0200
***************
*** 111,114 ****
--- 111,116 ----
  int has_non_ascii(char_u *s);
  void parse_queued_messages(void);
  int mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc);
+ int build_argv_from_string(char_u *cmd, char ***argv, int *argc);
+ int build_argv_from_list(list_T *l, char ***argv, int *argc);
  /* vim: set ft=c : */
*** ../vim-8.0.1746/src/terminal.c      2018-04-21 22:30:04.712058412 +0200
--- src/terminal.c      2018-04-21 23:16:40.644044898 +0200
***************
*** 5342,5347 ****
--- 5342,5359 ----
      job = job_alloc();
      if (job == NULL)
        goto failed;
+     if (argvar->v_type == VAR_STRING)
+     {
+       int argc;
+ 
+       build_argv_from_string(cmd, &job->jv_argv, &argc);
+     }
+     else
+     {
+       int argc;
+ 
+       build_argv_from_list(argvar->vval.v_list, &job->jv_argv, &argc);
+     }
  
      if (opt->jo_set & JO_IN_BUF)
        job->jv_in_buf = buflist_findnr(opt->jo_io_buf[PART_IN]);
*** ../vim-8.0.1746/src/version.c       2018-04-21 23:00:22.917439549 +0200
--- src/version.c       2018-04-21 23:33:33.683000794 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1747,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
244. You use more than 20 passwords.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui