Skip to content

Commit aa8c48f

Browse files
committed
updated for version 7.4.015
Problem: MS-Windows: Detecting node type does not work for multi-byte characters. Solution: Use wide character function when needed. (Ken Takata)
1 parent a573223 commit aa8c48f

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

src/os_win32.c

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,21 +3107,51 @@ mch_nodetype(char_u *name)
31073107
{
31083108
HANDLE hFile;
31093109
int type;
3110+
#ifdef FEAT_MBYTE
3111+
WCHAR *wn = NULL;
3112+
#endif
31103113

31113114
/* We can't open a file with a name "\\.\con" or "\\.\prn" and trying to
31123115
* read from it later will cause Vim to hang. Thus return NODE_WRITABLE
31133116
* here. */
31143117
if (STRNCMP(name, "\\\\.\\", 4) == 0)
31153118
return NODE_WRITABLE;
31163119

3117-
hFile = CreateFile(name, /* file name */
3118-
GENERIC_WRITE, /* access mode */
3119-
0, /* share mode */
3120-
NULL, /* security descriptor */
3121-
OPEN_EXISTING, /* creation disposition */
3122-
0, /* file attributes */
3123-
NULL); /* handle to template file */
3120+
#ifdef FEAT_MBYTE
3121+
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
3122+
{
3123+
wn = enc_to_utf16(name, NULL);
3124+
if (wn != NULL)
3125+
{
3126+
hFile = CreateFileW(wn, /* file name */
3127+
GENERIC_WRITE, /* access mode */
3128+
0, /* share mode */
3129+
NULL, /* security descriptor */
3130+
OPEN_EXISTING, /* creation disposition */
3131+
0, /* file attributes */
3132+
NULL); /* handle to template file */
3133+
if (hFile == INVALID_HANDLE_VALUE
3134+
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
3135+
{
3136+
/* Retry with non-wide function (for Windows 98). */
3137+
vim_free(wn);
3138+
wn = NULL;
3139+
}
3140+
}
3141+
}
3142+
if (wn == NULL)
3143+
#endif
3144+
hFile = CreateFile(name, /* file name */
3145+
GENERIC_WRITE, /* access mode */
3146+
0, /* share mode */
3147+
NULL, /* security descriptor */
3148+
OPEN_EXISTING, /* creation disposition */
3149+
0, /* file attributes */
3150+
NULL); /* handle to template file */
31243151

3152+
#ifdef FEAT_MBYTE
3153+
vim_free(wn);
3154+
#endif
31253155
if (hFile == INVALID_HANDLE_VALUE)
31263156
return NODE_NORMAL;
31273157

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
15,
741743
/**/
742744
14,
743745
/**/

0 commit comments

Comments
 (0)