From e2f3ea24c0b0f6b1170423271d2066a71aa21ae2 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Mon, 30 Dec 2013 14:34:07 +0100 Subject: [PATCH] main.c, suppress progress report when '-o' is used to redirect output --- src/frontend/outitf.c | 52 ++++++++++++++++++++++++++----------------- src/main.c | 10 +++++---- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 9f424e1d2..3f47b3720 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -57,14 +57,18 @@ static bool name_eq(char *n1, char *n2); static bool getSpecial(dataDesc *desc, runDesc *run, IFvalue *val); static void freeRun(runDesc *run); -/*Output data to spice module saj*/ +/*Output data to spice module*/ #ifdef TCL_MODULE #include "ngspice/tclspice.h" #elif defined SHARED_MODULE extern int sh_ExecutePerLoop(void); extern void sh_vecinit(runDesc *run); #endif -/*saj*/ + +/*Suppressing progress info in -o option */ +#ifndef HAS_WINGUI +extern bool orflag; +#endif #define DOUBLE_PRECISION 15 @@ -465,11 +469,13 @@ OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr) every quarter of a second, to give some feedback without using too much CPU time */ #ifndef HAS_WINGUI - currclock = clock(); - if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) { - fprintf(stderr, " Reference value : % 12.5e\r", - refValue->cValue.real); - lastclock = currclock; + if (!orflag) { + currclock = clock(); + if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) { + fprintf(stderr, " Reference value : % 12.5e\r", + refValue->cValue.real); + lastclock = currclock; + } } #endif } else { @@ -478,11 +484,13 @@ OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr) fileAddRealValue(run->fp, run->binary, refValue->rValue); #ifndef HAS_WINGUI - currclock = clock(); - if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) { - fprintf(stderr, " Reference value : % 12.5e\r", - refValue->rValue); - lastclock = currclock; + if (!orflag) { + currclock = clock(); + if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) { + fprintf(stderr, " Reference value : % 12.5e\r", + refValue->rValue); + lastclock = currclock; + } } #endif } @@ -559,16 +567,18 @@ OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr) variable just the same */ #ifndef HAS_WINGUI - currclock = clock(); - if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) { - if (run->isComplex) { - fprintf(stderr, " Reference value : % 12.5e\r", - refValue ? refValue->cValue.real : NAN); - } else { - fprintf(stderr, " Reference value : % 12.5e\r", - refValue ? refValue->rValue : NAN); + if (!orflag) { + currclock = clock(); + if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) { + if (run->isComplex) { + fprintf(stderr, " Reference value : % 12.5e\r", + refValue ? refValue->cValue.real : NAN); + } else { + fprintf(stderr, " Reference value : % 12.5e\r", + refValue ? refValue->rValue : NAN); + } + lastclock = currclock; } - lastclock = currclock; } #endif diff --git a/src/main.c b/src/main.c index 266b3e00c..0ea88cdc5 100644 --- a/src/main.c +++ b/src/main.c @@ -100,6 +100,8 @@ char *ft_rawfile = "rawspice.raw"; extern void SetSource( char *Name); /* display the source file name in the source window */ extern int xmain(int argc, char **argv); FILE *flogp = NULL; /* log file ('-o logfile' command line option) */ +#else + bool orflag = FALSE; /* global for -o option */ #endif FILE *slogp = NULL; /* soa log file ('--soa-log file' command line option) */ @@ -803,7 +805,7 @@ main(int argc, char **argv) bool qflag = FALSE; FILE * volatile circuit_file; - bool orflag = FALSE; + bool oflag = FALSE; bool srflag = FALSE; #ifdef TRACE @@ -942,7 +944,7 @@ main(int argc, char **argv) /* switch to line buffering for stdout */ setvbuf(stdout, NULL, _IOLBF, BUFSIZ); sprintf (log_file, "%s", optarg); - orflag = TRUE; + oflag = TRUE; } break; @@ -989,7 +991,7 @@ main(int argc, char **argv) } /* --- End of command line option processing (While(1)-loop) --- */ - if (orflag) { /* -o option has been set */ + if (oflag) { /* -o option has been set */ com_version(NULL); @@ -1013,8 +1015,8 @@ main(int argc, char **argv) perror (log_file); sp_shutdown (EXIT_BAD); } -// oflag = TRUE; /* All further output to -o log file */ #else + orflag = TRUE; /* Connect stdout and stderr to file log_file and log stdout */ if (!freopen (log_file, "w", stdout)) { perror (log_file);