Windows: propagate system error text even with format commands

For example, error 193 now says "%1 is not a valid Win32 application.",
which is ugly but better than "Unknown error".
This commit is contained in:
Matthew Flatt 2013-02-13 08:54:53 -07:00
parent c6eb82524b
commit 9ff47ec1d0

View File

@ -502,7 +502,9 @@ static intptr_t sch_vsprintf(char *s, intptr_t maxlen, const char *msg, va_list
wchar_t mbuf[256];
int len;
if ((type != 'e') && !es) {
if ((len = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
if ((len = FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS),
NULL,
en, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
mbuf, 255, NULL))) {
int i;