Mercurial > ~dholland > hg > tradcpp > index.cgi
diff place.c @ 142:26ee741196d1
Allow complain(NULL, format, ...)
author | David A. Holland |
---|---|
date | Sat, 13 Jul 2013 12:38:54 -0400 |
parents | 05d67dd74e1f |
children | 95fbb216e23f |
line wrap: on
line diff
--- a/place.c Wed Jul 10 13:48:07 2013 -0400 +++ b/place.c Sat Jul 13 12:38:54 2013 -0400 @@ -50,6 +50,8 @@ static struct placefilearray placefiles; static bool overall_failure; +static const char *myprogname; + //////////////////////////////////////////////////////////// // seenfiles @@ -187,12 +189,23 @@ // complaints void +complain_init(const char *pn) +{ + myprogname = pn; +} + +void complain(const struct place *p, const char *fmt, ...) { va_list ap; - place_printfrom(p); - fprintf(stderr, "%s:%u:%u: ", place_getname(p), p->line, p->column); + if (p != NULL) { + place_printfrom(p); + fprintf(stderr, "%s:%u:%u: ", place_getname(p), + p->line, p->column); + } else { + fprintf(stderr, "%s: ", myprogname); + } va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap);