Skip to content

Commit

Permalink
patch 8.0.0850: MS-Windows: error message while starting up may be br…
Browse files Browse the repository at this point in the history
…oken

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)
  • Loading branch information
brammool committed Aug 3, 2017
1 parent 3c3a80d commit 01efafa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/message.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2628,10 +2628,29 @@ msg_puts_printf(char_u *str, int maxlen)
char_u *s = str; char_u *s = str;
char_u buf[4]; char_u buf[4];
char_u *p; char_u *p;

#ifdef WIN3264 #ifdef WIN3264
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
char_u *ccp = NULL;

# endif
if (!(silent_mode && p_verbose == 0)) if (!(silent_mode && p_verbose == 0))
mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */ mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */

# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage)
{
int len;
WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &len);

if (widestr != NULL)
{
WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, len,
(LPSTR *)&ccp, &len, 0, 0);
vim_free(widestr);
s = str = ccp;
}
}
# endif
#endif #endif
while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL) while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
{ {
Expand Down Expand Up @@ -2675,6 +2694,9 @@ msg_puts_printf(char_u *str, int maxlen)
msg_didout = TRUE; /* assume that line is not empty */ msg_didout = TRUE; /* assume that line is not empty */


#ifdef WIN3264 #ifdef WIN3264
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
vim_free(ccp);
# endif
if (!(silent_mode && p_verbose == 0)) if (!(silent_mode && p_verbose == 0))
mch_settmode(TMODE_RAW); mch_settmode(TMODE_RAW);
#endif #endif
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
850,
/**/ /**/
849, 849,
/**/ /**/
Expand Down

0 comments on commit 01efafa

Please sign in to comment.