|
|
1fa1ff |
To: vim_dev@googlegroups.com
|
|
|
1fa1ff |
Subject: Patch 7.4.016
|
|
|
1fa1ff |
Fcc: outbox
|
|
|
1fa1ff |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
1fa1ff |
Mime-Version: 1.0
|
|
|
1fa1ff |
Content-Type: text/plain; charset=UTF-8
|
|
|
1fa1ff |
Content-Transfer-Encoding: 8bit
|
|
|
1fa1ff |
------------
|
|
|
1fa1ff |
|
|
|
1fa1ff |
Patch 7.4.016
|
|
|
1fa1ff |
Problem: MS-Windows: File name completion doesn't work properly with
|
|
|
1fa1ff |
Chinese characters. (Yue Wu)
|
|
|
1fa1ff |
Solution: Add fname_casew(). (Ken Takata)
|
|
|
1fa1ff |
Files: src/os_win32.c
|
|
|
1fa1ff |
|
|
|
1fa1ff |
|
|
|
1fa1ff |
*** ../vim-7.4.015/src/os_win32.c 2013-08-30 17:11:29.000000000 +0200
|
|
|
1fa1ff |
--- src/os_win32.c 2013-08-30 17:28:30.000000000 +0200
|
|
|
1fa1ff |
***************
|
|
|
1fa1ff |
*** 2500,2508 ****
|
|
|
1fa1ff |
--- 2500,2624 ----
|
|
|
1fa1ff |
}
|
|
|
1fa1ff |
|
|
|
1fa1ff |
|
|
|
1fa1ff |
+ #ifdef FEAT_MBYTE
|
|
|
1fa1ff |
+ /*
|
|
|
1fa1ff |
+ * fname_casew(): Wide version of fname_case(). Set the case of the file name,
|
|
|
1fa1ff |
+ * if it already exists. When "len" is > 0, also expand short to long
|
|
|
1fa1ff |
+ * filenames.
|
|
|
1fa1ff |
+ * Return FAIL if wide functions are not available, OK otherwise.
|
|
|
1fa1ff |
+ * NOTE: much of this is identical to fname_case(), keep in sync!
|
|
|
1fa1ff |
+ */
|
|
|
1fa1ff |
+ static int
|
|
|
1fa1ff |
+ fname_casew(
|
|
|
1fa1ff |
+ WCHAR *name,
|
|
|
1fa1ff |
+ int len)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ WCHAR szTrueName[_MAX_PATH + 2];
|
|
|
1fa1ff |
+ WCHAR szTrueNameTemp[_MAX_PATH + 2];
|
|
|
1fa1ff |
+ WCHAR *ptrue, *ptruePrev;
|
|
|
1fa1ff |
+ WCHAR *porig, *porigPrev;
|
|
|
1fa1ff |
+ int flen;
|
|
|
1fa1ff |
+ WIN32_FIND_DATAW fb;
|
|
|
1fa1ff |
+ HANDLE hFind;
|
|
|
1fa1ff |
+ int c;
|
|
|
1fa1ff |
+ int slen;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ flen = (int)wcslen(name);
|
|
|
1fa1ff |
+ if (flen > _MAX_PATH)
|
|
|
1fa1ff |
+ return OK;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* slash_adjust(name) not needed, already adjusted by fname_case(). */
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* Build the new name in szTrueName[] one component at a time. */
|
|
|
1fa1ff |
+ porig = name;
|
|
|
1fa1ff |
+ ptrue = szTrueName;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ if (iswalpha(porig[0]) && porig[1] == L':')
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ /* copy leading drive letter */
|
|
|
1fa1ff |
+ *ptrue++ = *porig++;
|
|
|
1fa1ff |
+ *ptrue++ = *porig++;
|
|
|
1fa1ff |
+ *ptrue = NUL; /* in case nothing follows */
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ while (*porig != NUL)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ /* copy \ characters */
|
|
|
1fa1ff |
+ while (*porig == psepc)
|
|
|
1fa1ff |
+ *ptrue++ = *porig++;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ ptruePrev = ptrue;
|
|
|
1fa1ff |
+ porigPrev = porig;
|
|
|
1fa1ff |
+ while (*porig != NUL && *porig != psepc)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ *ptrue++ = *porig++;
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ *ptrue = NUL;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* To avoid a slow failure append "\*" when searching a directory,
|
|
|
1fa1ff |
+ * server or network share. */
|
|
|
1fa1ff |
+ wcscpy(szTrueNameTemp, szTrueName);
|
|
|
1fa1ff |
+ slen = (int)wcslen(szTrueNameTemp);
|
|
|
1fa1ff |
+ if (*porig == psepc && slen + 2 < _MAX_PATH)
|
|
|
1fa1ff |
+ wcscpy(szTrueNameTemp + slen, L"\\*");
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* Skip "", "." and "..". */
|
|
|
1fa1ff |
+ if (ptrue > ptruePrev
|
|
|
1fa1ff |
+ && (ptruePrev[0] != L'.'
|
|
|
1fa1ff |
+ || (ptruePrev[1] != NUL
|
|
|
1fa1ff |
+ && (ptruePrev[1] != L'.' || ptruePrev[2] != NUL)))
|
|
|
1fa1ff |
+ && (hFind = FindFirstFileW(szTrueNameTemp, &fb))
|
|
|
1fa1ff |
+ != INVALID_HANDLE_VALUE)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ c = *porig;
|
|
|
1fa1ff |
+ *porig = NUL;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* Only use the match when it's the same name (ignoring case) or
|
|
|
1fa1ff |
+ * expansion is allowed and there is a match with the short name
|
|
|
1fa1ff |
+ * and there is enough room. */
|
|
|
1fa1ff |
+ if (_wcsicoll(porigPrev, fb.cFileName) == 0
|
|
|
1fa1ff |
+ || (len > 0
|
|
|
1fa1ff |
+ && (_wcsicoll(porigPrev, fb.cAlternateFileName) == 0
|
|
|
1fa1ff |
+ && (int)(ptruePrev - szTrueName)
|
|
|
1fa1ff |
+ + (int)wcslen(fb.cFileName) < len)))
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ wcscpy(ptruePrev, fb.cFileName);
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* Look for exact match and prefer it if found. Must be a
|
|
|
1fa1ff |
+ * long name, otherwise there would be only one match. */
|
|
|
1fa1ff |
+ while (FindNextFileW(hFind, &fb))
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ if (*fb.cAlternateFileName != NUL
|
|
|
1fa1ff |
+ && (wcscoll(porigPrev, fb.cFileName) == 0
|
|
|
1fa1ff |
+ || (len > 0
|
|
|
1fa1ff |
+ && (_wcsicoll(porigPrev,
|
|
|
1fa1ff |
+ fb.cAlternateFileName) == 0
|
|
|
1fa1ff |
+ && (int)(ptruePrev - szTrueName)
|
|
|
1fa1ff |
+ + (int)wcslen(fb.cFileName) < len))))
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ wcscpy(ptruePrev, fb.cFileName);
|
|
|
1fa1ff |
+ break;
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ FindClose(hFind);
|
|
|
1fa1ff |
+ *porig = c;
|
|
|
1fa1ff |
+ ptrue = ptruePrev + wcslen(ptruePrev);
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ else if (hFind == INVALID_HANDLE_VALUE
|
|
|
1fa1ff |
+ && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
1fa1ff |
+ return FAIL;
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ wcscpy(name, szTrueName);
|
|
|
1fa1ff |
+ return OK;
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ #endif
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
/*
|
|
|
1fa1ff |
* fname_case(): Set the case of the file name, if it already exists.
|
|
|
1fa1ff |
* When "len" is > 0, also expand short to long filenames.
|
|
|
1fa1ff |
+ * NOTE: much of this is identical to fname_casew(), keep in sync!
|
|
|
1fa1ff |
*/
|
|
|
1fa1ff |
void
|
|
|
1fa1ff |
fname_case(
|
|
|
1fa1ff |
***************
|
|
|
1fa1ff |
*** 2520,2530 ****
|
|
|
1fa1ff |
int slen;
|
|
|
1fa1ff |
|
|
|
1fa1ff |
flen = (int)STRLEN(name);
|
|
|
1fa1ff |
! if (flen == 0 || flen > _MAX_PATH)
|
|
|
1fa1ff |
return;
|
|
|
1fa1ff |
|
|
|
1fa1ff |
slash_adjust(name);
|
|
|
1fa1ff |
|
|
|
1fa1ff |
/* Build the new name in szTrueName[] one component at a time. */
|
|
|
1fa1ff |
porig = name;
|
|
|
1fa1ff |
ptrue = szTrueName;
|
|
|
1fa1ff |
--- 2636,2679 ----
|
|
|
1fa1ff |
int slen;
|
|
|
1fa1ff |
|
|
|
1fa1ff |
flen = (int)STRLEN(name);
|
|
|
1fa1ff |
! if (flen == 0)
|
|
|
1fa1ff |
return;
|
|
|
1fa1ff |
|
|
|
1fa1ff |
slash_adjust(name);
|
|
|
1fa1ff |
|
|
|
1fa1ff |
+ #ifdef FEAT_MBYTE
|
|
|
1fa1ff |
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ WCHAR *p = enc_to_utf16(name, NULL);
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ if (p != NULL)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ char_u *q;
|
|
|
1fa1ff |
+ WCHAR buf[_MAX_PATH + 2];
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ wcscpy(buf, p);
|
|
|
1fa1ff |
+ vim_free(p);
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ if (fname_casew(buf, (len > 0) ? _MAX_PATH : 0) == OK)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ q = utf16_to_enc(buf, NULL);
|
|
|
1fa1ff |
+ if (q != NULL)
|
|
|
1fa1ff |
+ {
|
|
|
1fa1ff |
+ vim_strncpy(name, q, (len > 0) ? len - 1 : flen);
|
|
|
1fa1ff |
+ vim_free(q);
|
|
|
1fa1ff |
+ return;
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ /* Retry with non-wide function (for Windows 98). */
|
|
|
1fa1ff |
+ }
|
|
|
1fa1ff |
+ #endif
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
+ /* If 'enc' is utf-8, flen can be larger than _MAX_PATH.
|
|
|
1fa1ff |
+ * So we should check this after calling wide function. */
|
|
|
1fa1ff |
+ if (flen > _MAX_PATH)
|
|
|
1fa1ff |
+ return;
|
|
|
1fa1ff |
+
|
|
|
1fa1ff |
/* Build the new name in szTrueName[] one component at a time. */
|
|
|
1fa1ff |
porig = name;
|
|
|
1fa1ff |
ptrue = szTrueName;
|
|
|
1fa1ff |
*** ../vim-7.4.015/src/version.c 2013-08-30 17:11:29.000000000 +0200
|
|
|
1fa1ff |
--- src/version.c 2013-08-30 17:15:06.000000000 +0200
|
|
|
1fa1ff |
***************
|
|
|
1fa1ff |
*** 740,741 ****
|
|
|
1fa1ff |
--- 740,743 ----
|
|
|
1fa1ff |
{ /* Add new patch number below this line */
|
|
|
1fa1ff |
+ /**/
|
|
|
1fa1ff |
+ 16,
|
|
|
1fa1ff |
/**/
|
|
|
1fa1ff |
|
|
|
1fa1ff |
--
|
|
|
1fa1ff |
Fingers not found - Pound head on keyboard to continue.
|
|
|
1fa1ff |
|
|
|
1fa1ff |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
1fa1ff |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
1fa1ff |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
1fa1ff |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|