aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-07 23:25:01 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-07 23:25:01 +0000
commit874ac26ff8affa95d651832b3050f9fd13ae9aca (patch)
tree3e41ce381f7ce00da58aa4520a6496ec065b39e7 /mdoc_validate.c
parentd8b6133e338cc53510b2bd1ebbfa509a54acccda (diff)
downloadmandoc-874ac26ff8affa95d651832b3050f9fd13ae9aca.tar.gz
mandoc-874ac26ff8affa95d651832b3050f9fd13ae9aca.tar.zst
mandoc-874ac26ff8affa95d651832b3050f9fd13ae9aca.zip
warn about AUTHORS sections without .An macros, inspired by mdoclint(1)
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index ff691ba6..c89de9c9 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.246 2014/09/07 00:05:28 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.247 2014/09/07 23:25:01 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -67,6 +67,7 @@ static void check_text(struct mdoc *, int, int, char *);
static void check_argv(struct mdoc *,
struct mdoc_node *, struct mdoc_argv *);
static void check_args(struct mdoc *, struct mdoc_node *);
+static int child_an(const struct mdoc_node *);
static enum mdoc_sec a2sec(const char *);
static size_t macro2len(enum mdoct);
@@ -114,8 +115,9 @@ static int post_par(POST_ARGS);
static int post_root(POST_ARGS);
static int post_rs(POST_ARGS);
static int post_sh(POST_ARGS);
-static int post_sh_body(POST_ARGS);
static int post_sh_head(POST_ARGS);
+static int post_sh_name(POST_ARGS);
+static int post_sh_authors(POST_ARGS);
static int post_st(POST_ARGS);
static int post_vt(POST_ARGS);
static int pre_an(PRE_ARGS);
@@ -1847,22 +1849,31 @@ post_sh(POST_ARGS)
post_ignpar(mdoc);
- if (MDOC_HEAD == mdoc->last->type)
+ switch (mdoc->last->type) {
+ case MDOC_HEAD:
return(post_sh_head(mdoc));
- if (MDOC_BODY == mdoc->last->type)
- return(post_sh_body(mdoc));
+ case MDOC_BODY:
+ switch (mdoc->lastsec) {
+ case SEC_NAME:
+ return(post_sh_name(mdoc));
+ case SEC_AUTHORS:
+ return(post_sh_authors(mdoc));
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
return(1);
}
static int
-post_sh_body(POST_ARGS)
+post_sh_name(POST_ARGS)
{
struct mdoc_node *n;
- if (SEC_NAME != mdoc->lastsec)
- return(1);
-
/*
* Warn if the NAME section doesn't contain the `Nm' and `Nd'
* macros (can have multiple `Nm' and one `Nd'). Note that the
@@ -1894,6 +1905,26 @@ post_sh_body(POST_ARGS)
}
static int
+child_an(const struct mdoc_node *n)
+{
+
+ for (n = n->child; n != NULL; n = n->next)
+ if ((n->tok == MDOC_An && n->nchild) || child_an(n))
+ return(1);
+ return(0);
+}
+
+static int
+post_sh_authors(POST_ARGS)
+{
+
+ if ( ! child_an(mdoc->last))
+ mandoc_msg(MANDOCERR_AN_MISSING, mdoc->parse,
+ mdoc->last->line, mdoc->last->pos, NULL);
+ return(1);
+}
+
+static int
post_sh_head(POST_ARGS)
{
struct mdoc_node *n;