Mercurial > vim
comparison src/ex_cmds2.c @ 15002:9ae60773dd03 v8.1.0512
patch 8.1.0512: 'helplang' default is inconsistent for C and C.UTF-8
commit https://github.com/vim/vim/commit/389ab7122bec99c11ad4ce6d87cc6f38a21e4e40
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 5 20:25:52 2018 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 05 Nov 2018 20:30:08 +0100 |
parents | 162d79d273e6 |
children | 67e3103d6e18 |
comparison
equal
deleted
inserted
replaced
15001:9401618259e9 | 15002:9ae60773dd03 |
---|---|
5357 } | 5357 } |
5358 #endif | 5358 #endif |
5359 | 5359 |
5360 #if defined(FEAT_MULTI_LANG) || defined(PROTO) | 5360 #if defined(FEAT_MULTI_LANG) || defined(PROTO) |
5361 /* | 5361 /* |
5362 * Return TRUE when "lang" starts with a valid language name. | |
5363 * Rejects NULL, empty string, "C", "C.UTF-8" and others. | |
5364 */ | |
5365 static int | |
5366 is_valid_mess_lang(char_u *lang) | |
5367 { | |
5368 return lang != NULL && ASCII_ISALPHA(lang[0]) && ASCII_ISALPHA(lang[1]); | |
5369 } | |
5370 | |
5371 /* | |
5362 * Obtain the current messages language. Used to set the default for | 5372 * Obtain the current messages language. Used to set the default for |
5363 * 'helplang'. May return NULL or an empty string. | 5373 * 'helplang'. May return NULL or an empty string. |
5364 */ | 5374 */ |
5365 char_u * | 5375 char_u * |
5366 get_mess_lang(void) | 5376 get_mess_lang(void) |
5377 * US. */ | 5387 * US. */ |
5378 p = get_locale_val(LC_COLLATE); | 5388 p = get_locale_val(LC_COLLATE); |
5379 # endif | 5389 # endif |
5380 # else | 5390 # else |
5381 p = mch_getenv((char_u *)"LC_ALL"); | 5391 p = mch_getenv((char_u *)"LC_ALL"); |
5382 if (p == NULL || *p == NUL) | 5392 if (!is_valid_mess_lang(p)) |
5383 { | 5393 { |
5384 p = mch_getenv((char_u *)"LC_MESSAGES"); | 5394 p = mch_getenv((char_u *)"LC_MESSAGES"); |
5385 if (p == NULL || *p == NUL) | 5395 if (!is_valid_mess_lang(p)) |
5386 p = mch_getenv((char_u *)"LANG"); | 5396 p = mch_getenv((char_u *)"LANG"); |
5387 } | 5397 } |
5388 # endif | 5398 # endif |
5389 # ifdef WIN32 | 5399 # ifdef WIN32 |
5390 p = gettext_lang(p); | 5400 p = gettext_lang(p); |
5391 # endif | 5401 # endif |
5392 return p; | 5402 return is_valid_mess_lang(p) ? p : NULL; |
5393 } | 5403 } |
5394 #endif | 5404 #endif |
5395 | 5405 |
5396 /* Complicated #if; matches with where get_mess_env() is used below. */ | 5406 /* Complicated #if; matches with where get_mess_env() is used below. */ |
5397 #if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ | 5407 #if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ |