To:
[email protected]
Subject: Patch 6.3a.009
Fcc: outbox
From: Bram Moolenaar <
[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 6.3a.009
Problem: Win32: Completion of filenames does not work properly when
'encoding' differs from the active code page.
Solution: Use wide functions for expanding wildcards when appropriate.
Files: src/misc1.c
*** ../vim-6.3a.008/src/misc1.c Mon May 10 12:49:59 2004
--- src/misc1.c Tue May 11 19:40:42 2004
***************
*** 7828,7833 ****
--- 7828,7837 ----
#ifdef WIN3264
WIN32_FIND_DATA fb;
HANDLE hFind;
+ # ifdef FEAT_MBYTE
+ WIN32_FIND_DATAW wfb;
+ WCHAR *wn = NULL; /* UCS-2 name, NULL when not used. */
+ # endif
#else
struct ffblk fb;
#endif
***************
*** 7917,7923 ****
/* Scan all files in the directory with "dir/ *.*" */
STRCPY(s, "*.*");
#ifdef WIN3264
! hFind = FindFirstFile(buf, &fb);
ok = (hFind != INVALID_HANDLE_VALUE);
#else
/* If we are expanding wildcards we try both files and directories */
--- 7921,7948 ----
/* Scan all files in the directory with "dir/ *.*" */
STRCPY(s, "*.*");
#ifdef WIN3264
! # ifdef FEAT_MBYTE
! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
! {
! /* The active codepage differs from 'encoding'. Attempt using the
! * wide function. If it fails because it is not implemented fall back
! * to the non-wide version (for Windows 98) */
! wn = enc_to_ucs2(buf, NULL);
! if (wn != NULL)
! {
! hFind = FindFirstFileW(wn, &wfb);
! if (hFind == INVALID_HANDLE_VALUE
! && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
! {
! vim_free(wn);
! wn = NULL;
! }
! }
! }
!
! if (wn == NULL)
! # endif
! hFind = FindFirstFile(buf, &fb);
ok = (hFind != INVALID_HANDLE_VALUE);
#else
/* If we are expanding wildcards we try both files and directories */
***************
*** 7928,7934 ****
while (ok)
{
#ifdef WIN3264
! p = (char_u *)fb.cFileName;
#else
p = (char_u *)fb.ff_name;
#endif
--- 7953,7964 ----
while (ok)
{
#ifdef WIN3264
! # ifdef FEAT_MBYTE
! if (wn != NULL)
! p = ucs2_to_enc(wfb.cFileName, NULL); /* p is allocated here */
! else
! # endif
! p = (char_u *)fb.cFileName;
#else
p = (char_u *)fb.ff_name;
#endif
***************
*** 7961,7968 ****
addfile(gap, buf, flags);
}
}
#ifdef WIN3264
! ok = FindNextFile(hFind, &fb);
#else
ok = (findnext(&fb) == 0);
#endif
--- 7991,8007 ----
addfile(gap, buf, flags);
}
}
+
#ifdef WIN3264
! # ifdef FEAT_MBYTE
! if (wn != NULL)
! {
! vim_free(p);
! ok = FindNextFileW(hFind, &wfb);
! }
! else
! # endif
! ok = FindNextFile(hFind, &fb);
#else
ok = (findnext(&fb) == 0);
#endif
***************
*** 7974,7980 ****
STRCPY(s, matchname);
#ifdef WIN3264
FindClose(hFind);
! hFind = FindFirstFile(buf, &fb);
ok = (hFind != INVALID_HANDLE_VALUE);
#else
ok = (findfirst((char *)buf, &fb,
--- 8013,8029 ----
STRCPY(s, matchname);
#ifdef WIN3264
FindClose(hFind);
! # ifdef FEAT_MBYTE
! if (wn != NULL)
! {
! vim_free(wn);
! wn = enc_to_ucs2(buf, NULL);
! if (wn != NULL)
! hFind = FindFirstFileW(wn, &wfb);
! }
! if (wn == NULL)
! # endif
! hFind = FindFirstFile(buf, &fb);
ok = (hFind != INVALID_HANDLE_VALUE);
#else
ok = (findfirst((char *)buf, &fb,
***************
*** 7987,7992 ****
--- 8036,8044 ----
#ifdef WIN3264
FindClose(hFind);
+ # ifdef FEAT_MBYTE
+ vim_free(wn);
+ # endif
#endif
vim_free(buf);
vim_free(regmatch.regprog);
*** ../vim-6.3a.008/src/version.c Tue May 11 17:54:06 2004
--- src/version.c Tue May 11 19:45:23 2004
***************
*** 643,644 ****
--- 643,646 ----
{ /* Add new patch number below this line */
+ /**/
+ 9,
/**/
--
hundred-and-one symptoms of being an internet addict:
250. You've given up the search for the "perfect woman" and instead,
sit in front of the PC until you're just too tired to care.
/// Bram Moolenaar --
[email protected] --
http://www.Moolenaar.net \\\
/// Sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ Project leader for A-A-P --
http://www.A-A-P.org ///
\\\ Buy at Amazon and help AIDS victims --
http://ICCF.nl/click1.html ///