From abc9aea1b52cb2d4a8de04c1e39acc9f0492a136 Mon Sep 17 00:00:00 2001 From: "David P. Chassin" Date: Wed, 3 Mar 2021 09:27:17 -0800 Subject: [PATCH] Add output progress flush control for validation --- gldcore/output.cpp | 15 +++++++++++++++ gldcore/output.h | 1 + gldcore/validate.cpp | 2 ++ 3 files changed, 18 insertions(+) diff --git a/gldcore/output.cpp b/gldcore/output.cpp index a7d48ae32..84c9abd1f 100644 --- a/gldcore/output.cpp +++ b/gldcore/output.cpp @@ -40,6 +40,13 @@ static char buffer[65536]; int overflow=CHECK; int flush = 0; +bool output_enable_flush(bool enable) +{ + int old = flush; + flush = ( enable ? 1 : 0 ); + return old; +} + static char prefix[16]=""; void output_prefix_enable(void) { @@ -705,9 +712,17 @@ int output_message(const char *format,...) /**< \bprintf style argument list */ } Output: if (redirect.output) + { result = fprintf(redirect.output,"%s%s\n", prefix, buffer); + if ( flush ) + { + fflush(redirect.output); + } + } else + { result = (*printstd)("%s%s\n", prefix, buffer); + } Unlock: wunlock(&output_lock); return result; diff --git a/gldcore/output.h b/gldcore/output.h index f717b6d7d..19298f773 100644 --- a/gldcore/output.h +++ b/gldcore/output.h @@ -31,6 +31,7 @@ PRINTFUNCTION output_set_stdout(PRINTFUNCTION call); PRINTFUNCTION output_set_stderr(PRINTFUNCTION call); int output_init(int argc, const char *argv[]); +bool output_enable_flush(bool enable); void output_cleanup(void); void output_prefix_enable(void); diff --git a/gldcore/validate.cpp b/gldcore/validate.cpp index 99ce3cb04..f7fd2b655 100644 --- a/gldcore/validate.cpp +++ b/gldcore/validate.cpp @@ -95,7 +95,9 @@ class counters { } else if ( global_keep_progress ) { + int old = output_enable_flush(true); output_message("Processing %s...",ptr); + output_enable_flush(old); } else {