Skip to content

Commit 389ab71

Browse files
committed
patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
Problem: 'helplang' default is inconsistent for C and C.UTF-8. Solution: Don't accept a value unless it starts with two letters.
1 parent 9e353b5 commit 389ab71

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/ex_cmds2.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,6 +5358,16 @@ gettext_lang(char_u *name)
53585358
#endif
53595359

53605360
#if defined(FEAT_MULTI_LANG) || defined(PROTO)
5361+
/*
5362+
* Return TRUE when "lang" starts with a valid language name.
5363+
* Rejects NULL, empty string, "C", "C.UTF-8" and others.
5364+
*/
5365+
static int
5366+
is_valid_mess_lang(char_u *lang)
5367+
{
5368+
return lang != NULL && ASCII_ISALPHA(lang[0]) && ASCII_ISALPHA(lang[1]);
5369+
}
5370+
53615371
/*
53625372
* Obtain the current messages language. Used to set the default for
53635373
* 'helplang'. May return NULL or an empty string.
@@ -5379,17 +5389,17 @@ get_mess_lang(void)
53795389
# endif
53805390
# else
53815391
p = mch_getenv((char_u *)"LC_ALL");
5382-
if (p == NULL || *p == NUL)
5392+
if (!is_valid_mess_lang(p))
53835393
{
53845394
p = mch_getenv((char_u *)"LC_MESSAGES");
5385-
if (p == NULL || *p == NUL)
5395+
if (!is_valid_mess_lang(p))
53865396
p = mch_getenv((char_u *)"LANG");
53875397
}
53885398
# endif
53895399
# ifdef WIN32
53905400
p = gettext_lang(p);
53915401
# endif
5392-
return p;
5402+
return is_valid_mess_lang(p) ? p : NULL;
53935403
}
53945404
#endif
53955405

src/version.c

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

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
512,
795797
/**/
796798
511,
797799
/**/

0 commit comments

Comments
 (0)