diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-06 15:09:05 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-06 15:09:05 +0000 |
commit | d1c93a587dfb54f669ffb05890dab4d523cc57dc (patch) | |
tree | e8862f17d03e32664ba10cc8d9aa4b682bbeff64 /man_validate.c | |
parent | 5f1748e981fcd266c4bc34941a57e258388e7c69 (diff) | |
download | mandoc-d1c93a587dfb54f669ffb05890dab4d523cc57dc.tar.gz mandoc-d1c93a587dfb54f669ffb05890dab4d523cc57dc.tar.zst mandoc-d1c93a587dfb54f669ffb05890dab4d523cc57dc.zip |
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.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/man_validate.c b/man_validate.c index 5de92996..c17eb9ec 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.104 2014/08/01 21:24:17 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.105 2014/08/06 15:09:05 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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 */ |