From 5833f4765646e24f0d8a6e1be2f3a8328bbdfcd2 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 17 Aug 2005 15:28:47 +0000 Subject: [PATCH] Also write \r to stdout on Windows if it is the last character to be written. Flush stdout afterwards so that frontends (e.g. mmg) receive the output immediately. --- src/common/mm_io.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/mm_io.cpp b/src/common/mm_io.cpp index ab22bdde6..09c561282 100644 --- a/src/common/mm_io.cpp +++ b/src/common/mm_io.cpp @@ -1167,10 +1167,11 @@ mm_stdio_c::write(const void *buffer, bytes_written = 0; s = (const char *)buffer; for (i = 0; i < size; ++i) - if (('\r' != s[i]) || - (((i + 1) < size) && ('\n' != s[i + 1]))) + if (('\r' != s[i]) || ((i + 1) == size) || ('\n' != s[i + 1])) bytes_written += fwrite(&s[i], 1, 1, stdout); + fflush(stdout); + return bytes_written; #else // defined(SYS_WINDOWS)