Commit 3f1374fc authored by Russ Cox's avatar Russ Cox

cmd/dist: use vfprintf on Windows, same as on Unix

Apparently, the Windows routines sometimes fail to generate output.
Copy the Unix stdio-based implementations instead.

Suggested by Pietro Gagliardi in CL 65280043 but that CL
seems to have been abandoned.

Fixes #7242.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71550044
parent 671cc6ef
......@@ -840,34 +840,20 @@ void
xprintf(char *fmt, ...)
{
va_list arg;
char *p;
DWORD n, w;
va_start(arg, fmt);
n = vsnprintf(NULL, 0, fmt, arg);
p = xmalloc(n+1);
vsnprintf(p, n+1, fmt, arg);
vprintf(fmt, arg);
va_end(arg);
w = 0;
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), p, n, &w, 0);
xfree(p);
}
void
errprintf(char *fmt, ...)
{
va_list arg;
char *p;
DWORD n, w;
va_start(arg, fmt);
n = vsnprintf(NULL, 0, fmt, arg);
p = xmalloc(n+1);
vsnprintf(p, n+1, fmt, arg);
vfprintf(stderr, fmt, arg);
va_end(arg);
w = 0;
WriteFile(GetStdHandle(STD_ERROR_HANDLE), p, n, &w, 0);
xfree(p);
}
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment