forked from aniani/vim
updated for version 7.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)
This commit is contained in:
108
src/os_win32.c
108
src/os_win32.c
@@ -3788,6 +3788,50 @@ mch_set_winsize_now(void)
|
|||||||
}
|
}
|
||||||
#endif /* FEAT_GUI_W32 */
|
#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)
|
#if defined(FEAT_GUI_W32) || defined(PROTO)
|
||||||
@@ -3834,18 +3878,8 @@ mch_system_classic(char *cmd, int options)
|
|||||||
cmd += 3;
|
cmd += 3;
|
||||||
|
|
||||||
/* Now, run the command */
|
/* Now, run the command */
|
||||||
CreateProcess(NULL, /* Executable name */
|
vim_create_process(cmd, FALSE,
|
||||||
cmd, /* Command to execute */
|
CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE, &si, &pi);
|
||||||
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 */
|
|
||||||
|
|
||||||
|
|
||||||
/* Wait for the command to terminate before continuing */
|
/* Wait for the command to terminate before continuing */
|
||||||
if (g_PlatformId != VER_PLATFORM_WIN32s)
|
if (g_PlatformId != VER_PLATFORM_WIN32s)
|
||||||
@@ -4177,22 +4211,11 @@ mch_system_piped(char *cmd, int options)
|
|||||||
p = cmd;
|
p = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, run the command */
|
/* Now, run the command.
|
||||||
CreateProcess(NULL, /* Executable name */
|
* About "Inherit handles" being TRUE: this command can be litigious,
|
||||||
p, /* Command to execute */
|
* handle inheritance was deactivated for pending temp file, but, if we
|
||||||
NULL, /* Process security attributes */
|
* deactivate it, the pipes don't work for some reason. */
|
||||||
NULL, /* Thread security attributes */
|
vim_create_process(p, TRUE, CREATE_DEFAULT_ERROR_MODE, &si, &pi);
|
||||||
|
|
||||||
// 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 */
|
|
||||||
|
|
||||||
if (p != cmd)
|
if (p != cmd)
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
@@ -4410,7 +4433,25 @@ mch_system(char *cmd, int options)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
# 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)
|
# define mch_system(c, o) system(c)
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -4578,16 +4619,7 @@ mch_call_shell(
|
|||||||
* inherit our handles which causes unpleasant dangling swap
|
* inherit our handles which causes unpleasant dangling swap
|
||||||
* files if we exit before the spawned process
|
* files if we exit before the spawned process
|
||||||
*/
|
*/
|
||||||
if (CreateProcess(NULL, // Executable name
|
if (vim_create_process(newcmd, FALSE, flags, &si, &pi))
|
||||||
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
|
|
||||||
x = 0;
|
x = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
122,
|
||||||
/**/
|
/**/
|
||||||
121,
|
121,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user