From bd6866f90b6cf7334a9f0d160be6f3b1e5157d51 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 5 Nov 2018 20:06:26 -0500 Subject: vim-patch:8.1.0510: filter test fails when $LANG is C.UTF-8 Problem: Filter test fails when $LANG is C.UTF-8. Solution: Set 'helplang' to "en" for any C language. (Christian Brabandt, closes vim/vim#3577) https://github.com/vim/vim/commit/dcd71cbaedf75dd8e5c5a45c5c2e3ec7ee552dce --- src/nvim/option.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index a0fb2d9e36..4fa99424e8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -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; -- cgit From e0d6894a54b0ed263d8c93197e50ad5fca641f08 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 5 Nov 2018 20:40:32 -0500 Subject: 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. https://github.com/vim/vim/commit/389ab7122bec99c11ad4ce6d87cc6f38a21e4e40 --- src/nvim/ex_cmds2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 90fb7b8bc3..a148f51527 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -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. -- cgit