To: vim-dev@vim.org Subject: Patch 6.2.508 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.508 Problem: Win32: "v:lang" does not show the current language for messages if it differs from the other locale settings. Solution: Use the value of the $LC_MESSAGES environment variable. Files: src/ex_cmds2.c *** ../vim-6.2.507/src/ex_cmds2.c Mon Apr 19 20:26:42 2004 --- src/ex_cmds2.c Tue Apr 27 22:26:37 2004 *************** *** 5489,5494 **** --- 5489,5527 ---- } #endif + #if !defined(LC_MESSAGES) \ + && (((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \ + && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))) \ + || defined(FEAT_EVAL)) + static char_u *get_mess_env __ARGS((void)); + + /* + * Get the language used for messages from the environment. + */ + static char_u * + get_mess_env() + { + char_u *p; + + 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"); + if (VIM_ISDIGIT(*p)) /* ignore something like "1043" */ + p = NULL; + # if defined(HAVE_LOCALE_H) || defined(X_LOCALE) + if (p == NULL || *p == NUL) + p = (char_u *)get_locale_val(LC_CTYPE); + # endif + } + } + return p; + } + #endif + #if defined(FEAT_EVAL) || defined(PROTO) /* *************** *** 5508,5516 **** # endif set_vim_var_string(VV_CTYPE, loc, -1); ! /* When LC_MESSAGES isn't defined use the value from LC_CTYPE. */ # if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) && defined(LC_MESSAGES) loc = (char_u *)get_locale_val(LC_MESSAGES); # endif set_vim_var_string(VV_LANG, loc, -1); --- 5541,5552 ---- # endif set_vim_var_string(VV_CTYPE, loc, -1); ! /* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall ! * back to LC_CTYPE if it's empty. */ # if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) && defined(LC_MESSAGES) loc = (char_u *)get_locale_val(LC_MESSAGES); + # else + loc = get_mess_env(); # endif set_vim_var_string(VV_LANG, loc, -1); *************** *** 5573,5587 **** { #ifndef LC_MESSAGES if (what == VIM_LC_MESSAGES) ! { ! 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"); ! } ! } else #endif p = (char_u *)setlocale(what, NULL); --- 5609,5615 ---- { #ifndef LC_MESSAGES if (what == VIM_LC_MESSAGES) ! p = get_mess_env(); else #endif p = (char_u *)setlocale(what, NULL); *** ../vim-6.2.507/src/version.c Tue Apr 27 21:42:53 2004 --- src/version.c Tue Apr 27 22:22:39 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 508, /**/ -- Nothing is fool-proof to a sufficiently talented fool. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///