From 37fc9452eae26c51be7df689f984abae6d78ccea Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 20 Jun 2014 23:02:31 +0000 Subject: As suggested by jmc@, only include line and column numbers into messages when they are meaningful, to avoid confusing stuff like this: $ mandoc /dev/null mandoc: /dev/null:0:1: FATAL: not a manual Instead, just say: mandoc: /dev/null: FATAL: not a manual Another example this applies to is documents having a prologue, but lacking a body. Do not throw a FATAL error for these; instead, issue a WARNING and show the empty document, in the man(7) case with the same amount of blank lines as groff does. Also downgrade mdoc(7) documents having content before the first .Sh from FATAL to WARNING. --- main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 00cdfb76..c1e5ba9f 100644 --- a/main.c +++ b/main.c @@ -408,9 +408,13 @@ mmsg(enum mandocerr t, enum mandoclevel lvl, const char *file, int line, int col, const char *msg) { - fprintf(stderr, "%s: %s:%d:%d: %s: %s", progname, - file, line, col + 1, - mparse_strlevel(lvl), mparse_strerror(t)); + fprintf(stderr, "%s: %s:", progname, file); + + if (line) + fprintf(stderr, "%d:%d:", line, col + 1); + + fprintf(stderr, " %s: %s", mparse_strlevel(lvl), + mparse_strerror(t)); if (msg) fprintf(stderr, ": %s", msg); -- cgit