diff --git a/src/job.c b/src/job.c index 876898c8..1ac64ebc 100644 --- a/src/job.c +++ b/src/job.c @@ -861,7 +861,7 @@ reap_children (int block, int err) map_windows32_error_to_string from calling 'fatal', which will then call reap_children again */ if (werr && exit_code > 0 && exit_code < WSABASEERR) - fprintf (stderr, "make (e=%d): %s", exit_code, + fprintf (stderr, "make (e=%d): %s\n", exit_code, map_windows32_error_to_string (exit_code)); /* signal */ @@ -2552,7 +2552,7 @@ exec_command (char **argv, char **envp) exit_code = process_exit_code (hWaitPID); if (err) - fprintf (stderr, "make (e=%d, rc=%d): %s", + fprintf (stderr, "make (e=%d, rc=%d): %s\n", err, exit_code, map_windows32_error_to_string (err)); /* cleanup process */ diff --git a/src/w32/subproc/sub_proc.c b/src/w32/subproc/sub_proc.c index 501afc3e..5352bf4a 100644 --- a/src/w32/subproc/sub_proc.c +++ b/src/w32/subproc/sub_proc.c @@ -887,7 +887,7 @@ proc_stderr_thread(sub_process *pproc) for (;;) { if (ReadFile( (HANDLE)pproc->sv_stderr[0], &c, 1, &nread, NULL) == FALSE) { - map_windows32_error_to_string(GetLastError()); +/* map_windows32_error_to_string(GetLastError());*/ _endthreadex(0); } if (nread == 0) diff --git a/src/w32/subproc/w32err.c b/src/w32/subproc/w32err.c index eb201034..ad9049cd 100644 --- a/src/w32/subproc/w32err.c +++ b/src/w32/subproc/w32err.c @@ -44,42 +44,42 @@ map_windows32_error_to_string (DWORD ercode) { * static. (If and when we do need it to be in thread-local storage, * the corresponding GCC qualifier is '__thread'.) */ - static char szMessageBuffer[128]; - /* Fill message buffer with a default message in - * case FormatMessage fails - */ - wsprintf (szMessageBuffer, "Error %ld\n", ercode); + static char szMessageBuffer[128]; + DWORD ret; - /* - * Special code for winsock error handling. - */ - if (ercode > WSABASEERR) { -#if 0 - HMODULE hModule = GetModuleHandle("wsock32"); - if (hModule != NULL) { - FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, - hModule, - ercode, - LANG_NEUTRAL, - szMessageBuffer, - sizeof(szMessageBuffer), - NULL); - FreeLibrary(hModule); - } -#else - O (fatal, NILF, szMessageBuffer); -#endif - } else { - /* - * Default system message handling - */ - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - ercode, - LANG_NEUTRAL, - szMessageBuffer, - sizeof(szMessageBuffer), - NULL); + /* Fill message buffer with a default message in + * case FormatMessage fails + */ + wsprintf (szMessageBuffer, "Error %ld", ercode); + + /* + * Special code for winsock error handling. + */ + if (ercode > WSABASEERR) { + O (fatal, NILF, szMessageBuffer); + } + + /* + * Default system message handling + */ + ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + ercode, + LANG_NEUTRAL, + szMessageBuffer, + sizeof(szMessageBuffer), + NULL); + + if (ret) + { + char *cp; + for (cp = szMessageBuffer + ret - 1; cp >= szMessageBuffer; --cp) + { + if (*cp != '\r' && *cp != '\n') + break; + *cp = '\0'; } - return szMessageBuffer; + } + + return szMessageBuffer; }