aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.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 /mdoc_validate.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 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 6e8ef19b..bb7025b9 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.215 2014/06/20 17:24:00 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.216 2014/06/20 23:02:31 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1645,15 +1645,15 @@ ebool(struct mdoc *mdoc)
static int
post_root(POST_ARGS)
{
- int erc;
+ int ret;
struct mdoc_node *n;
- erc = 0;
+ ret = 1;
/* Check that we have a finished prologue. */
if ( ! (MDOC_PBODY & mdoc->flags)) {
- erc++;
+ ret = 0;
mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG);
}
@@ -1662,17 +1662,13 @@ post_root(POST_ARGS)
/* Check that we begin with a proper `Sh'. */
- if (NULL == n->child) {
- erc++;
- mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY);
- } else if (MDOC_BLOCK != n->child->type ||
- MDOC_Sh != n->child->tok) {
- erc++;
- /* Can this be lifted? See rxdebug.1 for example. */
- mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY);
- }
+ if (NULL == n->child)
+ mdoc_nmsg(mdoc, n, MANDOCERR_DOC_EMPTY);
+ else if (MDOC_BLOCK != n->child->type ||
+ MDOC_Sh != n->child->tok)
+ mdoc_nmsg(mdoc, n->child, MANDOCERR_SEC_BEFORE);
- return(erc ? 0 : 1);
+ return(ret);
}
static int