# HG changeset patch # User Bram Moolenaar # Date 1553973304 -3600 # Node ID 097a56d293c7bb8ca63f41210dd6fc3ec1a0d092 # Parent ee589ab1fc15804af24b81e2f99a95eaae96b8be patch 8.1.1090: MS-Windows: modify_fname() has problems with some 'encoding' commit https://github.com/vim/vim/commit/2d04a91d691ae1ea0c3bf9fc522c3fddc2c9746a Author: Bram Moolenaar Date: Sat Mar 30 20:04:08 2019 +0100 patch 8.1.1090: MS-Windows: modify_fname() has problems with some 'encoding' Problem: MS-Windows: modify_fname() has problems with some 'encoding'. Solution: Use GetLongPathNameW() instead of GetLongPathName(). (Ken Takata, closes #4007) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -10321,19 +10321,25 @@ repeat: # if _WIN32_WINNT >= 0x0500 if (vim_strchr(*fnamep, '~') != NULL) { - /* Expand 8.3 filename to full path. Needed to make sure the same - * file does not have two different names. - * Note: problem does not occur if _WIN32_WINNT < 0x0500. */ - p = alloc(_MAX_PATH + 1); - if (p != NULL) - { - if (GetLongPathName((LPSTR)*fnamep, (LPSTR)p, _MAX_PATH)) - { - vim_free(*bufp); - *bufp = *fnamep = p; - } - else - vim_free(p); + // Expand 8.3 filename to full path. Needed to make sure the same + // file does not have two different names. + // Note: problem does not occur if _WIN32_WINNT < 0x0500. + WCHAR *wfname = enc_to_utf16(*fnamep, NULL); + WCHAR buf[_MAX_PATH]; + + if (wfname != NULL) + { + if (GetLongPathNameW(wfname, buf, _MAX_PATH)) + { + char_u *p = utf16_to_enc(buf, NULL); + + if (p != NULL) + { + vim_free(*bufp); // free any allocated file name + *bufp = *fnamep = p; + } + } + vim_free(wfname); } } # endif diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -776,6 +776,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1090, +/**/ 1089, /**/ 1088,