summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.122
blob: 2e6e581c7d0bfe16af1b67e2e732d6721e92357b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
To: vim_dev@googlegroups.com
Subject: Patch 7.4.122
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 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)
Files:	    src/os_win32.c


*** ../vim-7.4.121/src/os_win32.c	2013-12-07 14:48:06.000000000 +0100
--- src/os_win32.c	2013-12-11 17:57:48.000000000 +0100
***************
*** 3788,3793 ****
--- 3788,3837 ----
  }
  #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,3851 ****
  	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 */
! 
  
      /* Wait for the command to terminate before continuing */
      if (g_PlatformId != VER_PLATFORM_WIN32s)
--- 3878,3885 ----
  	cmd += 3;
  
      /* Now, run the command */
!     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,4198 ****
  	    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 */
  
      if (p != cmd)
  	vim_free(p);
--- 4211,4221 ----
  	    p = cmd;
      }
  
!     /* 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,4416 ****
  }
  #else
  
! # define mch_system(c, o) system(c)
  
  #endif
  
--- 4433,4457 ----
  }
  #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)
! # endif
  
  #endif
  
***************
*** 4578,4593 ****
  	     * 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
  		x = 0;
  	    else
  	    {
--- 4619,4625 ----
  	     * inherit our handles which causes unpleasant dangling swap
  	     * files if we exit before the spawned process
  	     */
! 	    if (vim_create_process(newcmd, FALSE, flags, &si, &pi))
  		x = 0;
  	    else
  	    {
*** ../vim-7.4.121/src/version.c	2013-12-11 17:44:33.000000000 +0100
--- src/version.c	2013-12-11 17:48:09.000000000 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     122,
  /**/

-- 
Never overestimate a man's ability to underestimate a woman.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///