=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.323 retrieving revision 1.328 diff -u -p -r1.323 -r1.328 --- mandoc/mdoc_validate.c 2017/05/04 17:48:29 1.323 +++ mandoc/mdoc_validate.c 2017/05/30 19:30:38 1.328 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.323 2017/05/04 17:48:29 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.328 2017/05/30 19:30:38 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -105,6 +105,7 @@ static void post_sh_authors(POST_ARGS); static void post_sm(POST_ARGS); static void post_st(POST_ARGS); static void post_std(POST_ARGS); +static void post_useless(POST_ARGS); static void post_xr(POST_ARGS); static void post_xx(POST_ARGS); @@ -201,7 +202,7 @@ static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] post_sm, /* Sm */ post_hyph, /* Sx */ NULL, /* Sy */ - NULL, /* Tn */ + post_useless, /* Tn */ post_xx, /* Ux */ NULL, /* Xc */ NULL, /* Xo */ @@ -227,10 +228,8 @@ static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] post_en, /* En */ post_xx, /* Dx */ NULL, /* %Q */ - post_par, /* sp */ NULL, /* %U */ NULL, /* Ta */ - NULL, /* ll */ }; static const v_post *const mdoc_valids = __mdoc_valids - MDOC_Dd; @@ -329,10 +328,12 @@ mdoc_node_validate(struct roff_man *mdoc) if (n->tok < ROFF_MAX) { switch(n->tok) { case ROFF_br: + case ROFF_sp: post_par(mdoc); break; default: - abort(); + roff_validate(mdoc); + break; } break; } @@ -671,6 +672,7 @@ post_eoln(POST_ARGS) { struct roff_node *n; + post_useless(mdoc); n = mdoc->last; if (n->child != NULL) mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, n->line, @@ -866,6 +868,16 @@ post_obsolete(POST_ARGS) n->line, n->pos, roff_name[n->tok]); } +static void +post_useless(POST_ARGS) +{ + struct roff_node *n; + + n = mdoc->last; + mandoc_msg(MANDOCERR_MACRO_USELESS, mdoc->parse, + n->line, n->pos, roff_name[n->tok]); +} + /* * Block macros. */ @@ -1879,7 +1891,7 @@ post_sh_see_also(POST_ARGS) if (isalpha((const unsigned char)*name)) return; lastpunct = n->string; - if (n->next == NULL) + if (n->next == NULL || n->next->tok == MDOC_Rs) mandoc_vmsg(MANDOCERR_XR_PUNCT, mdoc->parse, n->line, n->pos, "%s after %s(%s)", lastpunct, lastname, lastsec); @@ -2096,10 +2108,10 @@ post_par(POST_ARGS) struct roff_node *np; np = mdoc->last; - if (np->tok != ROFF_br && np->tok != MDOC_sp) + if (np->tok != ROFF_br && np->tok != ROFF_sp) post_prevpar(mdoc); - if (np->tok == MDOC_sp) { + if (np->tok == ROFF_sp) { if (np->child != NULL && np->child->next != NULL) mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, np->child->next->line, np->child->next->pos, @@ -2115,7 +2127,7 @@ post_par(POST_ARGS) return; } else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp && (mdoc->last->tok != ROFF_br || - (np->tok != MDOC_sp && np->tok != ROFF_br))) + (np->tok != ROFF_sp && np->tok != ROFF_br))) return; mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse,