summaryrefslogtreecommitdiffstats
path: root/man_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-08-06 15:09:05 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-08-06 15:09:05 +0000
commit24b160c265af79f44e54160d97249622ff07747a (patch)
tree6bab11dc37008079265c87f0b7d5ee5ad38955f6 /man_validate.c
parent4e6374f6dccb1f26d1d9efc07a9ce9c9c600c3e7 (diff)
downloadmandoc-24b160c265af79f44e54160d97249622ff07747a.tar.gz
Bring the handling of defective prologues even closer to groff,
in particular relaxing the distinction between prologue and body and further improving messages. * The last .Dd wins and the last .Os wins, even in the body. * The last .Dt before the first body macro wins. * Missing title in .Dt defaults to UNTITLED. Warn about it. * Missing section in .Dt does not default to 1. But warn about it. * Do not warn multiple times about the same mdoc(7) prologue macro. * Warn about missing .Os. * Incomplete .TH defaults to empty strings. Warn about it.
Diffstat (limited to 'man_validate.c')
-rw-r--r--man_validate.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/man_validate.c b/man_validate.c
index 2091840d..76aebe1c 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -43,7 +43,6 @@ typedef int (*v_check)(CHKARGS);
static int check_eq0(CHKARGS);
static int check_eq2(CHKARGS);
static int check_le1(CHKARGS);
-static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
static int check_par(CHKARGS);
static int check_part(CHKARGS);
@@ -142,7 +141,7 @@ check_root(CHKARGS)
man->meta.hasbody = 1;
if (NULL == man->meta.title) {
- mandoc_msg(MANDOCERR_TH_MISSING, man->parse,
+ mandoc_msg(MANDOCERR_TH_NOTITLE, man->parse,
n->line, n->pos, NULL);
/*
@@ -150,8 +149,8 @@ check_root(CHKARGS)
* implication, date and section also aren't set).
*/
- man->meta.title = mandoc_strdup("unknown");
- man->meta.msec = mandoc_strdup("1");
+ man->meta.title = mandoc_strdup("");
+ man->meta.msec = mandoc_strdup("");
man->meta.date = man->quick ? mandoc_strdup("") :
mandoc_normdate(man->parse, NULL, n->line, n->pos);
}
@@ -189,7 +188,6 @@ check_##name(CHKARGS) \
INEQ_DEFINE(0, ==, eq0)
INEQ_DEFINE(2, ==, eq2)
INEQ_DEFINE(1, <=, le1)
-INEQ_DEFINE(2, >=, ge2)
INEQ_DEFINE(5, <=, le5)
static int
@@ -324,7 +322,6 @@ post_TH(CHKARGS)
struct man_node *nb;
const char *p;
- check_ge2(man, n);
check_le5(man, n);
free(man->meta.title);
@@ -354,8 +351,11 @@ post_TH(CHKARGS)
}
}
man->meta.title = mandoc_strdup(n->string);
- } else
+ } else {
man->meta.title = mandoc_strdup("");
+ mandoc_msg(MANDOCERR_TH_NOTITLE, man->parse,
+ nb->line, nb->pos, "TH");
+ }
/* TITLE ->MSEC<- DATE SOURCE VOL */
@@ -363,8 +363,11 @@ post_TH(CHKARGS)
n = n->next;
if (n && n->string)
man->meta.msec = mandoc_strdup(n->string);
- else
+ else {
man->meta.msec = mandoc_strdup("");
+ mandoc_vmsg(MANDOCERR_MSEC_MISSING, man->parse,
+ nb->line, nb->pos, "TH %s", man->meta.title);
+ }
/* TITLE MSEC ->DATE<- SOURCE VOL */