=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/man_validate.c,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- src/usr.bin/mandoc/man_validate.c 2018/08/18 02:03:41 1.108 +++ src/usr.bin/mandoc/man_validate.c 2018/12/03 21:00:06 1.109 @@ -1,4 +1,4 @@ -/* $OpenBSD: man_validate.c,v 1.108 2018/08/18 02:03:41 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.109 2018/12/03 21:00:06 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2018 Ingo Schwarze @@ -38,6 +38,7 @@ typedef void (*v_check)(CHKARGS); +static void check_abort(CHKARGS); static void check_par(CHKARGS); static void check_part(CHKARGS); static void check_root(CHKARGS); @@ -58,9 +59,9 @@ NULL, /* SS */ NULL, /* TP */ NULL, /* TQ */ - check_par, /* LP */ + check_abort,/* LP */ check_par, /* PP */ - check_par, /* P */ + check_abort,/* P */ post_IP, /* IP */ NULL, /* HP */ NULL, /* SM */ @@ -95,13 +96,33 @@ }; +/* Validate the subtree rooted at man->last. */ void man_node_validate(struct roff_man *man) { struct roff_node *n; const v_check *cp; + /* + * Translate obsolete macros such that later code + * does not need to look for them. + */ + n = man->last; + switch (n->tok) { + case MAN_LP: + case MAN_P: + n->tok = MAN_PP; + break; + default: + break; + } + + /* + * Iterate over all children, recursing into each one + * in turn, depth-first. + */ + man->last = man->last->child; while (man->last != NULL) { man_node_validate(man); @@ -111,6 +132,8 @@ man->last = man->last->next; } + /* Finally validate the macro itself. */ + man->last = n; man->next = ROFF_NEXT_SIBLING; switch (n->type) { @@ -181,6 +204,12 @@ } static void +check_abort(CHKARGS) +{ + abort(); +} + +static void check_text(CHKARGS) { char *cp, *p; @@ -475,8 +504,6 @@ case MAN_SH: case MAN_SS: case MAN_PP: - case MAN_LP: - case MAN_P: mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, n->line, n->pos, "%s after %s", roff_name[n->tok], roff_name[n->parent->tok]);