From ec35b1bc2f3572acb8519abe0717ce13c8781092 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 14 May 2010 04:50:33 +0200 Subject: Remove prefix ascii art from error messages stored in the error text buffer. --- fitz/base_error.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'fitz/base_error.c') diff --git a/fitz/base_error.c b/fitz/base_error.c index 52e1b601..3045d912 100644 --- a/fitz/base_error.c +++ b/fitz/base_error.c @@ -1,20 +1,25 @@ #include "fitz.h" -char fz_errorbuf[100*20] = {0}; +char fz_errorbuf[150*20] = {0}; static int fz_errorlen = 0; static int fz_errorclear = 1; static void fz_printerror(int type, const char *file, int line, const char *func, char *msg) { - char buf[100]; + char buf[150]; int len; + char *s; - snprintf(buf, sizeof buf, "%c %s:%d: %s(): %s", type, file, line, func, msg); - len = strlen(buf); + s = strrchr(file, '\\'); + if (s) + file = s + 1; + + fprintf(stderr, "%c %s:%d: %s(): %s\n", type, file, line, func, msg); - fputs(buf, stderr); - putc('\n', stderr); + snprintf(buf, sizeof buf, "%s:%d: %s(): %s", file, line, func, msg); + buf[sizeof(buf)-1] = 0; + len = strlen(buf); if (fz_errorclear) { @@ -44,33 +49,36 @@ void fz_warn(char *fmt, ...) fz_error fz_throwimp(const char *file, int line, const char *func, char *fmt, ...) { - char buf[100]; + char buf[150]; va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); + buf[sizeof(buf)-1] = 0; fz_printerror('+', file, line, func, buf); return -1; } fz_error fz_rethrowimp(fz_error cause, const char *file, int line, const char *func, char *fmt, ...) { - char buf[100]; + char buf[150]; va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); + buf[sizeof(buf)-1] = 0; fz_printerror('|', file, line, func, buf); return cause; } fz_error fz_catchimp(fz_error cause, const char *file, int line, const char *func, char *fmt, ...) { - char buf[100]; + char buf[150]; va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); + buf[sizeof(buf)-1] = 0; fz_printerror('\\', file, line, func, buf); fz_errorclear = 1; return cause; -- cgit v1.2.3