]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.223
- new: 7.3.252
[packages/vim.git] / 7.3.223
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.223
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.223
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
15
16
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
19 ***************
20 *** 87,93 ****
21   
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
28 --- 87,93 ----
29   
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
38 ***************
39 *** 1105,1236 ****
40       return ret;
41   }
42   
43 - #if defined(FEAT_MBYTE) || defined(PROTO)
44 - /*
45 -  * Note: the following two functions are only guaranteed to work when using
46 -  * valid MS-Windows codepages or when iconv() is available.
47 -  */
48
49 - /*
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.
55 -  */
56 -     short_u *
57 - enc_to_utf16(char_u *str, int *lenp)
58 - {
59 -     vimconv_T conv;
60 -     WCHAR     *ret;
61 -     char_u    *allocbuf = NULL;
62 -     int               len_loc;
63 -     int               length;
64
65 -     if (lenp == NULL)
66 -     {
67 -       len_loc = (int)STRLEN(str) + 1;
68 -       lenp = &len_loc;
69 -     }
70
71 -     if (enc_codepage > 0)
72 -     {
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);
76 -     }
77 -     else
78 -     {
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)
85 -           return NULL;
86 -       if (conv.vc_type != CONV_NONE)
87 -       {
88 -           str = allocbuf = string_convert(&conv, str, lenp);
89 -           if (str == NULL)
90 -               return NULL;
91 -       }
92 -       convert_setup(&conv, NULL, NULL);
93
94 -       length = utf8_to_utf16(str, *lenp, NULL, NULL);
95 -       ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
96 -       if (ret != NULL)
97 -       {
98 -           utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
99 -           ret[length] = 0;
100 -       }
101
102 -       vim_free(allocbuf);
103 -     }
104
105 -     *lenp = length;
106 -     return (short_u *)ret;
107 - }
108
109 - /*
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.
116 -  */
117 -     char_u *
118 - utf16_to_enc(short_u *str, int *lenp)
119 - {
120 -     vimconv_T conv;
121 -     char_u    *utf8_str = NULL, *enc_str = NULL;
122 -     int               len_loc;
123
124 -     if (lenp == NULL)
125 -     {
126 -       len_loc = (int)wcslen(str) + 1;
127 -       lenp = &len_loc;
128 -     }
129
130 -     if (enc_codepage > 0)
131 -     {
132 -       /* We can do any UTF-16 -> CP### in one pass. */
133 -       int length;
134
135 -       WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
136 -                                           (LPSTR *)&enc_str, &length, 0, 0);
137 -       *lenp = length;
138 -       return enc_str;
139 -     }
140
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)
144 -     {
145 -       *lenp = utf16_to_utf8(str, *lenp, utf8_str);
146
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)
152 -       {
153 -           /* p_enc is utf-8, so we're done. */
154 -           enc_str = utf8_str;
155 -       }
156 -       else
157 -       {
158 -           enc_str = string_convert(&conv, utf8_str, lenp);
159 -           vim_free(utf8_str);
160 -       }
161
162 -       convert_setup(&conv, NULL, NULL);
163 -     }
164
165 -     return enc_str;
166 - }
167 - #endif /* FEAT_MBYTE */
168
169   /*
170    * Wait for another process to Close the Clipboard.
171    * Returns TRUE for success.
172 --- 1105,1110 ----
173 ***************
174 *** 1436,1467 ****
175   #endif
176   }
177   
178 - #if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
179 - /*
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.
183 -  */
184 -     void
185 - acp_to_enc(str, str_size, out, outlen)
186 -     char_u    *str;
187 -     int               str_size;
188 -     char_u    **out;
189 -     int               *outlen;
190
191 - {
192 -     LPWSTR    widestr;
193
194 -     MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
195 -     if (widestr != NULL)
196 -     {
197 -       ++*outlen;      /* Include the 0 after the string */
198 -       *out = utf16_to_enc((short_u *)widestr, outlen);
199 -       vim_free(widestr);
200 -     }
201 - }
202 - #endif
203
204   /*
205    * Send the current selection to the clipboard.
206    */
207 --- 1310,1315 ----
208 ***************
209 *** 1626,1631 ****
210 --- 1474,1631 ----
211   
212   #endif /* FEAT_CLIPBOARD */
213   
214 + #if defined(FEAT_MBYTE) || defined(PROTO)
215 + /*
216 +  * Note: the following two functions are only guaranteed to work when using
217 +  * valid MS-Windows codepages or when iconv() is available.
218 +  */
219
220 + /*
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.
226 +  */
227 +     short_u *
228 + enc_to_utf16(char_u *str, int *lenp)
229 + {
230 +     vimconv_T conv;
231 +     WCHAR     *ret;
232 +     char_u    *allocbuf = NULL;
233 +     int               len_loc;
234 +     int               length;
235
236 +     if (lenp == NULL)
237 +     {
238 +       len_loc = (int)STRLEN(str) + 1;
239 +       lenp = &len_loc;
240 +     }
241
242 +     if (enc_codepage > 0)
243 +     {
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);
247 +     }
248 +     else
249 +     {
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)
256 +           return NULL;
257 +       if (conv.vc_type != CONV_NONE)
258 +       {
259 +           str = allocbuf = string_convert(&conv, str, lenp);
260 +           if (str == NULL)
261 +               return NULL;
262 +       }
263 +       convert_setup(&conv, NULL, NULL);
264
265 +       length = utf8_to_utf16(str, *lenp, NULL, NULL);
266 +       ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
267 +       if (ret != NULL)
268 +       {
269 +           utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
270 +           ret[length] = 0;
271 +       }
272
273 +       vim_free(allocbuf);
274 +     }
275
276 +     *lenp = length;
277 +     return (short_u *)ret;
278 + }
279
280 + /*
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.
287 +  */
288 +     char_u *
289 + utf16_to_enc(short_u *str, int *lenp)
290 + {
291 +     vimconv_T conv;
292 +     char_u    *utf8_str = NULL, *enc_str = NULL;
293 +     int               len_loc;
294
295 +     if (lenp == NULL)
296 +     {
297 +       len_loc = (int)wcslen(str) + 1;
298 +       lenp = &len_loc;
299 +     }
300
301 +     if (enc_codepage > 0)
302 +     {
303 +       /* We can do any UTF-16 -> CP### in one pass. */
304 +       int length;
305
306 +       WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
307 +                                           (LPSTR *)&enc_str, &length, 0, 0);
308 +       *lenp = length;
309 +       return enc_str;
310 +     }
311
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)
315 +     {
316 +       *lenp = utf16_to_utf8(str, *lenp, utf8_str);
317
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)
323 +       {
324 +           /* p_enc is utf-8, so we're done. */
325 +           enc_str = utf8_str;
326 +       }
327 +       else
328 +       {
329 +           enc_str = string_convert(&conv, utf8_str, lenp);
330 +           vim_free(utf8_str);
331 +       }
332
333 +       convert_setup(&conv, NULL, NULL);
334 +     }
335
336 +     return enc_str;
337 + }
338 + #endif /* FEAT_MBYTE */
339
340 + #if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
341 + /*
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.
345 +  */
346 +     void
347 + acp_to_enc(str, str_size, out, outlen)
348 +     char_u    *str;
349 +     int               str_size;
350 +     char_u    **out;
351 +     int               *outlen;
352
353 + {
354 +     LPWSTR    widestr;
355
356 +     MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
357 +     if (widestr != NULL)
358 +     {
359 +       ++*outlen;      /* Include the 0 after the string */
360 +       *out = utf16_to_enc((short_u *)widestr, outlen);
361 +       vim_free(widestr);
362 +     }
363 + }
364 + #endif
365
366   
367   /*
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
371 ***************
372 *** 711,712 ****
373 --- 711,714 ----
374   {   /* Add new patch number below this line */
375 + /**/
376 +     223,
377   /**/
378
379 -- 
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.
383
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    ///
This page took 0.056958 seconds and 3 git commands to generate.