aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-02-15 11:56:20 +0000
committerRon Yorston <rmy@pobox.com>2021-02-15 11:56:20 +0000
commitc07e998a46b5ee3be1720413d660745b552b8c85 (patch)
tree21f7c8e473a09d3aee1f1b6b1f1907c5f9a4be39
parent4340e4d3d581c438a8634868c838f73b9018fb8b (diff)
downloadbusybox-w32-c07e998a46b5ee3be1720413d660745b552b8c85.tar.gz
busybox-w32-c07e998a46b5ee3be1720413d660745b552b8c85.tar.bz2
busybox-w32-c07e998a46b5ee3be1720413d660745b552b8c85.zip
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.
-rw-r--r--win32/winansi.c6
1 files 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)
750 cur_len = strlen(s); 750 cur_len = strlen(s);
751 if ( cur_len > max_len ) { 751 if ( cur_len > max_len ) {
752 free(mem); 752 free(mem);
753 mem = strdup(s); 753 mem = xstrdup(s);
754 max_len = cur_len; 754 max_len = cur_len;
755 } 755 }
756 else { 756 else {
@@ -942,7 +942,7 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list)
942 va_end(cp); 942 va_end(cp);
943 943
944 if (len > sizeof(small_buf) - 1) { 944 if (len > sizeof(small_buf) - 1) {
945 buf = malloc(len + 1); 945 buf = xmalloc(len + 1);
946 if (!buf) 946 if (!buf)
947 goto abort; 947 goto abort;
948 948
@@ -962,7 +962,7 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list)
962 962
963abort: 963abort:
964 SetLastError(0); 964 SetLastError(0);
965 if ((rv=vfprintf(stream, format, list)) == EOF) 965 if ((rv=vfprintf(stream, format, list)) == EOF || ferror(stream) != 0)
966 check_pipe(stream); 966 check_pipe(stream);
967 return rv; 967 return rv;
968} 968}