From 98338d33c9bc055ec9c807443aa8f737855854bc Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 8 Mar 2014 17:47:06 +0000 Subject: [PATCH] introduce progress_eol and make stderr line buffered --- main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 0cc8d9b..a816871 100644 --- a/main.c +++ b/main.c @@ -91,6 +91,11 @@ static unsigned printcounter; static int ncpus = 1; +static void progress_eol(void) { + fprintf(stderr," \r"); + fflush(stderr); +} + static AdjWord *xalloc_adjmatrix(void) { return xmalloc(sizeof(*adjmatrix)*n); } @@ -99,6 +104,7 @@ static void prep(void) { adjall = ~((~(AdjWord)0) << m); adjmatrix = xalloc_adjmatrix(); glp_term_out(GLP_OFF); + setlinebuf(stderr); } static AdjWord one_adj_bit(int bitnum) { @@ -332,7 +338,7 @@ static void optimise(bool doprint) { out: if (prob) glp_delete_prob(prob); - if (doprint) { PRINTF(" \r"); fflush(stdout); } + if (doprint) progress_eol(); } static void iterate_recurse(int i, AdjWord min) { -- 2.30.2