To: vim_dev@googlegroups.com Subject: Patch 8.1.0512 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0512 Problem: 'helplang' default is inconsistent for C and C.UTF-8. Solution: Don't accept a value unless it starts with two letters. Files: src/ex_cmds2.c *** ../vim-8.1.0511/src/ex_cmds2.c 2018-10-14 21:40:57.356848425 +0200 --- src/ex_cmds2.c 2018-11-05 20:19:07.922777334 +0100 *************** *** 5359,5364 **** --- 5359,5374 ---- #if defined(FEAT_MULTI_LANG) || defined(PROTO) /* + * Return TRUE when "lang" starts with a valid language name. + * Rejects NULL, empty string, "C", "C.UTF-8" and others. + */ + static int + is_valid_mess_lang(char_u *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. */ *************** *** 5379,5395 **** # endif # else p = mch_getenv((char_u *)"LC_ALL"); ! if (p == NULL || *p == NUL) { p = mch_getenv((char_u *)"LC_MESSAGES"); ! if (p == NULL || *p == NUL) p = mch_getenv((char_u *)"LANG"); } # endif # ifdef WIN32 p = gettext_lang(p); # endif ! return p; } #endif --- 5389,5405 ---- # endif # else p = mch_getenv((char_u *)"LC_ALL"); ! if (!is_valid_mess_lang(p)) { p = mch_getenv((char_u *)"LC_MESSAGES"); ! if (!is_valid_mess_lang(p)) p = mch_getenv((char_u *)"LANG"); } # endif # ifdef WIN32 p = gettext_lang(p); # endif ! return is_valid_mess_lang(p) ? p : NULL; } #endif *** ../vim-8.1.0511/src/version.c 2018-11-04 23:39:33.953644902 +0100 --- src/version.c 2018-11-05 20:24:20.654263866 +0100 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 512, /**/ -- Nothing is impossible for the man who doesn't have to do it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///