summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-06-20 22:58:42 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-06-20 22:58:42 +0000
commit9999ebc80ee1df63e3257e4fa41715be601a7bed (patch)
treed0bbb9f5fe20cf79ba166821559679d5dedecad7 /usr.bin/mandoc/main.c
parent1ba7e466112a238c682c6b8bc4a043f544ab4787 (diff)
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.
Diffstat (limited to 'usr.bin/mandoc/main.c')
-rw-r--r--usr.bin/mandoc/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index b0b35319bed..e754060cb60 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.91 2014/06/20 16:11:03 schwarze Exp $ */
+/* $Id: main.c,v 1.92 2014/06/20 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -409,9 +409,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);