From a98f6ac69b0770888510398d8d03d9ffd3f0d4f5 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 15 Dec 2018 18:10:03 +0100 Subject: [PATCH] proper initialization of OldAn, callback only if output has changed --- src/sharedspice.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sharedspice.c b/src/sharedspice.c index 4eb008cf8..27e49dfd3 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -46,6 +46,7 @@ /**********************************************************************/ #include +#include #include /* workaround since fputs, putc are replaced by sh_fputs, @@ -1614,6 +1615,7 @@ void SetAnalyse( static int OldPercent = -2; /* Previous progress value */ static char OldAn[128]; /* Previous analysis type */ char* s; /* outputs to callback function */ + static char olds[128]; /* previous output */ static struct timeb timebefore; /* previous time stamp */ struct timeb timenow; /* actual time stamp */ int diffsec, diffmillisec; /* differences actual minus prev. time stamp */ @@ -1628,7 +1630,7 @@ void SetAnalyse( if (nostatuswanted) return; - OldAn[0] = '\0'; + strcpy(OldAn, "?"); if ((DecaPercent == OldPercent) && !strcmp(OldAn, Analyse)) return; @@ -1691,8 +1693,10 @@ void SetAnalyse( printf("%s finished after %4.2f seconds.\n", OldAn, seconds()); strncpy(OldAn, Analyse, 127); } - - result = statfcn(s, ng_ident, userptr); + /* ouput only after a change */ + if (strcmp(olds, s)) + result = statfcn(s, ng_ident, userptr); + strcpy(olds, s); } tfree(s); #else