]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.122 v7.4.122
authorBram Moolenaar <Bram@vim.org>
Wed, 11 Dec 2013 16:58:35 +0000 (17:58 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 11 Dec 2013 16:58:35 +0000 (17:58 +0100)
Problem:    Win32: When 'encoding' is set to "utf-8" and the active codepage
            is cp932 then ":grep" and other commands don't work for multi-byte
            characters.
Solution:   (Yasuhiro Matsumoto)

src/os_win32.c
src/version.c

index 91c8368f30826ad8bd967e2ec0772a1a4f00af73..2d5544b44291214592f4dc62f6068bd40e317c20 100644 (file)
@@ -3788,6 +3788,50 @@ mch_set_winsize_now(void)
 }
 #endif /* FEAT_GUI_W32 */
 
+    static BOOL
+vim_create_process(
+    const char         *cmd,
+    DWORD              flags,
+    BOOL               inherit_handles,
+    STARTUPINFO                *si,
+    PROCESS_INFORMATION *pi)
+{
+#  ifdef FEAT_MBYTE
+    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+    {
+       WCHAR   *wcmd = enc_to_utf16(cmd, NULL);
+
+       if (wcmd != NULL)
+       {
+           BOOL ret;
+           ret = CreateProcessW(
+               NULL,                   /* Executable name */
+               wcmd,                   /* Command to execute */
+               NULL,                   /* Process security attributes */
+               NULL,                   /* Thread security attributes */
+               inherit_handles,        /* Inherit handles */
+               flags,                  /* Creation flags */
+               NULL,                   /* Environment */
+               NULL,                   /* Current directory */
+               si,                     /* Startup information */
+               pi);                    /* Process information */
+           vim_free(wcmd);
+           return ret;
+       }
+    }
+#endif
+    return CreateProcess(
+       NULL,                   /* Executable name */
+       cmd,                    /* Command to execute */
+       NULL,                   /* Process security attributes */
+       NULL,                   /* Thread security attributes */
+       inherit_handles,        /* Inherit handles */
+       flags,                  /* Creation flags */
+       NULL,                   /* Environment */
+       NULL,                   /* Current directory */
+       si,                     /* Startup information */
+       pi);                    /* Process information */
+}
 
 
 #if defined(FEAT_GUI_W32) || defined(PROTO)
@@ -3834,18 +3878,8 @@ mch_system_classic(char *cmd, int options)
        cmd += 3;
 
     /* Now, run the command */
-    CreateProcess(NULL,                        /* Executable name */
-                 cmd,                  /* Command to execute */
-                 NULL,                 /* Process security attributes */
-                 NULL,                 /* Thread security attributes */
-                 FALSE,                /* Inherit handles */
-                 CREATE_DEFAULT_ERROR_MODE |   /* Creation flags */
-                       CREATE_NEW_CONSOLE,
-                 NULL,                 /* Environment */
-                 NULL,                 /* Current directory */
-                 &si,                  /* Startup information */
-                 &pi);                 /* Process information */
-
+    vim_create_process(cmd, FALSE,
+           CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE, &si, &pi);
 
     /* Wait for the command to terminate before continuing */
     if (g_PlatformId != VER_PLATFORM_WIN32s)
@@ -4177,22 +4211,11 @@ mch_system_piped(char *cmd, int options)
            p = cmd;
     }
 
-    /* Now, run the command */
-    CreateProcess(NULL,                        /* Executable name */
-                 p,                    /* Command to execute */
-                 NULL,                 /* Process security attributes */
-                 NULL,                 /* Thread security attributes */
-
-                 // this command can be litigious, handle inheritance was
-                 // deactivated for pending temp file, but, if we deactivate
-                 // it, the pipes don't work for some reason.
-                 TRUE,                 /* Inherit handles, first deactivated,
-                                        * but needed */
-                 CREATE_DEFAULT_ERROR_MODE, /* Creation flags */
-                 NULL,                 /* Environment */
-                 NULL,                 /* Current directory */
-                 &si,                  /* Startup information */
-                 &pi);                 /* Process information */
+    /* Now, run the command.
+     * About "Inherit handles" being TRUE: this command can be litigious,
+     * handle inheritance was deactivated for pending temp file, but, if we
+     * deactivate it, the pipes don't work for some reason. */
+     vim_create_process(p, TRUE, CREATE_DEFAULT_ERROR_MODE, &si, &pi);
 
     if (p != cmd)
        vim_free(p);
@@ -4410,7 +4433,25 @@ mch_system(char *cmd, int options)
 }
 #else
 
-# define mch_system(c, o) system(c)
+# ifdef FEAT_MBYTE
+    static int
+mch_system(char *cmd, int options)
+{
+    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+    {
+       WCHAR   *wcmd = enc_to_utf16(cmd, NULL);
+       if (wcmd != NULL)
+       {
+           int ret = _wsystem(wcmd);
+           vim_free(wcmd);
+           return ret;
+       }
+    }
+    return system(cmd);
+}
+# else
+#  define mch_system(c, o) system(c)
+# endif
 
 #endif
 
@@ -4578,16 +4619,7 @@ mch_call_shell(
             * inherit our handles which causes unpleasant dangling swap
             * files if we exit before the spawned process
             */
-           if (CreateProcess(NULL,             // Executable name
-                   newcmd,                     // Command to execute
-                   NULL,                       // Process security attributes
-                   NULL,                       // Thread security attributes
-                   FALSE,                      // Inherit handles
-                   flags,                      // Creation flags
-                   NULL,                       // Environment
-                   NULL,                       // Current directory
-                   &si,                        // Startup information
-                   &pi))                       // Process information
+           if (vim_create_process(newcmd, FALSE, flags, &si, &pi))
                x = 0;
            else
            {
index 6fed35fb2edc3e2d3f7ba261956d168bf7dc95cb..4bfd68ff91835b2fc621e73d220b32efa00e3a61 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    122,
 /**/
     121,
 /**/