From c07e998a46b5ee3be1720413d660745b552b8c85 Mon Sep 17 00:00:00 2001 From: Ron Yorston <rmy@pobox.com> Date: Mon, 15 Feb 2021 11:56:20 +0000 Subject: winansi: allow test suite to run on Wine Running the test suite on Wine failed because in seq 4 0 8 | head -n 10 'seq' didn't detect the broken pipe when 'head' terminated and carried on forever. Fix this by adding a call to ferror(3) in winansi_vfprintf(). Also, use xstrdup() and xmalloc() in a couple of places. --- win32/winansi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/win32/winansi.c b/win32/winansi.c index af030caa8..fd0de8656 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -750,7 +750,7 @@ static int ansi_emulate(const char *s, FILE *stream) cur_len = strlen(s); if ( cur_len > max_len ) { free(mem); - mem = strdup(s); + mem = xstrdup(s); max_len = cur_len; } else { @@ -942,7 +942,7 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list) va_end(cp); if (len > sizeof(small_buf) - 1) { - buf = malloc(len + 1); + buf = xmalloc(len + 1); if (!buf) goto abort; @@ -962,7 +962,7 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list) abort: SetLastError(0); - if ((rv=vfprintf(stream, format, list)) == EOF) + if ((rv=vfprintf(stream, format, list)) == EOF || ferror(stream) != 0) check_pipe(stream); return rv; } -- cgit v1.2.3-55-g6feb