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