8b9a1c
To: vim_dev@googlegroups.com
8b9a1c
Subject: Patch 7.4.122
8b9a1c
Fcc: outbox
8b9a1c
From: Bram Moolenaar <Bram@moolenaar.net>
8b9a1c
Mime-Version: 1.0
8b9a1c
Content-Type: text/plain; charset=UTF-8
8b9a1c
Content-Transfer-Encoding: 8bit
8b9a1c
------------
8b9a1c
8b9a1c
Patch 7.4.122
8b9a1c
Problem:    Win32: When 'encoding' is set to "utf-8" and the active codepage
8b9a1c
	    is cp932 then ":grep" and other commands don't work for multi-byte
8b9a1c
	    characters.
8b9a1c
Solution:   (Yasuhiro Matsumoto)
8b9a1c
Files:	    src/os_win32.c
8b9a1c
8b9a1c
8b9a1c
*** ../vim-7.4.121/src/os_win32.c	2013-12-07 14:48:06.000000000 +0100
8b9a1c
--- src/os_win32.c	2013-12-11 17:57:48.000000000 +0100
8b9a1c
***************
8b9a1c
*** 3788,3793 ****
8b9a1c
--- 3788,3837 ----
8b9a1c
  }
8b9a1c
  #endif /* FEAT_GUI_W32 */
8b9a1c
  
8b9a1c
+     static BOOL
8b9a1c
+ vim_create_process(
8b9a1c
+     const char		*cmd,
8b9a1c
+     DWORD		flags,
8b9a1c
+     BOOL		inherit_handles,
8b9a1c
+     STARTUPINFO		*si,
8b9a1c
+     PROCESS_INFORMATION *pi)
8b9a1c
+ {
8b9a1c
+ #  ifdef FEAT_MBYTE
8b9a1c
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
8b9a1c
+     {
8b9a1c
+ 	WCHAR	*wcmd = enc_to_utf16(cmd, NULL);
8b9a1c
+ 
8b9a1c
+ 	if (wcmd != NULL)
8b9a1c
+ 	{
8b9a1c
+ 	    BOOL ret;
8b9a1c
+ 	    ret = CreateProcessW(
8b9a1c
+ 		NULL,			/* Executable name */
8b9a1c
+ 		wcmd,			/* Command to execute */
8b9a1c
+ 		NULL,			/* Process security attributes */
8b9a1c
+ 		NULL,			/* Thread security attributes */
8b9a1c
+ 		inherit_handles,	/* Inherit handles */
8b9a1c
+ 		flags,			/* Creation flags */
8b9a1c
+ 		NULL,			/* Environment */
8b9a1c
+ 		NULL,			/* Current directory */
8b9a1c
+ 		si,			/* Startup information */
8b9a1c
+ 		pi);			/* Process information */
8b9a1c
+ 	    vim_free(wcmd);
8b9a1c
+ 	    return ret;
8b9a1c
+ 	}
8b9a1c
+     }
8b9a1c
+ #endif
8b9a1c
+     return CreateProcess(
8b9a1c
+ 	NULL,			/* Executable name */
8b9a1c
+ 	cmd,			/* Command to execute */
8b9a1c
+ 	NULL,			/* Process security attributes */
8b9a1c
+ 	NULL,			/* Thread security attributes */
8b9a1c
+ 	inherit_handles,	/* Inherit handles */
8b9a1c
+ 	flags,			/* Creation flags */
8b9a1c
+ 	NULL,			/* Environment */
8b9a1c
+ 	NULL,			/* Current directory */
8b9a1c
+ 	si,			/* Startup information */
8b9a1c
+ 	pi);			/* Process information */
8b9a1c
+ }
8b9a1c
  
8b9a1c
  
8b9a1c
  #if defined(FEAT_GUI_W32) || defined(PROTO)
8b9a1c
***************
8b9a1c
*** 3834,3851 ****
8b9a1c
  	cmd += 3;
8b9a1c
  
8b9a1c
      /* Now, run the command */
8b9a1c
!     CreateProcess(NULL,			/* Executable name */
8b9a1c
! 		  cmd,			/* Command to execute */
8b9a1c
! 		  NULL,			/* Process security attributes */
8b9a1c
! 		  NULL,			/* Thread security attributes */
8b9a1c
! 		  FALSE,		/* Inherit handles */
8b9a1c
! 		  CREATE_DEFAULT_ERROR_MODE |	/* Creation flags */
8b9a1c
! 			CREATE_NEW_CONSOLE,
8b9a1c
! 		  NULL,			/* Environment */
8b9a1c
! 		  NULL,			/* Current directory */
8b9a1c
! 		  &si,			/* Startup information */
8b9a1c
! 		  &pi);			/* Process information */
8b9a1c
! 
8b9a1c
  
8b9a1c
      /* Wait for the command to terminate before continuing */
8b9a1c
      if (g_PlatformId != VER_PLATFORM_WIN32s)
8b9a1c
--- 3878,3885 ----
8b9a1c
  	cmd += 3;
8b9a1c
  
8b9a1c
      /* Now, run the command */
8b9a1c
!     vim_create_process(cmd, FALSE,
8b9a1c
! 	    CREATE_DEFAULT_ERROR_MODE |	CREATE_NEW_CONSOLE, &si, &pi);
8b9a1c
  
8b9a1c
      /* Wait for the command to terminate before continuing */
