aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-06-20 23:02:31 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-06-20 23:02:31 +0000
commitb4c01f5c60dab8debad192bef6f9db1c465255b9 (patch)
treee78d628565794d197118e581bb2357acd6ba5f4f /main.c
parentb3b89a43d7165af5fd4fe84f88cdeef6cb5ee1aa (diff)
downloadmandoc-b4c01f5c60dab8debad192bef6f9db1c465255b9.tar.gz
mandoc-b4c01f5c60dab8debad192bef6f9db1c465255b9.tar.zst
mandoc-b4c01f5c60dab8debad192bef6f9db1c465255b9.zip
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 'main.c')
-rw-r--r--main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.c b/main.c
index c1497761..f7f107a1 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.174 2014/06/20 16:11:42 schwarze Exp $ */
+/* $Id: main.c,v 1.175 2014/06/20 23:02:31 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);