changeset 16170:097a56d293c7 v8.1.1090

patch 8.1.1090: MS-Windows: modify_fname() has problems with some 'encoding' commit https://github.com/vim/vim/commit/2d04a91d691ae1ea0c3bf9fc522c3fddc2c9746a Author: Bram Moolenaar <Bram@vim.org> 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)
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Mar 2019 20:15:04 +0100
parents ee589ab1fc15
children 99532bf924ff
files src/eval.c src/version.c
diffstat 2 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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,