summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2013-12-11 17:58:35 +0100
committerBram Moolenaar <bram@vim.org>2013-12-11 17:58:35 +0100
commit2716f418c9f20a58f54eb9351c6e520680285265 (patch)
treee4c61706d6baf77b5cbbcde2f0eb5f189d17b025
parent03c7bd0f47ba63ec04fdc78c9ef5647b9eae4a8f (diff)
downloadvim-2716f418c9f20a58f54eb9351c6e520680285265.tar.gz
updated for version 7.4.122v7.4.122v7-4-122
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)
-rw-r--r--src/os_win32.c110
-rw-r--r--src/version.c2
2 files changed, 73 insertions, 39 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 91c8368f..2d5544b4 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -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
{
diff --git a/src/version.c b/src/version.c
index 6fed35fb..4bfd68ff 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 122,
+/**/
121,
/**/
120,