Skip to content

Commit 3823192

Browse files
committed
patch 8.2.2009: MS-Windows: setting $LANG in gvimext only causes problems
Problem: MS-Windows: setting $LANG in gvimext only causes problems. Solution: Do not set $LANG. (Ken Takata, closes #7325)
1 parent 032f40a commit 3823192

2 files changed

Lines changed: 13 additions & 68 deletions

File tree

src/GvimExt/gvimext.cpp

Lines changed: 11 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ static char *null_libintl_bindtextdomain(const char *, const char *);
161161
static int dyn_libintl_init(char *dir);
162162
static void dyn_libintl_end(void);
163163

164-
static wchar_t *oldenv = NULL;
165164
static HINSTANCE hLibintlDLL = 0;
166165
static char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
167166
static char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
@@ -205,17 +204,17 @@ dyn_libintl_init(char *dir)
205204
if (buf != NULL && buf2 != NULL)
206205
{
207206
GetEnvironmentVariableW(L"PATH", buf, len);
208-
#ifdef _WIN64
207+
# ifdef _WIN64
209208
_snwprintf(buf2, len2, L"%S\\GvimExt64;%s", dir, buf);
210-
#else
209+
# else
211210
_snwprintf(buf2, len2, L"%S\\GvimExt32;%s", dir, buf);
212-
#endif
211+
# endif
213212
SetEnvironmentVariableW(L"PATH", buf2);
214213
hLibintlDLL = LoadLibrary(GETTEXT_DLL);
215-
#ifdef GETTEXT_DLL_ALT
214+
# ifdef GETTEXT_DLL_ALT
216215
if (!hLibintlDLL)
217216
hLibintlDLL = LoadLibrary(GETTEXT_DLL_ALT);
218-
#endif
217+
# endif
219218
SetEnvironmentVariableW(L"PATH", buf);
220219
}
221220
free(buf);
@@ -273,56 +272,7 @@ null_libintl_textdomain(const char* /* domainname */)
273272
dyn_gettext_load(void)
274273
{
275274
char szBuff[BUFSIZE];
276-
char szLang[BUFSIZE];
277275
DWORD len;
278-
HKEY keyhandle;
279-
int gotlang = 0;
280-
281-
strcpy(szLang, "LANG=");
282-
283-
// First try getting the language from the registry, this can be
284-
// used to overrule the system language.
285-
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0,
286-
KEY_READ, &keyhandle) == ERROR_SUCCESS)
287-
{
288-
len = BUFSIZE;
289-
if (RegQueryValueEx(keyhandle, "lang", 0, NULL, (BYTE*)szBuff, &len)
290-
== ERROR_SUCCESS)
291-
{
292-
szBuff[len] = 0;
293-
strcat(szLang, szBuff);
294-
gotlang = 1;
295-
}
296-
RegCloseKey(keyhandle);
297-
}
298-
299-
if (!gotlang && getenv("LANG") == NULL)
300-
{
301-
// Get the language from the system.
302-
// Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
303-
// LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
304-
// only the first two.
305-
len = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
306-
(LPTSTR)szBuff, BUFSIZE);
307-
if (len >= 2 && _strnicmp(szBuff, "en", 2) != 0)
308-
{
309-
// There are a few exceptions (probably more)
310-
if (_strnicmp(szBuff, "cht", 3) == 0
311-
|| _strnicmp(szBuff, "zht", 3) == 0)
312-
strcpy(szBuff, "zh_TW");
313-
else if (_strnicmp(szBuff, "chs", 3) == 0
314-
|| _strnicmp(szBuff, "zhc", 3) == 0)
315-
strcpy(szBuff, "zh_CN");
316-
else if (_strnicmp(szBuff, "jp", 2) == 0)
317-
strcpy(szBuff, "ja");
318-
else
319-
szBuff[2] = 0; // truncate to two-letter code
320-
strcat(szLang, szBuff);
321-
gotlang = 1;
322-
}
323-
}
324-
if (gotlang)
325-
putenv(szLang);
326276

327277
// Try to locate the runtime files. The path is used to find libintl.dll
328278
// and the vim.mo files.
@@ -378,10 +328,8 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */)
378328
inc_cRefThisDLL()
379329
{
380330
#ifdef FEAT_GETTEXT
381-
if (g_cRefThisDll == 0) {
331+
if (g_cRefThisDll == 0)
382332
dyn_gettext_load();
383-
oldenv = GetEnvironmentStringsW();
384-
}
385333
#endif
386334
InterlockedIncrement((LPLONG)&g_cRefThisDll);
387335
}
@@ -390,13 +338,8 @@ inc_cRefThisDLL()
390338
dec_cRefThisDLL()
391339
{
392340
#ifdef FEAT_GETTEXT
393-
if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) {
341+
if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0)
394342
dyn_gettext_free();
395-
if (oldenv != NULL) {
396-
FreeEnvironmentStringsW(oldenv);
397-
oldenv = NULL;
398-
}
399-
}
400343
#else
401344
InterlockedDecrement((LPLONG)&g_cRefThisDll);
402345
#endif
@@ -967,8 +910,8 @@ STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
967910
NULL, // Process handle not inheritable.
968911
NULL, // Thread handle not inheritable.
969912
FALSE, // Set handle inheritance to FALSE.
970-
oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT,
971-
oldenv, // Use unmodified environment block.
913+
0, // No creation flags.
914+
NULL, // Use parent's environment block.
972915
NULL, // Use parent's starting directory.
973916
&si, // Pointer to STARTUPINFO structure.
974917
&pi) // Pointer to PROCESS_INFORMATION structure.
@@ -1057,8 +1000,8 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
10571000
NULL, // Process handle not inheritable.
10581001
NULL, // Thread handle not inheritable.
10591002
FALSE, // Set handle inheritance to FALSE.
1060-
oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT,
1061-
oldenv, // Use unmodified environment block.
1003+
0, // No creation flags.
1004+
NULL, // Use parent's environment block.
10621005
NULL, // Use parent's starting directory.
10631006
&si, // Pointer to STARTUPINFO structure.
10641007
&pi) // Pointer to PROCESS_INFORMATION structure.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2009,
753755
/**/
754756
2008,
755757
/**/

0 commit comments

Comments
 (0)