diff options
-rw-r--r-- | include/Exceptions.h | 4 | ||||
-rw-r--r-- | lib/generic.cc | 59 |
2 files changed, 61 insertions, 2 deletions
diff --git a/include/Exceptions.h b/include/Exceptions.h index 9aac968..addf78e 100644 --- a/include/Exceptions.h +++ b/include/Exceptions.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Exceptions.h,v 1.44 2007-05-30 11:57:08 pixel Exp $ */ +/* $Id: Exceptions.h,v 1.45 2007-08-07 09:50:46 pixel Exp $ */ #ifndef __EXCEPTIONS_H__ #define __EXCEPTIONS_H__ @@ -73,6 +73,8 @@ class Base { static void exit(int); static void printm(int level, const ugly_string &, ...); static void printm(int level, const char *, ...); + static void printr(int level, const ugly_string &); + static void printr(int level, const char *); static void exception(const String &); static void pushcontext(const String &); static void popcontext(void); diff --git a/lib/generic.cc b/lib/generic.cc index 95fe74d..7f7c5f5 100644 --- a/lib/generic.cc +++ b/lib/generic.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: generic.cc,v 1.14 2007-05-30 11:57:10 pixel Exp $ */ +/* $Id: generic.cc,v 1.15 2007-08-07 09:50:46 pixel Exp $ */ #include <stdio.h> #include <stdarg.h> @@ -87,6 +87,63 @@ void Base::printm(int level, const char * m, ...) { va_end(ap); } +static bool wrapper_printer(printer_t * prt, int level, const char * msg, ...) { + bool r; + va_list ap; + + va_start(ap, prt); + r = prt->printm(level, msg, ap); + va_end(ap); + + return r; +} + +void Base::printr(int level, const ugly_string & m) { + bool display = true; + + if (verbosity < abs(level)) { + return; + } + + if (printer) + display = wrapper_printer(printer, level, "%s", m.p); + + if (display) { + if (level > 0) { + fprintf(stderr, "(%s) ", heads[level]); + } + +#ifdef HAVE_GMP + gmp_fprintf(stderr, "%s", m.p); +#else + fprintf(stderr, "%s", m.p); +#endif + } +} + +void Base::printr(int level, const char * m) { + bool display = true; + + if (verbosity < abs(level)) { + return; + } + + if (printer) + display = wrapper_printer(printer, level, "%s", m); + + if (display) { + if (level > 0) { + fprintf(stderr, "(%s) ", heads[level]); + } + +#ifdef HAVE_GMP + gmp_fprintf(stderr, "%s", m); +#else + fprintf(stderr, "%s", m); +#endif + } +} + char ** split(char * s, char t) { static char * p[100]; int i; |