Patch 8.2.2009

4 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 18, 2020, 9:30:46 AM11/18/20
to vim...@googlegroups.com

Patch 8.2.2009
Problem: MS-Windows: setting $LANG in gvimext only causes problems.
Solution: Do not set $LANG. (Ken Takata, closes #7325)
Files: src/GvimExt/gvimext.cpp


*** ../vim-8.2.2008/src/GvimExt/gvimext.cpp 2019-05-09 15:08:50.000000000 +0200
--- src/GvimExt/gvimext.cpp 2020-11-18 15:28:18.584668399 +0100
***************
*** 161,167 ****
static int dyn_libintl_init(char *dir);
static void dyn_libintl_end(void);

- static wchar_t *oldenv = NULL;
static HINSTANCE hLibintlDLL = 0;
static char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
static char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
--- 161,166 ----
***************
*** 205,221 ****
if (buf != NULL && buf2 != NULL)
{
GetEnvironmentVariableW(L"PATH", buf, len);
! #ifdef _WIN64
_snwprintf(buf2, len2, L"%S\\GvimExt64;%s", dir, buf);
! #else
_snwprintf(buf2, len2, L"%S\\GvimExt32;%s", dir, buf);
! #endif
SetEnvironmentVariableW(L"PATH", buf2);
hLibintlDLL = LoadLibrary(GETTEXT_DLL);
! #ifdef GETTEXT_DLL_ALT
if (!hLibintlDLL)
hLibintlDLL = LoadLibrary(GETTEXT_DLL_ALT);
! #endif
SetEnvironmentVariableW(L"PATH", buf);
}
free(buf);
--- 204,220 ----
if (buf != NULL && buf2 != NULL)
{
GetEnvironmentVariableW(L"PATH", buf, len);
! # ifdef _WIN64
_snwprintf(buf2, len2, L"%S\\GvimExt64;%s", dir, buf);
! # else
_snwprintf(buf2, len2, L"%S\\GvimExt32;%s", dir, buf);
! # endif
SetEnvironmentVariableW(L"PATH", buf2);
hLibintlDLL = LoadLibrary(GETTEXT_DLL);
! # ifdef GETTEXT_DLL_ALT
if (!hLibintlDLL)
hLibintlDLL = LoadLibrary(GETTEXT_DLL_ALT);
! # endif
SetEnvironmentVariableW(L"PATH", buf);
}
free(buf);
***************
*** 273,328 ****
dyn_gettext_load(void)
{
char szBuff[BUFSIZE];
- char szLang[BUFSIZE];
DWORD len;
- HKEY keyhandle;
- int gotlang = 0;
-
- strcpy(szLang, "LANG=");
-
- // First try getting the language from the registry, this can be
- // used to overrule the system language.
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0,
- KEY_READ, &keyhandle) == ERROR_SUCCESS)
- {
- len = BUFSIZE;
- if (RegQueryValueEx(keyhandle, "lang", 0, NULL, (BYTE*)szBuff, &len)
- == ERROR_SUCCESS)
- {
- szBuff[len] = 0;
- strcat(szLang, szBuff);
- gotlang = 1;
- }
- RegCloseKey(keyhandle);
- }
-
- if (!gotlang && getenv("LANG") == NULL)
- {
- // Get the language from the system.
- // Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
- // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
- // only the first two.
- len = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
- (LPTSTR)szBuff, BUFSIZE);
- if (len >= 2 && _strnicmp(szBuff, "en", 2) != 0)
- {
- // There are a few exceptions (probably more)
- if (_strnicmp(szBuff, "cht", 3) == 0
- || _strnicmp(szBuff, "zht", 3) == 0)
- strcpy(szBuff, "zh_TW");
- else if (_strnicmp(szBuff, "chs", 3) == 0
- || _strnicmp(szBuff, "zhc", 3) == 0)
- strcpy(szBuff, "zh_CN");
- else if (_strnicmp(szBuff, "jp", 2) == 0)
- strcpy(szBuff, "ja");
- else
- szBuff[2] = 0; // truncate to two-letter code
- strcat(szLang, szBuff);
- gotlang = 1;
- }
- }
- if (gotlang)
- putenv(szLang);

// Try to locate the runtime files. The path is used to find libintl.dll
// and the vim.mo files.
--- 272,278 ----
***************
*** 378,387 ****
inc_cRefThisDLL()
{
#ifdef FEAT_GETTEXT
! if (g_cRefThisDll == 0) {
dyn_gettext_load();
- oldenv = GetEnvironmentStringsW();
- }
#endif
InterlockedIncrement((LPLONG)&g_cRefThisDll);
}
--- 328,335 ----
inc_cRefThisDLL()
{
#ifdef FEAT_GETTEXT
! if (g_cRefThisDll == 0)
dyn_gettext_load();
#endif
InterlockedIncrement((LPLONG)&g_cRefThisDll);
}
***************
*** 390,402 ****
dec_cRefThisDLL()
{
#ifdef FEAT_GETTEXT
! if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) {
dyn_gettext_free();
- if (oldenv != NULL) {
- FreeEnvironmentStringsW(oldenv);
- oldenv = NULL;
- }
- }
#else
InterlockedDecrement((LPLONG)&g_cRefThisDll);
#endif
--- 338,345 ----
dec_cRefThisDLL()
{
#ifdef FEAT_GETTEXT
! if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0)
dyn_gettext_free();
#else
InterlockedDecrement((LPLONG)&g_cRefThisDll);
#endif
***************
*** 967,974 ****
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
! oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT,
! oldenv, // Use unmodified environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
--- 910,917 ----
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
! 0, // No creation flags.
! NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
***************
*** 1057,1064 ****
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
! oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT,
! oldenv, // Use unmodified environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
--- 1000,1007 ----
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
! 0, // No creation flags.
! NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi) // Pointer to PROCESS_INFORMATION structure.
*** ../vim-8.2.2008/src/version.c 2020-11-18 15:21:46.661732137 +0100
--- src/version.c 2020-11-18 15:29:41.116440943 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2009,
/**/

--
In war we're tough and able.
Quite indefatigable
Between our quests
We sequin vests
And impersonate Clark Gable
It's a busy life in Camelot.
I have to push the pram a lot.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages