1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: MingW cross compilation doesn't work with tiny features.
12 Solution: Move acp_to_enc(), enc_to_utf16() and utf16_to_enc() outside of
13 "#ifdef CLIPBOARD". Fix typo in makefile.
14 Files: src/Make_ming.mak, src/os_mswin.c
17 *** ../mercurial/vim73/src/Make_ming.mak 2010-12-30 14:50:46.000000000 +0100
18 --- src/Make_ming.mak 2011-06-19 01:20:16.000000000 +0200
22 # If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext
23 # or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/
24 ! # uncomment the following, but I can't build a static versiĆ³n with them, ?-(|
25 #GETTEXT=c:/gettext-0.10.37-20010430
26 #STATIC_GETTEXT=USE_STATIC_GETTEXT
27 #DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
30 # If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext
31 # or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/
32 ! # uncomment the following, but I can't build a static version with them, ?-(|
33 #GETTEXT=c:/gettext-0.10.37-20010430
34 #STATIC_GETTEXT=USE_STATIC_GETTEXT
35 #DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
36 *** ../mercurial/vim73/src/os_mswin.c 2011-06-19 01:14:23.000000000 +0200
37 --- src/os_mswin.c 2011-06-19 01:25:23.000000000 +0200
43 - #if defined(FEAT_MBYTE) || defined(PROTO)
45 - * Note: the following two functions are only guaranteed to work when using
46 - * valid MS-Windows codepages or when iconv() is available.
50 - * Convert "str" from 'encoding' to UTF-16.
51 - * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
52 - * Output is returned as an allocated string. "*lenp" is set to the length of
53 - * the result. A trailing NUL is always added.
54 - * Returns NULL when out of memory.
57 - enc_to_utf16(char_u *str, int *lenp)
61 - char_u *allocbuf = NULL;
67 - len_loc = (int)STRLEN(str) + 1;
71 - if (enc_codepage > 0)
73 - /* We can do any CP### -> UTF-16 in one pass, and we can do it
74 - * without iconv() (convert_* may need iconv). */
75 - MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
79 - /* Use "latin1" by default, we might be called before we have p_enc
80 - * set up. Convert to utf-8 first, works better with iconv(). Does
81 - * nothing if 'encoding' is "utf-8". */
82 - conv.vc_type = CONV_NONE;
83 - if (convert_setup(&conv, p_enc ? p_enc : (char_u *)"latin1",
84 - (char_u *)"utf-8") == FAIL)
86 - if (conv.vc_type != CONV_NONE)
88 - str = allocbuf = string_convert(&conv, str, lenp);
92 - convert_setup(&conv, NULL, NULL);
94 - length = utf8_to_utf16(str, *lenp, NULL, NULL);
95 - ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
98 - utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
102 - vim_free(allocbuf);
106 - return (short_u *)ret;
110 - * Convert an UTF-16 string to 'encoding'.
111 - * Input in "str" with length (counted in wide characters) "*lenp". When
112 - * "lenp" is NULL, use wcslen().
113 - * Output is returned as an allocated string. If "*lenp" is not NULL it is
114 - * set to the length of the result.
115 - * Returns NULL when out of memory.
118 - utf16_to_enc(short_u *str, int *lenp)
121 - char_u *utf8_str = NULL, *enc_str = NULL;
126 - len_loc = (int)wcslen(str) + 1;
130 - if (enc_codepage > 0)
132 - /* We can do any UTF-16 -> CP### in one pass. */
135 - WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
136 - (LPSTR *)&enc_str, &length, 0, 0);
141 - /* Avoid allocating zero bytes, it generates an error message. */
142 - utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
143 - if (utf8_str != NULL)
145 - *lenp = utf16_to_utf8(str, *lenp, utf8_str);
147 - /* We might be called before we have p_enc set up. */
148 - conv.vc_type = CONV_NONE;
149 - convert_setup(&conv, (char_u *)"utf-8",
150 - p_enc? p_enc: (char_u *)"latin1");
151 - if (conv.vc_type == CONV_NONE)
153 - /* p_enc is utf-8, so we're done. */
154 - enc_str = utf8_str;
158 - enc_str = string_convert(&conv, utf8_str, lenp);
159 - vim_free(utf8_str);
162 - convert_setup(&conv, NULL, NULL);
167 - #endif /* FEAT_MBYTE */
170 * Wait for another process to Close the Clipboard.
171 * Returns TRUE for success.
178 - #if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
180 - * Convert from the active codepage to 'encoding'.
181 - * Input is "str[str_size]".
182 - * The result is in allocated memory: "out[outlen]". With terminating NUL.
185 - acp_to_enc(str, str_size, out, outlen)
194 - MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
195 - if (widestr != NULL)
197 - ++*outlen; /* Include the 0 after the string */
198 - *out = utf16_to_enc((short_u *)widestr, outlen);
205 * Send the current selection to the clipboard.
212 #endif /* FEAT_CLIPBOARD */
214 + #if defined(FEAT_MBYTE) || defined(PROTO)
216 + * Note: the following two functions are only guaranteed to work when using
217 + * valid MS-Windows codepages or when iconv() is available.
221 + * Convert "str" from 'encoding' to UTF-16.
222 + * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
223 + * Output is returned as an allocated string. "*lenp" is set to the length of
224 + * the result. A trailing NUL is always added.
225 + * Returns NULL when out of memory.
228 + enc_to_utf16(char_u *str, int *lenp)
232 + char_u *allocbuf = NULL;
238 + len_loc = (int)STRLEN(str) + 1;
242 + if (enc_codepage > 0)
244 + /* We can do any CP### -> UTF-16 in one pass, and we can do it
245 + * without iconv() (convert_* may need iconv). */
246 + MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
250 + /* Use "latin1" by default, we might be called before we have p_enc
251 + * set up. Convert to utf-8 first, works better with iconv(). Does
252 + * nothing if 'encoding' is "utf-8". */
253 + conv.vc_type = CONV_NONE;
254 + if (convert_setup(&conv, p_enc ? p_enc : (char_u *)"latin1",
255 + (char_u *)"utf-8") == FAIL)
257 + if (conv.vc_type != CONV_NONE)
259 + str = allocbuf = string_convert(&conv, str, lenp);
263 + convert_setup(&conv, NULL, NULL);
265 + length = utf8_to_utf16(str, *lenp, NULL, NULL);
266 + ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
269 + utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
273 + vim_free(allocbuf);
277 + return (short_u *)ret;
281 + * Convert an UTF-16 string to 'encoding'.
282 + * Input in "str" with length (counted in wide characters) "*lenp". When
283 + * "lenp" is NULL, use wcslen().
284 + * Output is returned as an allocated string. If "*lenp" is not NULL it is
285 + * set to the length of the result.
286 + * Returns NULL when out of memory.
289 + utf16_to_enc(short_u *str, int *lenp)
292 + char_u *utf8_str = NULL, *enc_str = NULL;
297 + len_loc = (int)wcslen(str) + 1;
301 + if (enc_codepage > 0)
303 + /* We can do any UTF-16 -> CP### in one pass. */
306 + WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
307 + (LPSTR *)&enc_str, &length, 0, 0);
312 + /* Avoid allocating zero bytes, it generates an error message. */
313 + utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
314 + if (utf8_str != NULL)
316 + *lenp = utf16_to_utf8(str, *lenp, utf8_str);
318 + /* We might be called before we have p_enc set up. */
319 + conv.vc_type = CONV_NONE;
320 + convert_setup(&conv, (char_u *)"utf-8",
321 + p_enc? p_enc: (char_u *)"latin1");
322 + if (conv.vc_type == CONV_NONE)
324 + /* p_enc is utf-8, so we're done. */
325 + enc_str = utf8_str;
329 + enc_str = string_convert(&conv, utf8_str, lenp);
330 + vim_free(utf8_str);
333 + convert_setup(&conv, NULL, NULL);
338 + #endif /* FEAT_MBYTE */
340 + #if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
342 + * Convert from the active codepage to 'encoding'.
343 + * Input is "str[str_size]".
344 + * The result is in allocated memory: "out[outlen]". With terminating NUL.
347 + acp_to_enc(str, str_size, out, outlen)
356 + MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
357 + if (widestr != NULL)
359 + ++*outlen; /* Include the 0 after the string */
360 + *out = utf16_to_enc((short_u *)widestr, outlen);
368 * Debugging helper: expose the MCH_WRITE_DUMP stuff to other modules
369 *** ../vim-7.3.222/src/version.c 2011-06-19 01:27:29.000000000 +0200
370 --- src/version.c 2011-06-19 01:28:41.000000000 +0200
374 { /* Add new patch number below this line */
380 hundred-and-one symptoms of being an internet addict:
381 191. You rate eating establishments not by the quality of the food,
382 but by the availability of electrical outlets for your PowerBook.
384 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
385 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
386 \\\ an exciting new programming language -- http://www.Zimbu.org ///
387 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///