summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-03-30 20:04:08 +0100
committerBram Moolenaar <Bram@vim.org>2019-03-30 20:04:08 +0100
commit2d04a91d691ae1ea0c3bf9fc522c3fddc2c9746a (patch)
tree331d2cc3edbc259fea9c172fdff558449a3aee62 /src/eval.c
parentb44b7add8ae8e15328b4f68c3caf511bd9aaac8c (diff)
downloadvim-git-2d04a91d691ae1ea0c3bf9fc522c3fddc2c9746a.tar.gz
patch 8.1.1090: MS-Windows: modify_fname() has problems with some 'encoding'v8.1.1090
Problem: MS-Windows: modify_fname() has problems with some 'encoding'. Solution: Use GetLongPathNameW() instead of GetLongPathName(). (Ken Takata, closes #4007)
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/eval.c b/src/eval.c
index 2a138d56c..ec2dc9aa4 100644
--- 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)
+ // 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 (GetLongPathName((LPSTR)*fnamep, (LPSTR)p, _MAX_PATH))
+ if (GetLongPathNameW(wfname, buf, _MAX_PATH))
{
- vim_free(*bufp);
- *bufp = *fnamep = p;
+ char_u *p = utf16_to_enc(buf, NULL);
+
+ if (p != NULL)
+ {
+ vim_free(*bufp); // free any allocated file name
+ *bufp = *fnamep = p;
+ }
}
- else
- vim_free(p);
+ vim_free(wfname);
}
}
# endif