mirror of
https://github.com/neovim/neovim.git
synced 2026-04-27 17:54:10 +00:00
Merge pull request #9206 from janlazo/vim-8.1.0510
vim-patch:8.1.{510,512}
This commit is contained in:
@@ -3506,7 +3506,12 @@ static char *get_locale_val(int what)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Return true when "lang" starts with a valid language name.
|
||||
// Rejects NULL, empty string, "C", "C.UTF-8" and others.
|
||||
static bool is_valid_mess_lang(char *lang)
|
||||
{
|
||||
return lang != NULL && ASCII_ISALPHA(lang[0]) && ASCII_ISALPHA(lang[1]);
|
||||
}
|
||||
|
||||
/// Obtain the current messages language. Used to set the default for
|
||||
/// 'helplang'. May return NULL or an empty string.
|
||||
@@ -3526,14 +3531,14 @@ char *get_mess_lang(void)
|
||||
# endif
|
||||
# else
|
||||
p = os_getenv("LC_ALL");
|
||||
if (p == NULL) {
|
||||
if (!is_valid_mess_lang(p)) {
|
||||
p = os_getenv("LC_MESSAGES");
|
||||
if (p == NULL) {
|
||||
if (!is_valid_mess_lang(p)) {
|
||||
p = os_getenv("LANG");
|
||||
}
|
||||
}
|
||||
# endif
|
||||
return p;
|
||||
return is_valid_mess_lang(p) ? p : NULL;
|
||||
}
|
||||
|
||||
// Complicated #if; matches with where get_mess_env() is used below.
|
||||
|
||||
@@ -1068,6 +1068,10 @@ void set_helplang_default(const char *lang)
|
||||
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) {
|
||||
p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]);
|
||||
p_hlg[1] = (char_u)TOLOWER_ASC(p_hlg[4]);
|
||||
} else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C') {
|
||||
// any C like setting, such as C.UTF-8, becomes "en"
|
||||
p_hlg[0] = 'e';
|
||||
p_hlg[1] = 'n';
|
||||
}
|
||||
p_hlg[2] = NUL;
|
||||
options[idx].flags |= P_ALLOCED;
|
||||
|
||||
Reference in New Issue
Block a user