diff options
| author | Jussi Lahdenniemi | 2016-01-16 11:46:14 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-01-16 11:46:14 +0200 |
| commit | 86e45139698fe773ffb4efbe59387f90201b80c8 (patch) | |
| tree | 591778934aa994ac1b839a9fe2fb3dc40e8ecfcc /src/w32.c | |
| parent | 4e96521948b74b8e91eb5a6bca18427f8243bc98 (diff) | |
| download | emacs-86e45139698fe773ffb4efbe59387f90201b80c8.tar.gz emacs-86e45139698fe773ffb4efbe59387f90201b80c8.zip | |
Fix incompatbilities with MS-Windows 2000 and older
* src/w32.c <multiByteToWideCharFlags>: New global variable.
(filename_to_utf16, filename_from_ansi, check_windows_init_file):
Use it instead of the literal MB_ERR_INVALID_CHARS.
(maybe_load_unicows_dll): Initialize multiByteToWideCharFlags as
appropriate for the underlying OS version. For details, see
http://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00835.html.
* src/w32.h: Declare multiByteToWideCharFlags.
* src/w32fns.c (Fx_file_dialog, Fw32_shell_execute)
(add_tray_notification): Use multiByteToWideCharFlags instead of
the literal MB_ERR_INVALID_CHARS.
(_resetstkoflw_proc): New typedef.
(w32_reset_stack_overflow_guard): Call _resetstkoflw via a
pointer, as this function is absent in msvcrt.dll shipped with W2K
and older systems.
Copyright-paperwork-exempt: yes
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 23 |
1 files changed, 15 insertions, 8 deletions
| @@ -486,6 +486,7 @@ typedef DWORD (WINAPI *GetAdaptersInfo_Proc) ( | |||
| 486 | 486 | ||
| 487 | int (WINAPI *pMultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int); | 487 | int (WINAPI *pMultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int); |
| 488 | int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); | 488 | int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); |
| 489 | DWORD multiByteToWideCharFlags; | ||
| 489 | 490 | ||
| 490 | /* ** A utility function ** */ | 491 | /* ** A utility function ** */ |
| 491 | static BOOL | 492 | static BOOL |
| @@ -1552,8 +1553,8 @@ codepage_for_filenames (CPINFO *cp_info) | |||
| 1552 | int | 1553 | int |
| 1553 | filename_to_utf16 (const char *fn_in, wchar_t *fn_out) | 1554 | filename_to_utf16 (const char *fn_in, wchar_t *fn_out) |
| 1554 | { | 1555 | { |
| 1555 | int result = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, fn_in, -1, | 1556 | int result = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, fn_in, |
| 1556 | fn_out, MAX_PATH); | 1557 | -1, fn_out, MAX_PATH); |
| 1557 | 1558 | ||
| 1558 | if (!result) | 1559 | if (!result) |
| 1559 | { | 1560 | { |
| @@ -1643,8 +1644,8 @@ filename_from_ansi (const char *fn_in, char *fn_out) | |||
| 1643 | { | 1644 | { |
| 1644 | wchar_t fn_utf16[MAX_PATH]; | 1645 | wchar_t fn_utf16[MAX_PATH]; |
| 1645 | int codepage = codepage_for_filenames (NULL); | 1646 | int codepage = codepage_for_filenames (NULL); |
| 1646 | int result = pMultiByteToWideChar (codepage, MB_ERR_INVALID_CHARS, fn_in, -1, | 1647 | int result = pMultiByteToWideChar (codepage, multiByteToWideCharFlags, fn_in, |
| 1647 | fn_utf16, MAX_PATH); | 1648 | -1, fn_utf16, MAX_PATH); |
| 1648 | 1649 | ||
| 1649 | if (!result) | 1650 | if (!result) |
| 1650 | { | 1651 | { |
| @@ -9134,14 +9135,14 @@ check_windows_init_file (void) | |||
| 9134 | "not unpacked properly.\nSee the README.W32 file in the " | 9135 | "not unpacked properly.\nSee the README.W32 file in the " |
| 9135 | "top-level Emacs directory for more information.", | 9136 | "top-level Emacs directory for more information.", |
| 9136 | init_file_name, load_path); | 9137 | init_file_name, load_path); |
| 9137 | needed = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, | 9138 | needed = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 9138 | -1, NULL, 0); | 9139 | buffer, -1, NULL, 0); |
| 9139 | if (needed > 0) | 9140 | if (needed > 0) |
| 9140 | { | 9141 | { |
| 9141 | wchar_t *msg_w = alloca ((needed + 1) * sizeof (wchar_t)); | 9142 | wchar_t *msg_w = alloca ((needed + 1) * sizeof (wchar_t)); |
| 9142 | 9143 | ||
| 9143 | pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, -1, | 9144 | pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, buffer, |
| 9144 | msg_w, needed); | 9145 | -1, msg_w, needed); |
| 9145 | needed = pWideCharToMultiByte (CP_ACP, 0, msg_w, -1, | 9146 | needed = pWideCharToMultiByte (CP_ACP, 0, msg_w, -1, |
| 9146 | NULL, 0, NULL, NULL); | 9147 | NULL, 0, NULL, NULL); |
| 9147 | if (needed > 0) | 9148 | if (needed > 0) |
| @@ -9328,6 +9329,7 @@ maybe_load_unicows_dll (void) | |||
| 9328 | (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar"); | 9329 | (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar"); |
| 9329 | pWideCharToMultiByte = | 9330 | pWideCharToMultiByte = |
| 9330 | (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte"); | 9331 | (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte"); |
| 9332 | multiByteToWideCharFlags = MB_ERR_INVALID_CHARS; | ||
| 9331 | return ret; | 9333 | return ret; |
| 9332 | } | 9334 | } |
| 9333 | else | 9335 | else |
| @@ -9357,6 +9359,11 @@ maybe_load_unicows_dll (void) | |||
| 9357 | pointers; no need for the LoadLibrary dance. */ | 9359 | pointers; no need for the LoadLibrary dance. */ |
| 9358 | pMultiByteToWideChar = MultiByteToWideChar; | 9360 | pMultiByteToWideChar = MultiByteToWideChar; |
| 9359 | pWideCharToMultiByte = WideCharToMultiByte; | 9361 | pWideCharToMultiByte = WideCharToMultiByte; |
| 9362 | /* On NT 4.0, though, MB_ERR_INVALID_CHARS is not supported. */ | ||
| 9363 | if (w32_major_version < 5) | ||
| 9364 | multiByteToWideCharFlags = 0; | ||
| 9365 | else | ||
| 9366 | multiByteToWideCharFlags = MB_ERR_INVALID_CHARS; | ||
| 9360 | return LoadLibrary ("Gdi32.dll"); | 9367 | return LoadLibrary ("Gdi32.dll"); |
| 9361 | } | 9368 | } |
| 9362 | } | 9369 | } |