]> granicus.if.org Git - vim/commitdiff
patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8 v8.1.0512
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Nov 2018 19:25:52 +0000 (20:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Nov 2018 19:25:52 +0000 (20:25 +0100)
Problem:    'helplang' default is inconsistent for C and C.UTF-8.
Solution:   Don't accept a value unless it starts with two letters.

src/ex_cmds2.c
src/version.c

index 9a23f82055b703643bfe3bb5c72edd1723a1dd15..3a4bce8a26f300ae5d850c84d985c86126af2d05 100644 (file)
@@ -5358,6 +5358,16 @@ gettext_lang(char_u *name)
 #endif
 
 #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,17 +5389,17 @@ get_mess_lang(void)
 #  endif
 # else
     p = mch_getenv((char_u *)"LC_ALL");
-    if (p == NULL || *p == NUL)
+    if (!is_valid_mess_lang(p))
     {
        p = mch_getenv((char_u *)"LC_MESSAGES");
-       if (p == NULL || *p == NUL)
+       if (!is_valid_mess_lang(p))
            p = mch_getenv((char_u *)"LANG");
     }
 # endif
 # ifdef WIN32
     p = gettext_lang(p);
 # endif
-    return p;
+    return is_valid_mess_lang(p) ? p : NULL;
 }
 #endif
 
index 8440ce94015758b526d39acc07c0181bf02c612b..36397023149d6f83bce2925258513ac0f0eedfd6 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    512,
 /**/
     511,
 /**/