Skip to content

Commit 2d04a91

Browse files
committed
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)
1 parent b44b7ad commit 2d04a91

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/eval.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10321,19 +10321,25 @@ modify_fname(
1032110321
# if _WIN32_WINNT >= 0x0500
1032210322
if (vim_strchr(*fnamep, '~') != NULL)
1032310323
{
10324-
/* Expand 8.3 filename to full path. Needed to make sure the same
10325-
* file does not have two different names.
10326-
* Note: problem does not occur if _WIN32_WINNT < 0x0500. */
10327-
p = alloc(_MAX_PATH + 1);
10328-
if (p != NULL)
10324+
// Expand 8.3 filename to full path. Needed to make sure the same
10325+
// file does not have two different names.
10326+
// Note: problem does not occur if _WIN32_WINNT < 0x0500.
10327+
WCHAR *wfname = enc_to_utf16(*fnamep, NULL);
10328+
WCHAR buf[_MAX_PATH];
10329+
10330+
if (wfname != NULL)
1032910331
{
10330-
if (GetLongPathName((LPSTR)*fnamep, (LPSTR)p, _MAX_PATH))
10332+
if (GetLongPathNameW(wfname, buf, _MAX_PATH))
1033110333
{
10332-
vim_free(*bufp);
10333-
*bufp = *fnamep = p;
10334+
char_u *p = utf16_to_enc(buf, NULL);
10335+
10336+
if (p != NULL)
10337+
{
10338+
vim_free(*bufp); // free any allocated file name
10339+
*bufp = *fnamep = p;
10340+
}
1033410341
}
10335-
else
10336-
vim_free(p);
10342+
vim_free(wfname);
1033710343
}
1033810344
}
1033910345
# endif

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,8 @@ static char *(features[]) =
775775

776776
static int included_patches[] =
777777
{ /* Add new patch number below this line */
778+
/**/
779+
1090,
778780
/**/
779781
1089,
780782
/**/

0 commit comments

Comments
 (0)