Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Add output progress flush control for validation #850

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gldcore/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions gldcore/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions gldcore/validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down