]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1283 v7.4.1283
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Feb 2016 18:57:16 +0000 (19:57 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Feb 2016 18:57:16 +0000 (19:57 +0100)
Problem:    The job feature isn't available on MS-Windows.
Solution:   Add the job feature.  Fix argument of job_stop(). (Yasuhiro
            Matsumoto)

src/eval.c
src/feature.h
src/os_win32.c
src/proto/os_win32.pro
src/version.c

index 4b1250b593c82ea85575e2729f04e7e5fa36bfdc..c2d18aa8694240cc1adadf918ff5ea0f4b546466 100644 (file)
@@ -8205,7 +8205,7 @@ static struct fst
 #ifdef FEAT_JOB
     {"job_start",      1, 2, f_job_start},
     {"job_status",     1, 1, f_job_status},
-    {"job_stop",       1, 1, f_job_stop},
+    {"job_stop",       1, 2, f_job_stop},
 #endif
     {"join",           1, 2, f_join},
     {"jsdecode",       1, 1, f_jsdecode},
@@ -14286,7 +14286,7 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
 
     rettv->vval.v_job->jv_status = JOB_FAILED;
 #ifndef USE_ARGV
-    ga_init2(&ga, 200);
+    ga_init2(&ga, (int)sizeof(char*), 20);
 #endif
 
     if (argvars[0].v_type == VAR_STRING)
index 19425ed35577abc427256def8081a2be3b20cf6a..e1f8e27b783428fece63171eaa3fff6f6f9ce565 100644 (file)
 #endif
 
 /*
- * The +job feature requires Unix and +eval.
+ * The +job feature requires +eval and Unix or MS-Widndows.
  */
-#if defined(UNIX) && defined(FEAT_EVAL)
+#if (defined(UNIX) || defined(WIN32)) && defined(FEAT_EVAL)
 # define FEAT_JOB
 #endif
 
index db080e44ece87254f80351a6daf715cd585bc90c..4917a7f53fe861ed8eb99da3ff82a1e91f8c8ac8 100644 (file)
@@ -4155,7 +4155,7 @@ mch_system_classic(char *cmd, int options)
     si.cbReserved2 = 0;
     si.lpReserved2 = NULL;
 
-    /* There is a strange error on Windows 95 when using "c:\\command.com".
+    /* There is a strange error on Windows 95 when using "c:\command.com".
      * When the "c:\\" is left out it works OK...? */
     if (mch_windows95()
            && (STRNICMP(cmd, "c:/command.com", 14) == 0
@@ -5032,6 +5032,59 @@ mch_call_shell(
     return x;
 }
 
+#if defined(FEAT_JOB) || defined(PROTO)
+    void
+mch_start_job(char *cmd, job_T *job)
+{
+    STARTUPINFO                si;
+    PROCESS_INFORMATION        pi;
+
+    ZeroMemory(&si, sizeof(si));
+    si.cb = sizeof(si);
+
+    if (!vim_create_process(cmd, FALSE,
+           CREATE_DEFAULT_ERROR_MODE |
+           CREATE_NEW_PROCESS_GROUP |
+           CREATE_NO_WINDOW,
+           &si, &pi))
+       job->jv_status = JOB_FAILED;
+    else
+    {
+       job->jf_pi = pi;
+       job->jv_status = JOB_STARTED;
+    }
+}
+
+    char *
+mch_job_status(job_T *job)
+{
+    DWORD dwExitCode = 0;
+
+    if (!GetExitCodeProcess(job->jf_pi.hProcess, &dwExitCode))
+       return "dead";
+    if (dwExitCode != STILL_ACTIVE)
+    {
+       CloseHandle(job->jf_pi.hProcess);
+       CloseHandle(job->jf_pi.hThread);
+       return "dead";
+    }
+    return "run";
+}
+
+    int
+mch_stop_job(job_T *job, char_u *how)
+{
+    if (STRCMP(how, "kill") == 0)
+       TerminateProcess(job->jf_pi.hProcess, 0);
+    else
+       return GenerateConsoleCtrlEvent(
+           STRCMP(how, "hup") == 0 ?
+                   CTRL_BREAK_EVENT : CTRL_C_EVENT,
+               job->jf_pi.dwProcessId) ? OK : FAIL;
+    return OK;
+}
+#endif
+
 
 #ifndef FEAT_GUI_W32
 
index a5d4c77b4bee47ca66dc4c635e84760753dd49af..2128807ce59b17c5587e4aa563f689b1f0082132 100644 (file)
@@ -40,6 +40,9 @@ void mch_set_shellsize(void);
 void mch_new_shellsize(void);
 void mch_set_winsize_now(void);
 int mch_call_shell(char_u *cmd, int options);
+void mch_start_job(char *cmd, job_T *job);
+char *mch_job_status(job_T *job);
+int mch_stop_job(job_T *job, char_u *how);
 void mch_set_normal_colors(void);
 void mch_write(char_u *s, int len);
 void mch_delay(long msec, int ignoreinput);
index ffa3346a2e3e1ca9cdf52b3d2db12d7794b77c11..dab9368fc994eb0d5905c48831cacebfbdfdd87d 100644 (file)
@@ -747,6 +747,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1283,
 /**/
     1282,
 /**/