Hi Ingo, currently, mandoc DIAGNOSTICS recognizes an AUTHORS section without An. Would it be similarly useful to recognize a FILES section without Pa?
I left the empty lines after the opening { in case they are intended, just like child_an() and post_sh_authors() have them, but feel free to remove them all if they are not. Question: static int child_an(const struct roff_node *n) { for (n = n->child; n != NULL; n = n->next) if ((n->tok == MDOC_An && n->child != NULL) || child_an(n)) return 1; return 0; } If I'm reading this right, it tests whether the given node has an An child; the child_pa() below is an obvious modification. Does the recursive child_an(n) mean that an An node can itself have an An child? Similar question for child_pa() then. Jan Index: mandoc.1 =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v retrieving revision 1.143 diff -u -p -r1.143 mandoc.1 --- mandoc.1 7 Sep 2017 14:22:58 -0000 1.143 +++ mandoc.1 9 Nov 2017 11:28:44 -0000 @@ -1171,6 +1171,12 @@ An AUTHORS sections contains no .Ic \&An macros, or only empty ones. Probably, there are author names lacking markup. +.It Sy "FILES section without Pa macro" +.Pq mdoc +A FILES sections contains no +.Ic \&Pa +macros, or only empty ones. +Probably, there are file names lacking markup. .El .Ss "Warnings related to macros and nesting" .Bl -ohang Index: mandoc.h =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mandoc.h,v retrieving revision 1.187 diff -u -p -r1.187 mandoc.h --- mandoc.h 8 Jul 2017 14:51:01 -0000 1.187 +++ mandoc.h 9 Nov 2017 11:28:44 -0000 @@ -105,6 +105,7 @@ enum mandocerr { MANDOCERR_XR_ORDER, /* unusual Xr order: ... after ... */ MANDOCERR_XR_PUNCT, /* unusual Xr punctuation: ... after ... */ MANDOCERR_AN_MISSING, /* AUTHORS section without An macro */ + MANDOCERR_PA_MISSING, /* FILES section without Pa macro */ /* related to macros and nesting */ MANDOCERR_MACRO_OBS, /* obsolete macro: macro */ Index: mdoc_validate.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mdoc_validate.c,v retrieving revision 1.268 diff -u -p -r1.268 mdoc_validate.c --- mdoc_validate.c 12 Sep 2017 18:20:32 -0000 1.268 +++ mdoc_validate.c 9 Nov 2017 11:28:44 -0000 @@ -105,6 +105,7 @@ static void post_sh_head(POST_ARGS); static void post_sh_name(POST_ARGS); static void post_sh_see_also(POST_ARGS); static void post_sh_authors(POST_ARGS); +static void post_sh_files(POST_ARGS); static void post_sm(POST_ARGS); static void post_st(POST_ARGS); static void post_std(POST_ARGS); @@ -2080,6 +2081,9 @@ post_sh(POST_ARGS) case SEC_AUTHORS: post_sh_authors(mdoc); break; + case SEC_FILES: + post_sh_files(mdoc); + break; default: break; } @@ -2216,6 +2220,25 @@ post_sh_authors(POST_ARGS) if ( ! child_an(mdoc->last)) mandoc_msg(MANDOCERR_AN_MISSING, mdoc->parse, + mdoc->last->line, mdoc->last->pos, NULL); +} + +static int +child_pa(const struct roff_node *n) +{ + + for (n = n->child; n != NULL; n = n->next) + if ((n->tok == MDOC_Pa && n->child != NULL) || child_pa(n)) + return 1; + return 0; +} + +static void +post_sh_files(POST_ARGS) +{ + + if ( ! child_pa(mdoc->last)) + mandoc_msg(MANDOCERR_PA_MISSING, mdoc->parse, mdoc->last->line, mdoc->last->pos, NULL); } Index: read.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/read.c,v retrieving revision 1.164 diff -u -p -r1.164 read.c --- read.c 20 Jul 2017 14:36:32 -0000 1.164 +++ read.c 9 Nov 2017 11:28:44 -0000 @@ -141,6 +141,7 @@ static const char * const mandocerrs[MAN "unusual Xr order", "unusual Xr punctuation", "AUTHORS section without An macro", + "FILES section without Pa macro", /* related to macros and nesting */ "obsolete macro",