lkundrak / rpms / vim

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