From f26c1b71f9477f5656e171142f9b761f295fa8e9 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 4 Apr 2014 19:46:41 +0200 Subject: [PATCH] introduce OUTerrorf() and IFerrorf() a varargs variant of the older variants OUTerror() and IFerror() --- src/frontend/outitf.c | 25 +++++++++++++++++++++++++ src/frontend/outitf.h | 1 + src/include/ngspice/ifsim.h | 8 +++++++- src/main.c | 5 ++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 0ccff5867..0c512aef9 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -1285,6 +1285,31 @@ OUTerror(int flags, char *format, IFuid *names) fflush(cp_err); } + +void +OUTerrorf(int flags, const char *format, ...) +{ + struct mesg *m; + va_list args; + + if ((flags == ERR_INFO) && cp_getvar("printinfo", CP_BOOL, NULL)) + return; + + for (m = msgs; m->flag; m++) + if (flags & m->flag) + fprintf(cp_err, "%s: ", m->string); + + va_start (args, format); + + vfprintf(cp_err, format, args); + fputc('\n', cp_err); + + fflush(cp_err); + + va_end(args); +} + + static int InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr) { diff --git a/src/frontend/outitf.h b/src/frontend/outitf.h index c3446b4e3..ce67ff465 100644 --- a/src/frontend/outitf.h +++ b/src/frontend/outitf.h @@ -63,6 +63,7 @@ int OUTendDomain(runDesc *plotPtr); int OUTattributes(runDesc *plotPtr, IFuid varName, int param, IFvalue *value); int OUTstopnow(void); void OUTerror(int flags, char *format, IFuid *names); +void OUTerrorf(int, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); #endif diff --git a/src/include/ngspice/ifsim.h b/src/include/ngspice/ifsim.h index 75e244b2f..873e533b2 100644 --- a/src/include/ngspice/ifsim.h +++ b/src/include/ngspice/ifsim.h @@ -437,7 +437,13 @@ struct IFfrontEnd { /* should we stop now? */ double (*IFseconds) (void); /* what time is it? */ - int (*IFerror) (int, char *, IFuid *); + void (*IFerror) (int, char *, IFuid *); + /* output an error or warning message */ +#ifdef __GNUC__ + void (*IFerrorf) (int, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); +#else + void (*IFerrorf) (int, const char *fmt, ...); +#endif /* output an error or warning message */ int (*OUTpBeginPlot) (CKTcircuit *, JOB *, IFuid, diff --git a/src/main.c b/src/main.c index 1f79e02f8..b460301dd 100644 --- a/src/main.c +++ b/src/main.c @@ -204,7 +204,9 @@ extern int OUTwBeginPlot(CKTcircuit *,JOB *,IFuid,IFuid,int,int,IFuid *,int,runD extern int OUTwReference(runDesc *,IFvalue *,void **); extern int OUTwData(runDesc *,int,IFvalue *,void *), OUTwEnd(runDesc *), OUTendPlot(runDesc *); extern int OUTbeginDomain(runDesc *,IFuid,int,IFvalue *); -extern int OUTendDomain(runDesc *), OUTstopnow(void), OUTerror(int,char *,IFuid *); +extern int OUTendDomain(runDesc *), OUTstopnow(void); +extern void OUTerror(int,char *,IFuid *); +extern void OUTerrorf(int, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); extern int OUTattributes(runDesc *,IFuid,int,IFvalue *); extern void initw(void); @@ -215,6 +217,7 @@ IFfrontEnd nutmeginfo = { OUTstopnow, seconds, OUTerror, + OUTerrorf, OUTpBeginPlot, OUTpData, OUTwBeginPlot,