aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Morris2021-02-19 08:36:55 -0800
committerGlenn Morris2021-02-19 08:36:55 -0800
commit07b22b6b5d196b292f3cb03749b09092b2197cf9 (patch)
tree41580272d6339e71c3e06799a1659e250258a455 /src
parent6830199984b9964286fda8e4c904ce84aa68e514 (diff)
parent4712c75ab853ee77587dbc1910cc7c0401e02aa0 (diff)
downloademacs-07b22b6b5d196b292f3cb03749b09092b2197cf9.tar.gz
emacs-07b22b6b5d196b292f3cb03749b09092b2197cf9.zip
Merge from origin/emacs-27
4712c75ab8 Clarify when activate-mark-hook is run abedf3a865 Fix language-environment and font selection on MS-Windows 8b8708eadd Fix example in Sequence Functions node in the manual
Diffstat (limited to 'src')
-rw-r--r--src/w32.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/w32.c b/src/w32.c
index a3c247b8b0d..aade8024811 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -346,6 +346,7 @@ static BOOL g_b_init_get_adapters_addresses;
346static BOOL g_b_init_reg_open_key_ex_w; 346static BOOL g_b_init_reg_open_key_ex_w;
347static BOOL g_b_init_reg_query_value_ex_w; 347static BOOL g_b_init_reg_query_value_ex_w;
348static BOOL g_b_init_expand_environment_strings_w; 348static BOOL g_b_init_expand_environment_strings_w;
349static BOOL g_b_init_get_user_default_ui_language;
349 350
350BOOL g_b_init_compare_string_w; 351BOOL g_b_init_compare_string_w;
351BOOL g_b_init_debug_break_process; 352BOOL g_b_init_debug_break_process;
@@ -533,6 +534,7 @@ DWORD multiByteToWideCharFlags;
533typedef LONG (WINAPI *RegOpenKeyExW_Proc) (HKEY,LPCWSTR,DWORD,REGSAM,PHKEY); 534typedef LONG (WINAPI *RegOpenKeyExW_Proc) (HKEY,LPCWSTR,DWORD,REGSAM,PHKEY);
534typedef LONG (WINAPI *RegQueryValueExW_Proc) (HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD); 535typedef LONG (WINAPI *RegQueryValueExW_Proc) (HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
535typedef DWORD (WINAPI *ExpandEnvironmentStringsW_Proc) (LPCWSTR,LPWSTR,DWORD); 536typedef DWORD (WINAPI *ExpandEnvironmentStringsW_Proc) (LPCWSTR,LPWSTR,DWORD);
537typedef LANGID (WINAPI *GetUserDefaultUILanguage_Proc) (void);
536 538
537 /* ** A utility function ** */ 539 /* ** A utility function ** */
538static BOOL 540static BOOL
@@ -1489,6 +1491,28 @@ expand_environment_strings_w (LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
1489 return s_pfn_Expand_Environment_Strings_w (lpSrc, lpDst, nSize); 1491 return s_pfn_Expand_Environment_Strings_w (lpSrc, lpDst, nSize);
1490} 1492}
1491 1493
1494static LANGID WINAPI
1495get_user_default_ui_language (void)
1496{
1497 static GetUserDefaultUILanguage_Proc s_pfn_GetUserDefaultUILanguage = NULL;
1498 HMODULE hm_kernel32 = NULL;
1499
1500 if (is_windows_9x () == TRUE)
1501 return 0;
1502
1503 if (g_b_init_get_user_default_ui_language == 0)
1504 {
1505 g_b_init_get_user_default_ui_language = 1;
1506 hm_kernel32 = LoadLibrary ("Kernel32.dll");
1507 if (hm_kernel32)
1508 s_pfn_GetUserDefaultUILanguage = (GetUserDefaultUILanguage_Proc)
1509 get_proc_addr (hm_kernel32, "GetUserDefaultUILanguage");
1510 }
1511 if (s_pfn_GetUserDefaultUILanguage == NULL)
1512 return 0;
1513 return s_pfn_GetUserDefaultUILanguage ();
1514}
1515
1492 1516
1493 1517
1494/* Return 1 if P is a valid pointer to an object of size SIZE. Return 1518/* Return 1 if P is a valid pointer to an object of size SIZE. Return
@@ -2947,6 +2971,32 @@ init_environment (char ** argv)
2947 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, 2971 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
2948 locale_name, sizeof (locale_name))) 2972 locale_name, sizeof (locale_name)))
2949 { 2973 {
2974 /* Microsoft are migrating away of locale IDs, replacing them
2975 with locale names, such as "en-US", and are therefore
2976 deprecating the APIs which use LCID etc. As part of that
2977 deprecation, they don't bother inventing LCID and LANGID
2978 codes for new locales and language/culture combinations;
2979 instead, those get LCID of 0xC000 and LANGID of 0x2000, for
2980 which the LCID/LANGID oriented APIs return "ZZZ" as the
2981 "language name". Such "language name" is useless for our
2982 purposes. So we instead use the default UI language, in the
2983 hope of getting something usable. */
2984 if (strcmp (locale_name, "ZZZ") == 0)
2985 {
2986 LANGID lang_id = get_user_default_ui_language ();
2987
2988 if (lang_id != 0)
2989 {
2990 /* Disregard the sorting order differences between cultures. */
2991 LCID def_lcid = MAKELCID (lang_id, SORT_DEFAULT);
2992 char locale_name_def[32];
2993
2994 if (GetLocaleInfo (def_lcid,
2995 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
2996 locale_name_def, sizeof (locale_name_def)))
2997 strcpy (locale_name, locale_name_def);
2998 }
2999 }
2950 for (i = 0; i < N_ENV_VARS; i++) 3000 for (i = 0; i < N_ENV_VARS; i++)
2951 { 3001 {
2952 if (strcmp (env_vars[i].name, "LANG") == 0) 3002 if (strcmp (env_vars[i].name, "LANG") == 0)
@@ -10580,6 +10630,7 @@ globals_of_w32 (void)
10580 g_b_init_expand_environment_strings_w = 0; 10630 g_b_init_expand_environment_strings_w = 0;
10581 g_b_init_compare_string_w = 0; 10631 g_b_init_compare_string_w = 0;
10582 g_b_init_debug_break_process = 0; 10632 g_b_init_debug_break_process = 0;
10633 g_b_init_get_user_default_ui_language = 0;
10583 num_of_processors = 0; 10634 num_of_processors = 0;
10584 /* The following sets a handler for shutdown notifications for 10635 /* The following sets a handler for shutdown notifications for
10585 console apps. This actually applies to Emacs in both console and 10636 console apps. This actually applies to Emacs in both console and