]> granicus.if.org Git - vim/commitdiff
patch 8.1.1090: MS-Windows: modify_fname() has problems with some 'encoding' v8.1.1090
authorBram Moolenaar <Bram@vim.org>
Sat, 30 Mar 2019 19:04:08 +0000 (20:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 30 Mar 2019 19:04:08 +0000 (20:04 +0100)
Problem:    MS-Windows: modify_fname() has problems with some 'encoding'.
Solution:   Use GetLongPathNameW() instead of GetLongPathName(). (Ken Takata,
            closes #4007)

src/eval.c
src/version.c

index 2a138d56cf8a760e48af914367e7db2a0c845ac3..ec2dc9aa4aa7423a13a4ee1368670ff4e05feefe 100644 (file)
@@ -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
index 21152b0ec1f927e7e9cd9fa997ac707838678b8d..0f62b83a4df10038db40b01bfc4550386a921436 100644 (file)
@@ -775,6 +775,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1090,
 /**/
     1089,
 /**/