8b9a1c
      if (g_PlatformId != VER_PLATFORM_WIN32s)
8b9a1c
***************
8b9a1c
*** 4177,4198 ****
8b9a1c
  	    p = cmd;
8b9a1c
      }
8b9a1c
  
8b9a1c
!     /* Now, run the command */
8b9a1c
!     CreateProcess(NULL,			/* Executable name */
8b9a1c
! 		  p,			/* Command to execute */
8b9a1c
! 		  NULL,			/* Process security attributes */
8b9a1c
! 		  NULL,			/* Thread security attributes */
8b9a1c
! 
8b9a1c
! 		  // this command can be litigious, handle inheritance was
8b9a1c
! 		  // deactivated for pending temp file, but, if we deactivate
8b9a1c
! 		  // it, the pipes don't work for some reason.
8b9a1c
! 		  TRUE,			/* Inherit handles, first deactivated,
8b9a1c
! 					 * but needed */
8b9a1c
! 		  CREATE_DEFAULT_ERROR_MODE, /* Creation flags */
8b9a1c
! 		  NULL,			/* Environment */
8b9a1c
! 		  NULL,			/* Current directory */
8b9a1c
! 		  &si,			/* Startup information */
8b9a1c
! 		  &pi);			/* Process information */
8b9a1c
  
8b9a1c
      if (p != cmd)
8b9a1c
  	vim_free(p);
8b9a1c
--- 4211,4221 ----
8b9a1c
  	    p = cmd;
8b9a1c
      }
8b9a1c
  
8b9a1c
!     /* Now, run the command.
8b9a1c
!      * About "Inherit handles" being TRUE: this command can be litigious,
8b9a1c
!      * handle inheritance was deactivated for pending temp file, but, if we
8b9a1c
!      * deactivate it, the pipes don't work for some reason. */
8b9a1c
!      vim_create_process(p, TRUE, CREATE_DEFAULT_ERROR_MODE, &si, &pi);
8b9a1c
  
8b9a1c
      if (p != cmd)
8b9a1c
  	vim_free(p);
8b9a1c
***************
8b9a1c
*** 4410,4416 ****
8b9a1c
  }
8b9a1c
  #else
8b9a1c
  
8b9a1c
! # define mch_system(c, o) system(c)
8b9a1c
  
8b9a1c
  #endif
8b9a1c
  
8b9a1c
--- 4433,4457 ----
8b9a1c
  }
8b9a1c
  #else
8b9a1c
  
8b9a1c
! # ifdef FEAT_MBYTE
8b9a1c
!     static int
8b9a1c
! mch_system(char *cmd, int options)
8b9a1c
! {
8b9a1c
!     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
8b9a1c
!     {
8b9a1c
! 	WCHAR	*wcmd = enc_to_utf16(cmd, NULL);
8b9a1c
! 	if (wcmd != NULL)
8b9a1c
! 	{
8b9a1c
! 	    int ret = _wsystem(wcmd);
8b9a1c
! 	    vim_free(wcmd);
8b9a1c
! 	    return ret;
8b9a1c
! 	}
8b9a1c
!     }
8b9a1c
!     return system(cmd);
8b9a1c
! }
8b9a1c
! # else
8b9a1c
! #  define mch_system(c, o) system(c)
8b9a1c
! # endif
8b9a1c
  
8b9a1c
  #endif
8b9a1c
  
8b9a1c
***************
8b9a1c
*** 4578,4593 ****
8b9a1c
  	     * inherit our handles which causes unpleasant dangling swap
8b9a1c
  	     * files if we exit before the spawned process
8b9a1c
  	     */
8b9a1c
! 	    if (CreateProcess(NULL,		// Executable name
8b9a1c
! 		    newcmd,			// Command to execute
8b9a1c
! 		    NULL,			// Process security attributes
8b9a1c
! 		    NULL,			// Thread security attributes
8b9a1c
! 		    FALSE,			// Inherit handles
8b9a1c
! 		    flags,			// Creation flags
8b9a1c
! 		    NULL,			// Environment
8b9a1c
! 		    NULL,			// Current directory
8b9a1c
! 		    &si,			// Startup information
8b9a1c
! 		    &pi))			// Process information
8b9a1c
  		x = 0;
8b9a1c
  	    else
8b9a1c
  	    {
8b9a1c
--- 4619,4625 ----
8b9a1c
  	     * inherit our handles which causes unpleasant dangling swap
8b9a1c
  	     * files if we exit before the spawned process
8b9a1c
  	     */
8b9a1c
! 	    if (vim_create_process(newcmd, FALSE, flags, &si, &pi))
8b9a1c
  		x = 0;
8b9a1c
  	    else
8b9a1c
  	    {
8b9a1c
*** ../vim-7.4.121/src/version.c	2013-12-11 17:44:33.000000000 +0100
8b9a1c
--- src/version.c	2013-12-11 17:48:09.000000000 +0100
8b9a1c
***************
8b9a1c
*** 740,741 ****
8b9a1c
--- 740,743 ----
8b9a1c
  {   /* Add new patch number below this line */
8b9a1c
+ /**/
8b9a1c
+     122,
8b9a1c
  /**/
8b9a1c
8b9a1c
-- 
8b9a1c
Never overestimate a man's ability to underestimate a woman.
8b9a1c
8b9a1c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
8b9a1c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
8b9a1c
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
8b9a1c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///