From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s87NP2XU002903 for ; Sun, 7 Sep 2014 19:25:02 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s87NP1Id006406; Sun, 7 Sep 2014 19:25:01 -0400 (EDT) Date: Sun, 7 Sep 2014 19:25:01 -0400 (EDT) Message-Id: <201409072325.s87NP1Id006406@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: warn about AUTHORS sections without .An macros, inspired by X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- warn about AUTHORS sections without .An macros, inspired by mdoclint(1) Modified Files: -------------- mdocml: mandoc.1 mandoc.h mdoc_validate.c read.c Revision Data ------------- Index: mandoc.1 =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.1,v retrieving revision 1.110 retrieving revision 1.111 diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.110 -r1.111 --- mandoc.1 +++ mandoc.1 @@ -766,6 +766,12 @@ The same standard section title occurs m .Pq mdoc A standard section header occurs in a section of the manual where it normally isn't useful. +.It Sy "AUTHORS section without An macro" +.Pq mdoc +An AUTHORS sections contains no +.Ic \&An +macros, or only empty ones. +Probably, there are author names lacking markup. .El .Ss "Warnings related to macros and nesting" .Bl -ohang Index: mdoc_validate.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v retrieving revision 1.246 retrieving revision 1.247 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.246 -r1.247 --- mdoc_validate.c +++ mdoc_validate.c @@ -67,6 +67,7 @@ static void check_text(struct mdoc *, i 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 @@ -1890,6 +1901,26 @@ post_sh_body(POST_ARGS) mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse, n->line, n->pos, mdoc_macronames[n->tok]); + return(1); +} + +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); } Index: mandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v retrieving revision 1.153 retrieving revision 1.154 diff -Lmandoc.h -Lmandoc.h -u -p -r1.153 -r1.154 --- mandoc.h +++ mandoc.h @@ -72,6 +72,7 @@ enum mandocerr { MANDOCERR_SEC_ORDER, /* sections out of conventional order: Sh title */ MANDOCERR_SEC_REP, /* duplicate section title: Sh title */ MANDOCERR_SEC_MSEC, /* unexpected section: Sh title for ... only */ + MANDOCERR_AN_MISSING, /* AUTHORS section without An macro */ /* related to macros and nesting */ MANDOCERR_MACRO_OBS, /* obsolete macro: macro */ Index: read.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v retrieving revision 1.85 retrieving revision 1.86 diff -Lread.c -Lread.c -u -p -r1.85 -r1.86 --- read.c +++ read.c @@ -117,6 +117,7 @@ static const char * const mandocerrs[MAN "sections out of conventional order", "duplicate section title", "unexpected section", + "AUTHORS section without An macro", /* related to macros and nesting */ "obsolete macro", -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv