summaryrefslogtreecommitdiff
path: root/lib/generic.cc
diff options
context:
space:
mode:
authorpixel <pixel>2007-08-07 09:50:46 +0000
committerpixel <pixel>2007-08-07 09:50:46 +0000
commit75ef5ef4fda55ba36d90ff5c0834f0c5d6b3ccf9 (patch)
tree14dc39e2e6762c88c6d279a6f742e2e2bf3c2217 /lib/generic.cc
parent5621123d7c16be8800e37f3abd6d28151fc386ae (diff)
Adding the printr function.
Diffstat (limited to 'lib/generic.cc')
-rw-r--r--lib/generic.cc59
1 files changed, 58 insertions, 1 deletions
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;