Skip to content

Commit 01efafa

Browse files
committed
patch 8.0.0850: MS-Windows: error message while starting up may be broken
Problem: MS-Windows: Depending on the console encoding, an error message that is given during startup may be broken. Solution: Convert the message to the console codepage. (Yasuhiro Matsumoto, closes #1927)
1 parent 3c3a80d commit 01efafa

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/message.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,10 +2628,29 @@ msg_puts_printf(char_u *str, int maxlen)
26282628
char_u *s = str;
26292629
char_u buf[4];
26302630
char_u *p;
2631-
26322631
#ifdef WIN3264
2632+
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
2633+
char_u *ccp = NULL;
2634+
2635+
# endif
26332636
if (!(silent_mode && p_verbose == 0))
26342637
mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */
2638+
2639+
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
2640+
if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage)
2641+
{
2642+
int len;
2643+
WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &len);
2644+
2645+
if (widestr != NULL)
2646+
{
2647+
WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, len,
2648+
(LPSTR *)&ccp, &len, 0, 0);
2649+
vim_free(widestr);
2650+
s = str = ccp;
2651+
}
2652+
}
2653+
# endif
26352654
#endif
26362655
while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
26372656
{
@@ -2675,6 +2694,9 @@ msg_puts_printf(char_u *str, int maxlen)
26752694
msg_didout = TRUE; /* assume that line is not empty */
26762695

26772696
#ifdef WIN3264
2697+
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
2698+
vim_free(ccp);
2699+
# endif
26782700
if (!(silent_mode && p_verbose == 0))
26792701
mch_settmode(TMODE_RAW);
26802702
#endif

src/version.c

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

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
850,
772774
/**/
773775
849,
774776
/**/

0 commit comments

Comments
 (0)