/* Graphical user interface functions for the Microsoft Windows API.
-Copyright (C) 1989, 1992-2015 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2016 Free Software Foundation, Inc.
This file is part of GNU Emacs.
if (errno == ENOENT && filename_buf_w[MAX_PATH - 1] != 0)
report_file_error ("filename too long", default_filename);
}
- len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ len = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
SSDATA (prompt), -1, NULL, 0);
if (len > 32768)
len = 32768;
prompt_w = alloca (len * sizeof (wchar_t));
- pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
SSDATA (prompt), -1, prompt_w, len);
}
else
if (errno == ENOENT && filename_buf_a[MAX_PATH - 1] != 0)
report_file_error ("filename too long", default_filename);
}
- len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ len = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
SSDATA (prompt), -1, NULL, 0);
if (len > 32768)
len = 32768;
prompt_w = alloca (len * sizeof (wchar_t));
- pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
SSDATA (prompt), -1, prompt_w, len);
len = pWideCharToMultiByte (CP_ACP, 0, prompt_w, -1, NULL, 0, NULL, NULL);
if (len > 32768)
current_dir = ENCODE_FILE (current_dir);
/* Cannot use filename_to_utf16/ansi with DOCUMENT, since it could
be a URL that is not limited to MAX_PATH chararcters. */
- doclen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ doclen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
SSDATA (document), -1, NULL, 0);
doc_w = xmalloc (doclen * sizeof (wchar_t));
- pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
SSDATA (document), -1, doc_w, doclen);
if (use_unicode)
{
int len;
parameters = ENCODE_SYSTEM (parameters);
- len = pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
+ len = pMultiByteToWideChar (CP_ACP, multiByteToWideCharFlags,
SSDATA (parameters), -1, NULL, 0);
if (len > 32768)
len = 32768;
params_w = alloca (len * sizeof (wchar_t));
- pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
+ pMultiByteToWideChar (CP_ACP, multiByteToWideCharFlags,
SSDATA (parameters), -1, params_w, len);
params_w[len - 1] = 0;
}
later versions support up to 128. */
if (nidw.cbSize == MYNOTIFYICONDATAW_V1_SIZE)
{
- tiplen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ tiplen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
tip, utf8_mbslen_lim (tip, 63),
tipw, 64);
if (tiplen >= 63)
}
else
{
- tiplen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ tiplen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
tip, utf8_mbslen_lim (tip, 127),
tipw, 128);
if (tiplen >= 127)
{
int slen;
- slen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ slen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
msg, utf8_mbslen_lim (msg, 255),
msgw, 256);
if (slen >= 255)
}
wcscpy (nidw.szInfo, msgw);
nidw.uTimeout = timeout;
- slen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ slen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
title, utf8_mbslen_lim (title, 63),
titlew, 64);
if (slen >= 63)
/* Stack overflow recovery. */
+/* MinGW headers don't declare this (should be in malloc.h). Also,
+ the function is not present pre-W2K, so make the call through
+ a function pointer. */
+typedef int (__cdecl *_resetstkoflw_proc) (void);
+static _resetstkoflw_proc resetstkoflw;
+
/* Re-establish the guard page at stack limit. This is needed because
when a stack overflow is detected, Windows removes the guard bit
from the guard page, so if we don't re-establish that protection,
void
w32_reset_stack_overflow_guard (void)
{
- /* MinGW headers don't declare this (should be in malloc.h). */
- _CRTIMP int __cdecl _resetstkoflw (void);
-
+ if (resetstkoflw == NULL)
+ resetstkoflw =
+ (_resetstkoflw_proc)GetProcAddress (GetModuleHandle ("msvcrt.dll"),
+ "_resetstkoflw");
/* We ignore the return value. If _resetstkoflw fails, the next
stack overflow will crash the program. */
- (void)_resetstkoflw ();
+ if (resetstkoflw != NULL)
+ (void)resetstkoflw ();
}
static void
except_addr = 0;
#ifndef CYGWIN
prev_exception_handler = SetUnhandledExceptionFilter (my_exception_handler);
+ resetstkoflw = NULL;
#endif
DEFVAR_INT ("w32-ansi-code-page",