]> git.pld-linux.org Git - packages/vim.git/blob - 7.2.049
- updated to 7.2.102
[packages/vim.git] / 7.2.049
1 To: vim-dev@vim.org
2 Subject: Patch 7.2.049 (extra)
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.2.049 (extra)
11 Problem:    Win32: the clipboard doesn't support UTF-16.
12 Solution:   Change UCS-2 support to UTF-16 support. (Jia Yanwei)
13 Files:      src/gui_w32.c, src/gui_w48.c, src/mbyte.c, src/misc1.c,
14             src/os_mswin.c, src/os_win32.c, src/proto/os_mswin.pro
15
16
17 *** ../vim-7.2.048/src/gui_w32.c        Tue Jun 24 23:46:14 2008
18 --- src/gui_w32.c       Thu Nov 20 16:47:10 2008
19 ***************
20 *** 992,998 ****
21                             SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
22                                                                       0, 500);
23   
24 !                           tt_text = enc_to_ucs2(str, NULL);
25                             lpdi->lpszText = tt_text;
26                             /* can't show tooltip if failed */
27                         }
28 --- 992,998 ----
29                             SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
30                                                                       0, 500);
31   
32 !                           tt_text = enc_to_utf16(str, NULL);
33                             lpdi->lpszText = tt_text;
34                             /* can't show tooltip if failed */
35                         }
36 ***************
37 *** 1935,1941 ****
38       if (buf == NULL)
39         return NULL;
40   
41 !     convbuf = ucs2_to_enc(buf, lenp);
42       pImmReleaseContext(hwnd, hIMC);
43       vim_free(buf);
44       return convbuf;
45 --- 1935,1941 ----
46       if (buf == NULL)
47         return NULL;
48   
49 !     convbuf = utf16_to_enc(buf, lenp);
50       pImmReleaseContext(hwnd, hIMC);
51       vim_free(buf);
52       return convbuf;
53 ***************
54 *** 2566,2572 ****
55             {
56                 /* 'encoding' differs from active codepage: convert menu name
57                  * and use wide function */
58 !               wn = enc_to_ucs2(menu->name, NULL);
59                 if (wn != NULL)
60                 {
61                     MENUITEMINFOW       infow;
62 --- 2566,2572 ----
63             {
64                 /* 'encoding' differs from active codepage: convert menu name
65                  * and use wide function */
66 !               wn = enc_to_utf16(menu->name, NULL);
67                 if (wn != NULL)
68                 {
69                     MENUITEMINFOW       infow;
70 ***************
71 *** 2728,2734 ****
72         {
73             /* 'encoding' differs from active codepage: convert menu item name
74              * and use wide function */
75 !           wn = enc_to_ucs2(menu->name, NULL);
76             if (wn != NULL)
77             {
78                 n = InsertMenuW(parent->submenu_id, (UINT)idx,
79 --- 2728,2734 ----
80         {
81             /* 'encoding' differs from active codepage: convert menu item name
82              * and use wide function */
83 !           wn = enc_to_utf16(menu->name, NULL);
84             if (wn != NULL)
85             {
86                 n = InsertMenuW(parent->submenu_id, (UINT)idx,
87 ***************
88 *** 3570,3576 ****
89       if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
90       {
91         /* Not a codepage, use our own conversion function. */
92 !       wn = enc_to_ucs2(lpAnsiIn, NULL);
93         if (wn != NULL)
94         {
95             wcscpy(lpWCStr, wn);
96 --- 3570,3576 ----
97       if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
98       {
99         /* Not a codepage, use our own conversion function. */
100 !       wn = enc_to_utf16(lpAnsiIn, NULL);
101         if (wn != NULL)
102         {
103             wcscpy(lpWCStr, wn);
104 *** ../vim-7.2.048/src/gui_w48.c        Wed Nov 12 13:35:31 2008
105 --- src/gui_w48.c       Thu Nov 20 16:42:32 2008
106 ***************
107 *** 547,553 ****
108         else
109         {
110             len = 1;
111 !           ws = ucs2_to_enc(wstring, &len);
112             if (ws == NULL)
113                 len = 0;
114             else
115 --- 547,553 ----
116         else
117         {
118             len = 1;
119 !           ws = utf16_to_enc(wstring, &len);
120             if (ws == NULL)
121                 len = 0;
122             else
123 ***************
124 *** 2128,2134 ****
125       {
126         /* 'encoding' differs from active codepage: convert text and use wide
127          * function */
128 !       wstr = enc_to_ucs2(str, &wlen);
129         if (wstr != NULL)
130         {
131             n = GetTextExtentPointW(hdc, wstr, wlen, &size);
132 --- 2128,2134 ----
133       {
134         /* 'encoding' differs from active codepage: convert text and use wide
135          * function */
136 !       wstr = enc_to_utf16(str, &wlen);
137         if (wstr != NULL)
138         {
139             n = GetTextExtentPointW(hdc, wstr, wlen, &size);
140 ***************
141 *** 2252,2258 ****
142       {
143         /* 'encoding' differs from active codepage: convert menu name
144          * and use wide function */
145 !       wn = enc_to_ucs2(item_text, NULL);
146         if (wn != NULL)
147         {
148             MENUITEMINFOW       infow;
149 --- 2252,2258 ----
150       {
151         /* 'encoding' differs from active codepage: convert menu name
152          * and use wide function */
153 !       wn = enc_to_utf16(item_text, NULL);
154         if (wn != NULL)
155         {
156             MENUITEMINFOW       infow;
157 ***************
158 *** 2422,2428 ****
159         if (use_unicode)
160         {
161             /* Need to go through Unicode. */
162 !           wstr = enc_to_ucs2(NameBuff, NULL);
163             if (wstr != NULL)
164             {
165                 TCITEMW         tiw;
166 --- 2422,2428 ----
167         if (use_unicode)
168         {
169             /* Need to go through Unicode. */
170 !           wstr = enc_to_utf16(NameBuff, NULL);
171             if (wstr != NULL)
172             {
173                 TCITEMW         tiw;
174 ***************
175 *** 2521,2528 ****
176         WCHAR   *wbuf;
177         int     n;
178   
179 !       /* Convert the title from 'encoding' to ucs2. */
180 !       wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
181         if (wbuf != NULL)
182         {
183             n = SetWindowTextW(hwnd, wbuf);
184 --- 2521,2528 ----
185         WCHAR   *wbuf;
186         int     n;
187   
188 !       /* Convert the title from 'encoding' to UTF-16. */
189 !       wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
190         if (wbuf != NULL)
191         {
192             n = SetWindowTextW(hwnd, wbuf);
193 ***************
194 *** 3222,3228 ****
195         char_u *initdir,
196         char_u *filter)
197   {
198 !     /* We always use the wide function.  This means enc_to_ucs2() must work,
199        * otherwise it fails miserably! */
200       OPENFILENAMEW     fileStruct;
201       WCHAR             fileBuf[MAXPATHL];
202 --- 3222,3228 ----
203         char_u *initdir,
204         char_u *filter)
205   {
206 !     /* We always use the wide function.  This means enc_to_utf16() must work,
207        * otherwise it fails miserably! */
208       OPENFILENAMEW     fileStruct;
209       WCHAR             fileBuf[MAXPATHL];
210 ***************
211 *** 3238,3244 ****
212         fileBuf[0] = NUL;
213       else
214       {
215 !       wp = enc_to_ucs2(dflt, NULL);
216         if (wp == NULL)
217             fileBuf[0] = NUL;
218         else
219 --- 3238,3244 ----
220         fileBuf[0] = NUL;
221       else
222       {
223 !       wp = enc_to_utf16(dflt, NULL);
224         if (wp == NULL)
225             fileBuf[0] = NUL;
226         else
227 ***************
228 *** 3263,3273 ****
229   #endif
230   
231       if (title != NULL)
232 !       titlep = enc_to_ucs2(title, NULL);
233       fileStruct.lpstrTitle = titlep;
234   
235       if (ext != NULL)
236 !       extp = enc_to_ucs2(ext, NULL);
237       fileStruct.lpstrDefExt = extp;
238   
239       fileStruct.lpstrFile = fileBuf;
240 --- 3263,3273 ----
241   #endif
242   
243       if (title != NULL)
244 !       titlep = enc_to_utf16(title, NULL);
245       fileStruct.lpstrTitle = titlep;
246   
247       if (ext != NULL)
248 !       extp = enc_to_utf16(ext, NULL);
249       fileStruct.lpstrDefExt = extp;
250   
251       fileStruct.lpstrFile = fileBuf;
252 ***************
253 *** 3278,3284 ****
254       if (initdir != NULL && *initdir != NUL)
255       {
256         /* Must have backslashes here, no matter what 'shellslash' says */
257 !       initdirp = enc_to_ucs2(initdir, NULL);
258         if (initdirp != NULL)
259         {
260             for (wp = initdirp; *wp != NUL; ++wp)
261 --- 3278,3284 ----
262       if (initdir != NULL && *initdir != NUL)
263       {
264         /* Must have backslashes here, no matter what 'shellslash' says */
265 !       initdirp = enc_to_utf16(initdir, NULL);
266         if (initdirp != NULL)
267         {
268             for (wp = initdirp; *wp != NUL; ++wp)
269 ***************
270 *** 3318,3324 ****
271       vim_free(extp);
272   
273       /* Convert from UCS2 to 'encoding'. */
274 !     p = ucs2_to_enc(fileBuf, NULL);
275       if (p != NULL)
276         /* when out of memory we get garbage for non-ASCII chars */
277         STRCPY(fileBuf, p);
278 --- 3318,3324 ----
279       vim_free(extp);
280   
281       /* Convert from UCS2 to 'encoding'. */
282 !     p = utf16_to_enc(fileBuf, NULL);
283       if (p != NULL)
284         /* when out of memory we get garbage for non-ASCII chars */
285         STRCPY(fileBuf, p);
286 ***************
287 *** 3518,3524 ****
288         {
289   #ifdef FEAT_MBYTE
290             if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
291 !               fnames[i] = ucs2_to_enc(wszFile, NULL);
292             else
293   #endif
294             {
295 --- 3518,3524 ----
296         {
297   #ifdef FEAT_MBYTE
298             if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
299 !               fnames[i] = utf16_to_enc(wszFile, NULL);
300             else
301   #endif
302             {
303 *** ../vim-7.2.048/src/mbyte.c  Thu Nov 20 11:55:53 2008
304 --- src/mbyte.c Thu Nov 20 16:47:41 2008
305 ***************
306 *** 6101,6107 ****
307   
308             /* 1. codepage/UTF-8  ->  ucs-2. */
309             if (vcp->vc_cpfrom == 0)
310 !               tmp_len = utf8_to_ucs2(ptr, len, NULL, NULL);
311             else
312                 tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
313                                                               ptr, len, 0, 0);
314 --- 6101,6107 ----
315   
316             /* 1. codepage/UTF-8  ->  ucs-2. */
317             if (vcp->vc_cpfrom == 0)
318 !               tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
319             else
320                 tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
321                                                               ptr, len, 0, 0);
322 ***************
323 *** 6109,6121 ****
324             if (tmp == NULL)
325                 break;
326             if (vcp->vc_cpfrom == 0)
327 !               utf8_to_ucs2(ptr, len, tmp, unconvlenp);
328             else
329                 MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
330   
331             /* 2. ucs-2  ->  codepage/UTF-8. */
332             if (vcp->vc_cpto == 0)
333 !               retlen = ucs2_to_utf8(tmp, tmp_len, NULL);
334             else
335                 retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
336                                                     tmp, tmp_len, 0, 0, 0, 0);
337 --- 6109,6121 ----
338             if (tmp == NULL)
339                 break;
340             if (vcp->vc_cpfrom == 0)
341 !               utf8_to_utf16(ptr, len, tmp, unconvlenp);
342             else
343                 MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
344   
345             /* 2. ucs-2  ->  codepage/UTF-8. */
346             if (vcp->vc_cpto == 0)
347 !               retlen = utf16_to_utf8(tmp, tmp_len, NULL);
348             else
349                 retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
350                                                     tmp, tmp_len, 0, 0, 0, 0);
351 ***************
352 *** 6123,6129 ****
353             if (retval != NULL)
354             {
355                 if (vcp->vc_cpto == 0)
356 !                   ucs2_to_utf8(tmp, tmp_len, retval);
357                 else
358                     WideCharToMultiByte(vcp->vc_cpto, 0,
359                                           tmp, tmp_len, retval, retlen, 0, 0);
360 --- 6123,6129 ----
361             if (retval != NULL)
362             {
363                 if (vcp->vc_cpto == 0)
364 !                   utf16_to_utf8(tmp, tmp_len, retval);
365                 else
366                     WideCharToMultiByte(vcp->vc_cpto, 0,
367                                           tmp, tmp_len, retval, retlen, 0, 0);
368 *** ../vim-7.2.048/src/misc1.c  Sun Nov  9 13:43:25 2008
369 --- src/misc1.c Thu Nov 20 16:42:59 2008
370 ***************
371 *** 8728,8734 ****
372         /* The active codepage differs from 'encoding'.  Attempt using the
373          * wide function.  If it fails because it is not implemented fall back
374          * to the non-wide version (for Windows 98) */
375 !       wn = enc_to_ucs2(buf, NULL);
376         if (wn != NULL)
377         {
378             hFind = FindFirstFileW(wn, &wfb);
379 --- 8728,8734 ----
380         /* The active codepage differs from 'encoding'.  Attempt using the
381          * wide function.  If it fails because it is not implemented fall back
382          * to the non-wide version (for Windows 98) */
383 !       wn = enc_to_utf16(buf, NULL);
384         if (wn != NULL)
385         {
386             hFind = FindFirstFileW(wn, &wfb);
387 ***************
388 *** 8756,8762 ****
389   #ifdef WIN3264
390   # ifdef FEAT_MBYTE
391         if (wn != NULL)
392 !           p = ucs2_to_enc(wfb.cFileName, NULL);   /* p is allocated here */
393         else
394   # endif
395             p = (char_u *)fb.cFileName;
396 --- 8756,8762 ----
397   #ifdef WIN3264
398   # ifdef FEAT_MBYTE
399         if (wn != NULL)
400 !           p = utf16_to_enc(wfb.cFileName, NULL);   /* p is allocated here */
401         else
402   # endif
403             p = (char_u *)fb.cFileName;
404 ***************
405 *** 8830,8836 ****
406             if (wn != NULL)
407             {
408                 vim_free(wn);
409 !               wn = enc_to_ucs2(buf, NULL);
410                 if (wn != NULL)
411                     hFind = FindFirstFileW(wn, &wfb);
412             }
413 --- 8830,8836 ----
414             if (wn != NULL)
415             {
416                 vim_free(wn);
417 !               wn = enc_to_utf16(buf, NULL);
418                 if (wn != NULL)
419                     hFind = FindFirstFileW(wn, &wfb);
420             }
421 *** ../vim-7.2.048/src/os_mswin.c       Sat Aug  9 19:37:30 2008
422 --- src/os_mswin.c      Thu Nov 20 17:05:10 2008
423 ***************
424 *** 309,315 ****
425         if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
426         {
427             /* Convert the title from 'encoding' to the active codepage. */
428 !           WCHAR       *wp = enc_to_ucs2(title, NULL);
429             int n;
430   
431             if (wp != NULL)
432 --- 309,315 ----
433         if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
434         {
435             /* Convert the title from 'encoding' to the active codepage. */
436 !           WCHAR       *wp = enc_to_utf16(title, NULL);
437             int n;
438   
439             if (wp != NULL)
440 ***************
441 *** 406,415 ****
442              * - invoke _wfullpath()
443              * - convert the result from UCS2 to 'encoding'.
444              */
445 !           wname = enc_to_ucs2(fname, NULL);
446             if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
447             {
448 !               cname = ucs2_to_enc((short_u *)wbuf, NULL);
449                 if (cname != NULL)
450                 {
451                     vim_strncpy(buf, cname, len - 1);
452 --- 406,415 ----
453              * - invoke _wfullpath()
454              * - convert the result from UCS2 to 'encoding'.
455              */
456 !           wname = enc_to_utf16(fname, NULL);
457             if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
458             {
459 !               cname = utf16_to_enc((short_u *)wbuf, NULL);
460                 if (cname != NULL)
461                 {
462                     vim_strncpy(buf, cname, len - 1);
463 ***************
464 *** 507,513 ****
465   # endif
466          )
467       {
468 !       WCHAR   *wp = enc_to_ucs2(buf, NULL);
469         int     n;
470   
471         if (wp != NULL)
472 --- 507,513 ----
473   # endif
474          )
475       {
476 !       WCHAR   *wp = enc_to_utf16(buf, NULL);
477         int     n;
478   
479         if (wp != NULL)
480 ***************
481 *** 668,674 ****
482   #ifdef FEAT_MBYTE
483       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
484       {
485 !       WCHAR   *p = enc_to_ucs2(path, NULL);
486         int     n;
487   
488         if (p != NULL)
489 --- 668,674 ----
490   #ifdef FEAT_MBYTE
491       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
492       {
493 !       WCHAR   *p = enc_to_utf16(path, NULL);
494         int     n;
495   
496         if (p != NULL)
497 ***************
498 *** 891,909 ****
499   
500   #if defined(FEAT_MBYTE) || defined(PROTO)
501   /*
502 !  * Convert an UTF-8 string to UCS-2.
503    * "instr[inlen]" is the input.  "inlen" is in bytes.
504 !  * When "outstr" is NULL only return the number of UCS-2 words produced.
505    * Otherwise "outstr" must be a buffer of sufficient size.
506 !  * Returns the number of UCS-2 words produced.
507    */
508       int
509 ! utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
510   {
511       int               outlen = 0;
512       char_u    *p = instr;
513       int               todo = inlen;
514       int               l;
515   
516       while (todo > 0)
517       {
518 --- 891,910 ----
519   
520   #if defined(FEAT_MBYTE) || defined(PROTO)
521   /*
522 !  * Convert an UTF-8 string to UTF-16.
523    * "instr[inlen]" is the input.  "inlen" is in bytes.
524 !  * When "outstr" is NULL only return the number of UTF-16 words produced.
525    * Otherwise "outstr" must be a buffer of sufficient size.
526 !  * Returns the number of UTF-16 words produced.
527    */
528       int
529 ! utf8_to_utf16(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
530   {
531       int               outlen = 0;
532       char_u    *p = instr;
533       int               todo = inlen;
534       int               l;
535 +     int               ch;
536   
537       while (todo > 0)
538       {
539 ***************
540 *** 917,924 ****
541             break;
542         }
543   
544 !       if (outstr != NULL)
545 !           *outstr++ = utf_ptr2char(p);
546         ++outlen;
547         p += l;
548         todo -= l;
549 --- 918,936 ----
550             break;
551         }
552   
553 !       ch = utf_ptr2char(p);
554 !       if (ch >= 0x10000)
555 !       {
556 !           /* non-BMP character, encoding with surrogate pairs */
557 !           ++outlen;
558 !           if (outstr != NULL)
559 !           {
560 !               *outstr++ = (0xD800 - (0x10000 >> 10)) + (ch >> 10);
561 !               *outstr++ = 0xDC00 | (ch & 0x3FF);
562 !           }
563 !       }
564 !       else if (outstr != NULL)
565 !           *outstr++ = ch;
566         ++outlen;
567         p += l;
568         todo -= l;
569 ***************
570 *** 928,956 ****
571   }
572   
573   /*
574 !  * Convert an UCS-2 string to UTF-8.
575 !  * The input is "instr[inlen]" with "inlen" in number of ucs-2 words.
576    * When "outstr" is NULL only return the required number of bytes.
577    * Otherwise "outstr" must be a buffer of sufficient size.
578    * Return the number of bytes produced.
579    */
580       int
581 ! ucs2_to_utf8(short_u *instr, int inlen, char_u *outstr)
582   {
583       int               outlen = 0;
584       int               todo = inlen;
585       short_u   *p = instr;
586       int               l;
587   
588       while (todo > 0)
589       {
590         if (outstr != NULL)
591         {
592 !           l = utf_char2bytes(*p, outstr);
593             outstr += l;
594         }
595         else
596 !           l = utf_char2len(*p);
597         ++p;
598         outlen += l;
599         --todo;
600 --- 940,981 ----
601   }
602   
603   /*
604 !  * Convert an UTF-16 string to UTF-8.
605 !  * The input is "instr[inlen]" with "inlen" in number of UTF-16 words.
606    * When "outstr" is NULL only return the required number of bytes.
607    * Otherwise "outstr" must be a buffer of sufficient size.
608    * Return the number of bytes produced.
609    */
610       int
611 ! utf16_to_utf8(short_u *instr, int inlen, char_u *outstr)
612   {
613       int               outlen = 0;
614       int               todo = inlen;
615       short_u   *p = instr;
616       int               l;
617 +     int               ch, ch2;
618   
619       while (todo > 0)
620       {
621 +       ch = *p;
622 +       if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1)
623 +       {
624 +           /* surrogate pairs handling */
625 +           ch2 = p[1];
626 +           if (ch2 >= 0xDC00 && ch2 <= 0xDFFF)
627 +           {
628 +               ch = ((ch - 0xD800) << 10) + (ch2 & 0x3FF) + 0x10000;
629 +               ++p;
630 +               --todo;
631 +           }
632 +       }
633         if (outstr != NULL)
634         {
635 !           l = utf_char2bytes(ch, outstr);
636             outstr += l;
637         }
638         else
639 !           l = utf_char2len(ch);
640         ++p;
641         outlen += l;
642         --todo;
643 ***************
644 *** 1079,1092 ****
645    */
646   
647   /*
648 !  * Convert "str" from 'encoding' to UCS-2.
649    * Input in "str" with length "*lenp".  When "lenp" is NULL, use strlen().
650    * Output is returned as an allocated string.  "*lenp" is set to the length of
651    * the result.  A trailing NUL is always added.
652    * Returns NULL when out of memory.
653    */
654       short_u *
655 ! enc_to_ucs2(char_u *str, int *lenp)
656   {
657       vimconv_T conv;
658       WCHAR     *ret;
659 --- 1104,1117 ----
660    */
661   
662   /*
663 !  * Convert "str" from 'encoding' to UTF-16.
664    * Input in "str" with length "*lenp".  When "lenp" is NULL, use strlen().
665    * Output is returned as an allocated string.  "*lenp" is set to the length of
666    * the result.  A trailing NUL is always added.
667    * Returns NULL when out of memory.
668    */
669       short_u *
670 ! enc_to_utf16(char_u *str, int *lenp)
671   {
672       vimconv_T conv;
673       WCHAR     *ret;
674 ***************
675 *** 1102,1108 ****
676   
677       if (enc_codepage > 0)
678       {
679 !       /* We can do any CP### -> UCS-2 in one pass, and we can do it
680          * without iconv() (convert_* may need iconv). */
681         MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
682       }
683 --- 1127,1133 ----
684   
685       if (enc_codepage > 0)
686       {
687 !       /* We can do any CP### -> UTF-16 in one pass, and we can do it
688          * without iconv() (convert_* may need iconv). */
689         MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
690       }
691 ***************
692 *** 1123,1133 ****
693         }
694         convert_setup(&conv, NULL, NULL);
695   
696 !       length = utf8_to_ucs2(str, *lenp, NULL, NULL);
697         ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
698         if (ret != NULL)
699         {
700 !           utf8_to_ucs2(str, *lenp, (short_u *)ret, NULL);
701             ret[length] = 0;
702         }
703   
704 --- 1148,1158 ----
705         }
706         convert_setup(&conv, NULL, NULL);
707   
708 !       length = utf8_to_utf16(str, *lenp, NULL, NULL);
709         ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
710         if (ret != NULL)
711         {
712 !           utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
713             ret[length] = 0;
714         }
715   
716 ***************
717 *** 1139,1145 ****
718   }
719   
720   /*
721 !  * Convert an UCS-2 string to 'encoding'.
722    * Input in "str" with length (counted in wide characters) "*lenp".  When
723    * "lenp" is NULL, use wcslen().
724    * Output is returned as an allocated string.  If "*lenp" is not NULL it is
725 --- 1164,1170 ----
726   }
727   
728   /*
729 !  * Convert an UTF-16 string to 'encoding'.
730    * Input in "str" with length (counted in wide characters) "*lenp".  When
731    * "lenp" is NULL, use wcslen().
732    * Output is returned as an allocated string.  If "*lenp" is not NULL it is
733 ***************
734 *** 1147,1153 ****
735    * Returns NULL when out of memory.
736    */
737       char_u *
738 ! ucs2_to_enc(short_u *str, int *lenp)
739   {
740       vimconv_T conv;
741       char_u    *utf8_str = NULL, *enc_str = NULL;
742 --- 1172,1178 ----
743    * Returns NULL when out of memory.
744    */
745       char_u *
746 ! utf16_to_enc(short_u *str, int *lenp)
747   {
748       vimconv_T conv;
749       char_u    *utf8_str = NULL, *enc_str = NULL;
750 ***************
751 *** 1161,1167 ****
752   
753       if (enc_codepage > 0)
754       {
755 !       /* We can do any UCS-2 -> CP### in one pass. */
756         int length;
757   
758         WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
759 --- 1186,1192 ----
760   
761       if (enc_codepage > 0)
762       {
763 !       /* We can do any UTF-16 -> CP### in one pass. */
764         int length;
765   
766         WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
767 ***************
768 *** 1171,1180 ****
769       }
770   
771       /* Avoid allocating zero bytes, it generates an error message. */
772 !     utf8_str = alloc(ucs2_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
773       if (utf8_str != NULL)
774       {
775 !       *lenp = ucs2_to_utf8(str, *lenp, utf8_str);
776   
777         /* We might be called before we have p_enc set up. */
778         conv.vc_type = CONV_NONE;
779 --- 1196,1205 ----
780       }
781   
782       /* Avoid allocating zero bytes, it generates an error message. */
783 !     utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
784       if (utf8_str != NULL)
785       {
786 !       *lenp = utf16_to_utf8(str, *lenp, utf8_str);
787   
788         /* We might be called before we have p_enc set up. */
789         conv.vc_type = CONV_NONE;
790 ***************
791 *** 1308,1314 ****
792                     if (hMemWstr[str_size] == NUL)
793                         break;
794             }
795 !           to_free = str = ucs2_to_enc((short_u *)hMemWstr, &str_size);
796             GlobalUnlock(hMemW);
797         }
798       }
799 --- 1333,1339 ----
800                     if (hMemWstr[str_size] == NUL)
801                         break;
802             }
803 !           to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
804             GlobalUnlock(hMemW);
805         }
806       }
807 ***************
808 *** 1340,1346 ****
809   
810   # if defined(FEAT_MBYTE) && defined(WIN3264)
811             /* The text is in the active codepage.  Convert to 'encoding',
812 !            * going through UCS-2. */
813             acp_to_enc(str, str_size, &to_free, &maxlen);
814             if (to_free != NULL)
815             {
816 --- 1365,1371 ----
817   
818   # if defined(FEAT_MBYTE) && defined(WIN3264)
819             /* The text is in the active codepage.  Convert to 'encoding',
820 !            * going through UTF-16. */
821             acp_to_enc(str, str_size, &to_free, &maxlen);
822             if (to_free != NULL)
823             {
824 ***************
825 *** 1404,1410 ****
826       if (widestr != NULL)
827       {
828         ++*outlen;      /* Include the 0 after the string */
829 !       *out = ucs2_to_enc((short_u *)widestr, outlen);
830         vim_free(widestr);
831       }
832   }
833 --- 1429,1435 ----
834       if (widestr != NULL)
835       {
836         ++*outlen;      /* Include the 0 after the string */
837 !       *out = utf16_to_enc((short_u *)widestr, outlen);
838         vim_free(widestr);
839       }
840   }
841 ***************
842 *** 1466,1474 ****
843         WCHAR           *out;
844         int             len = metadata.txtlen;
845   
846 !       /* Convert the text to UCS-2. This is put on the clipboard as
847          * CF_UNICODETEXT. */
848 !       out = (WCHAR *)enc_to_ucs2(str, &len);
849         if (out != NULL)
850         {
851             WCHAR *lpszMemW;
852 --- 1491,1499 ----
853         WCHAR           *out;
854         int             len = metadata.txtlen;
855   
856 !       /* Convert the text to UTF-16. This is put on the clipboard as
857          * CF_UNICODETEXT. */
858 !       out = (WCHAR *)enc_to_utf16(str, &len);
859         if (out != NULL)
860         {
861             WCHAR *lpszMemW;
862 ***************
863 *** 1488,1494 ****
864             WideCharToMultiByte(GetACP(), 0, out, len,
865                                                   str, metadata.txtlen, 0, 0);
866   
867 !           /* Allocate memory for the UCS-2 text, add one NUL word to
868              * terminate the string. */
869             hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
870                                                    (len + 1) * sizeof(WCHAR));
871 --- 1513,1519 ----
872             WideCharToMultiByte(GetACP(), 0, out, len,
873                                                   str, metadata.txtlen, 0, 0);
874   
875 !           /* Allocate memory for the UTF-16 text, add one NUL word to
876              * terminate the string. */
877             hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
878                                                    (len + 1) * sizeof(WCHAR));
879 *** ../vim-7.2.048/src/os_win32.c       Thu Jul 24 20:50:30 2008
880 --- src/os_win32.c      Thu Nov 20 16:44:33 2008
881 ***************
882 *** 1587,1593 ****
883   #ifdef FEAT_MBYTE
884       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
885       {
886 !       WCHAR   *p = enc_to_ucs2(name, NULL);
887         WCHAR   fnamew[_MAX_PATH];
888         WCHAR   *dumw;
889         long    n;
890 --- 1587,1593 ----
891   #ifdef FEAT_MBYTE
892       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
893       {
894 !       WCHAR   *p = enc_to_utf16(name, NULL);
895         WCHAR   fnamew[_MAX_PATH];
896         WCHAR   *dumw;
897         long    n;
898 ***************
899 *** 2440,2446 ****
900   
901         if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
902         {
903 !           char_u  *p = ucs2_to_enc(wbuf, NULL);
904   
905             if (p != NULL)
906             {
907 --- 2440,2446 ----
908   
909         if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
910         {
911 !           char_u  *p = utf16_to_enc(wbuf, NULL);
912   
913             if (p != NULL)
914             {
915 ***************
916 *** 2466,2472 ****
917   #ifdef FEAT_MBYTE
918       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
919       {
920 !       WCHAR   *p = enc_to_ucs2(name, NULL);
921         long    n;
922   
923         if (p != NULL)
924 --- 2466,2472 ----
925   #ifdef FEAT_MBYTE
926       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
927       {
928 !       WCHAR   *p = enc_to_utf16(name, NULL);
929         long    n;
930   
931         if (p != NULL)
932 ***************
933 *** 2495,2501 ****
934   #ifdef FEAT_MBYTE
935       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
936       {
937 !       WCHAR   *p = enc_to_ucs2(name, NULL);
938         long    n;
939   
940         if (p != NULL)
941 --- 2495,2501 ----
942   #ifdef FEAT_MBYTE
943       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
944       {
945 !       WCHAR   *p = enc_to_utf16(name, NULL);
946         long    n;
947   
948         if (p != NULL)
949 ***************
950 *** 2522,2528 ****
951       WCHAR     *p = NULL;
952   
953       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
954 !       p = enc_to_ucs2(name, NULL);
955   #endif
956   
957   #ifdef FEAT_MBYTE
958 --- 2522,2528 ----
959       WCHAR     *p = NULL;
960   
961       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
962 !       p = enc_to_utf16(name, NULL);
963   #endif
964   
965   #ifdef FEAT_MBYTE
966 ***************
967 *** 2590,2596 ****
968       WCHAR     *wn = NULL;
969   
970       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
971 !       wn = enc_to_ucs2(fname, NULL);
972       if (wn != NULL)
973       {
974         hFile = CreateFileW(wn,         /* file name */
975 --- 2590,2596 ----
976       WCHAR     *wn = NULL;
977   
978       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
979 !       wn = enc_to_utf16(fname, NULL);
980       if (wn != NULL)
981       {
982         hFile = CreateFileW(wn,         /* file name */
983 ***************
984 *** 4239,4245 ****
985   
986       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
987       {
988 !       wn = enc_to_ucs2(name, NULL);
989         if (wn != NULL)
990         {
991             SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
992 --- 4239,4245 ----
993   
994       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
995       {
996 !       wn = enc_to_utf16(name, NULL);
997         if (wn != NULL)
998         {
999             SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
1000 ***************
1001 *** 4382,4389 ****
1002   
1003       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1004       {
1005 !       wold = enc_to_ucs2((char_u *)pszOldFile, NULL);
1006 !       wnew = enc_to_ucs2((char_u *)pszNewFile, NULL);
1007         if (wold != NULL && wnew != NULL)
1008             retval = mch_wrename(wold, wnew);
1009         vim_free(wold);
1010 --- 4382,4389 ----
1011   
1012       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1013       {
1014 !       wold = enc_to_utf16((char_u *)pszOldFile, NULL);
1015 !       wnew = enc_to_utf16((char_u *)pszNewFile, NULL);
1016         if (wold != NULL && wnew != NULL)
1017             retval = mch_wrename(wold, wnew);
1018         vim_free(wold);
1019 ***************
1020 *** 4492,4498 ****
1021       WCHAR     *wn = NULL;
1022   
1023       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1024 !       wn = enc_to_ucs2(n, NULL);
1025   #endif
1026   
1027       if (mch_isdir(n))
1028 --- 4492,4498 ----
1029       WCHAR     *wn = NULL;
1030   
1031       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1032 !       wn = enc_to_utf16(n, NULL);
1033   #endif
1034   
1035       if (mch_isdir(n))
1036 ***************
1037 *** 4618,4624 ****
1038   
1039   #if defined(FEAT_MBYTE) || defined(PROTO)
1040   /*
1041 !  * Version of open() that may use ucs2 file name.
1042    */
1043       int
1044   mch_open(char *name, int flags, int mode)
1045 --- 4618,4624 ----
1046   
1047   #if defined(FEAT_MBYTE) || defined(PROTO)
1048   /*
1049 !  * Version of open() that may use UTF-16 file name.
1050    */
1051       int
1052   mch_open(char *name, int flags, int mode)
1053 ***************
1054 *** 4630,4636 ****
1055   
1056       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1057       {
1058 !       wn = enc_to_ucs2(name, NULL);
1059         if (wn != NULL)
1060         {
1061             f = _wopen(wn, flags, mode);
1062 --- 4630,4636 ----
1063   
1064       if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
1065       {
1066 !       wn = enc_to_utf16(name, NULL);
1067         if (wn != NULL)
1068         {
1069             f = _wopen(wn, flags, mode);
1070 ***************
1071 *** 4648,4654 ****
1072   }
1073   
1074   /*
1075 !  * Version of fopen() that may use ucs2 file name.
1076    */
1077       FILE *
1078   mch_fopen(char *name, char *mode)
1079 --- 4648,4654 ----
1080   }
1081   
1082   /*
1083 !  * Version of fopen() that may use UTF-16 file name.
1084    */
1085       FILE *
1086   mch_fopen(char *name, char *mode)
1087 ***************
1088 *** 4675,4682 ****
1089         else if (newMode == 'b')
1090             _set_fmode(_O_BINARY);
1091   # endif
1092 !       wn = enc_to_ucs2(name, NULL);
1093 !       wm = enc_to_ucs2(mode, NULL);
1094         if (wn != NULL && wm != NULL)
1095             f = _wfopen(wn, wm);
1096         vim_free(wn);
1097 --- 4675,4682 ----
1098         else if (newMode == 'b')
1099             _set_fmode(_O_BINARY);
1100   # endif
1101 !       wn = enc_to_utf16(name, NULL);
1102 !       wm = enc_to_utf16(mode, NULL);
1103         if (wn != NULL && wm != NULL)
1104             f = _wfopen(wn, wm);
1105         vim_free(wn);
1106 ***************
1107 *** 4776,4783 ****
1108       int                       len;
1109   
1110       /* Convert the file names to wide characters. */
1111 !     fromw = enc_to_ucs2(from, NULL);
1112 !     tow = enc_to_ucs2(to, NULL);
1113       if (fromw != NULL && tow != NULL)
1114       {
1115         /* Open the file for reading. */
1116 --- 4776,4783 ----
1117       int                       len;
1118   
1119       /* Convert the file names to wide characters. */
1120 !     fromw = enc_to_utf16(from, NULL);
1121 !     tow = enc_to_utf16(to, NULL);
1122       if (fromw != NULL && tow != NULL)
1123       {
1124         /* Open the file for reading. */
1125 ***************
1126 *** 5122,5128 ****
1127       for (i = 0; i < used_file_count; ++i)
1128       {
1129         idx = used_file_indexes[i];
1130 !       str = ucs2_to_enc(ArglistW[idx], NULL);
1131         if (str != NULL)
1132         {
1133   #ifdef FEAT_DIFF
1134 --- 5122,5128 ----
1135       for (i = 0; i < used_file_count; ++i)
1136       {
1137         idx = used_file_indexes[i];
1138 !       str = utf16_to_enc(ArglistW[idx], NULL);
1139         if (str != NULL)
1140         {
1141   #ifdef FEAT_DIFF
1142 *** ../vim-7.2.048/src/proto/os_mswin.pro       Sat May  5 19:07:50 2007
1143 --- src/proto/os_mswin.pro      Thu Nov 20 16:41:00 2008
1144 ***************
1145 *** 22,35 ****
1146   int can_end_termcap_mode __ARGS((int give_msg));
1147   int mch_screenmode __ARGS((char_u *arg));
1148   int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
1149 ! int utf8_to_ucs2 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
1150 ! int ucs2_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
1151   void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
1152   void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
1153   int clip_mch_own_selection __ARGS((VimClipboard *cbd));
1154   void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
1155 ! short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp));
1156 ! char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp));
1157   void clip_mch_request_selection __ARGS((VimClipboard *cbd));
1158   void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
1159   void clip_mch_set_selection __ARGS((VimClipboard *cbd));
1160 --- 22,35 ----
1161   int can_end_termcap_mode __ARGS((int give_msg));
1162   int mch_screenmode __ARGS((char_u *arg));
1163   int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
1164 ! int utf8_to_utf16 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
1165 ! int utf16_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
1166   void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
1167   void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
1168   int clip_mch_own_selection __ARGS((VimClipboard *cbd));
1169   void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
1170 ! short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp));
1171 ! char_u *utf16_to_enc __ARGS((short_u *str, int *lenp));
1172   void clip_mch_request_selection __ARGS((VimClipboard *cbd));
1173   void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
1174   void clip_mch_set_selection __ARGS((VimClipboard *cbd));
1175 *** ../vim-7.2.048/src/version.c        Thu Nov 20 16:11:03 2008
1176 --- src/version.c       Thu Nov 20 17:08:07 2008
1177 ***************
1178 *** 678,679 ****
1179 --- 678,681 ----
1180   {   /* Add new patch number below this line */
1181 + /**/
1182 +     49,
1183   /**/
1184
1185 -- 
1186 FIRST HEAD: All right! All right! We'll kill him first and then have tea and
1187             biscuits.
1188                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
1189
1190  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
1191 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
1192 \\\        download, build and distribute -- http://www.A-A-P.org        ///
1193  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.201469 seconds and 3 git commands to generate.