Don't expect stdout be usable after exchanging file descriptors under
it.
This commit is contained in:
parent
29623c2e6b
commit
27db309518
|
@ -335,8 +335,6 @@ run_tests (char *logname, const char *tag)
|
||||||
SetErrorMode (SEM_FAILCRITICALERRORS);
|
SetErrorMode (SEM_FAILCRITICALERRORS);
|
||||||
|
|
||||||
if (!(wineloader = getenv("WINELOADER"))) wineloader = "wine";
|
if (!(wineloader = getenv("WINELOADER"))) wineloader = "wine";
|
||||||
if (setvbuf (stdout, NULL, _IONBF, 0))
|
|
||||||
report (R_FATAL, "Can't unbuffer output.");
|
|
||||||
|
|
||||||
tempdir = tempnam (0, "wct");
|
tempdir = tempnam (0, "wct");
|
||||||
if (!tempdir)
|
if (!tempdir)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "winetest.h"
|
#include "winetest.h"
|
||||||
|
@ -39,26 +40,14 @@ void *xrealloc (void *op, size_t len)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xprintf (const char *fmt, ...)
|
char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
if (vprintf (fmt, ap) < 0)
|
|
||||||
report (R_FATAL, "Can't write logs: %d", errno);
|
|
||||||
va_end (ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *vstrmake (size_t *lenp, va_list ap)
|
|
||||||
{
|
|
||||||
char *fmt;
|
|
||||||
size_t size = 1000;
|
size_t size = 1000;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
p = malloc (size);
|
p = malloc (size);
|
||||||
if (!p) return NULL;
|
if (!p) return NULL;
|
||||||
fmt = va_arg (ap, char*);
|
|
||||||
while (1) {
|
while (1) {
|
||||||
n = vsnprintf (p, size, fmt, ap);
|
n = vsnprintf (p, size, fmt, ap);
|
||||||
if (n < 0) size *= 2; /* Windows */
|
if (n < 0) size *= 2; /* Windows */
|
||||||
|
@ -75,6 +64,14 @@ char *vstrmake (size_t *lenp, va_list ap)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *vstrmake (size_t *lenp, va_list ap)
|
||||||
|
{
|
||||||
|
const char *fmt;
|
||||||
|
|
||||||
|
fmt = va_arg (ap, const char*);
|
||||||
|
return vstrfmtmake (lenp, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
char *strmake (size_t *lenp, ...)
|
char *strmake (size_t *lenp, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -87,6 +84,26 @@ char *strmake (size_t *lenp, ...)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xprintf (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
size_t size;
|
||||||
|
ssize_t written;
|
||||||
|
char *buffer, *head;
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
buffer = vstrfmtmake (&size, fmt, ap);
|
||||||
|
head = buffer;
|
||||||
|
va_end (ap);
|
||||||
|
while ((written = write (1, head, size)) != size) {
|
||||||
|
if (written == -1)
|
||||||
|
report (R_FATAL, "Can't write logs: %d", errno);
|
||||||
|
head += written;
|
||||||
|
size -= written;
|
||||||
|
}
|
||||||
|
free (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
badtagchar (char *tag)
|
badtagchar (char *tag)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue