diff options
Diffstat (limited to 'src/diag.c')
-rw-r--r-- | src/diag.c | 42 |
1 files changed, 14 insertions, 28 deletions
@@ -227,38 +227,16 @@ logmsg_printf (int prio, const char *fmt, ...) } void -grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg) +pies_diag_printer (grecs_locus_t const *locus, int err, int errcode, + const char *msg) { - char *locstr = NULL; - if (locus) { - size_t size = 0; + char *locstr = NULL; + size_t locsize = 0; + + grecs_asprint_locus (&locstr, &locsize, locus); - if (locus->beg.col == 0) - grecs_asprintf (&locstr, &size, "%s:%u", - locus->beg.file, - locus->beg.line); - else if (strcmp (locus->beg.file, locus->end.file)) - grecs_asprintf (&locstr, &size, "%s:%u.%u-%s:%u.%u", - locus->beg.file, - locus->beg.line, locus->beg.col, - locus->end.file, - locus->end.line, locus->end.col); - else if (locus->beg.line != locus->end.line) - grecs_asprintf (&locstr, &size, "%s:%u.%u-%u.%u", - locus->beg.file, - locus->beg.line, locus->beg.col, - locus->end.line, locus->end.col); - else - grecs_asprintf (&locstr, &size, "%s:%u.%u-%u", - locus->beg.file, - locus->beg.line, locus->beg.col, - locus->end.col); - } - - if (locstr) - { if (errcode) logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s: %s", locstr, msg, strerror (errcode)); @@ -277,3 +255,11 @@ grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg) } } +void +logfuncall (const char *fun, const char *arg, int err) +{ + if (arg) + grecs_error (NULL, err, _("%s: %s failed"), arg, fun); + else + grecs_error (NULL, err, _("%s failed"), fun); +} |