mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
vim-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.
389ab7122b
This commit is contained in:
@@ -3506,7 +3506,12 @@ static char *get_locale_val(int what)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
/// Obtain the current messages language. Used to set the default for
|
||||||
/// 'helplang'. May return NULL or an empty string.
|
/// 'helplang'. May return NULL or an empty string.
|
||||||
@@ -3526,14 +3531,14 @@ char *get_mess_lang(void)
|
|||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
p = os_getenv("LC_ALL");
|
p = os_getenv("LC_ALL");
|
||||||
if (p == NULL) {
|
if (!is_valid_mess_lang(p)) {
|
||||||
p = os_getenv("LC_MESSAGES");
|
p = os_getenv("LC_MESSAGES");
|
||||||
if (p == NULL) {
|
if (!is_valid_mess_lang(p)) {
|
||||||
p = os_getenv("LANG");
|
p = os_getenv("LANG");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
return p;
|
return is_valid_mess_lang(p) ? p : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complicated #if; matches with where get_mess_env() is used below.
|
// Complicated #if; matches with where get_mess_env() is used below.
|
||||||
|
Reference in New Issue
Block a user