=================================================================== RCS file: /cvs/mandoc/man_macro.c,v retrieving revision 1.53 retrieving revision 1.57 diff -u -p -r1.53 -r1.57 --- mandoc/man_macro.c 2010/12/06 15:31:19 1.53 +++ mandoc/man_macro.c 2011/03/20 16:02:05 1.57 @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.53 2010/12/06 15:31:19 kristaps Exp $ */ +/* $Id: man_macro.c,v 1.57 2011/03/20 16:02:05 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -24,6 +24,7 @@ #include #include "mandoc.h" +#include "libmandoc.h" #include "libman.h" enum rew { @@ -43,7 +44,7 @@ static enum rew rew_dohalt(enum mant, enum man_type, const struct man_node *); static enum rew rew_block(enum mant, enum man_type, const struct man_node *); -static int rew_warn(struct man *, +static void rew_warn(struct man *, struct man_node *, enum mandocerr); const struct man_macro __man_macros[MAN_MAX] = { @@ -69,11 +70,9 @@ const struct man_macro __man_macros[MAN_MAX] = { { in_line_eoln, 0 }, /* IR */ { in_line_eoln, 0 }, /* RI */ { in_line_eoln, MAN_NSCOPED }, /* na */ - { in_line_eoln, 0 }, /* i */ { in_line_eoln, MAN_NSCOPED }, /* sp */ { in_line_eoln, 0 }, /* nf */ { in_line_eoln, 0 }, /* fi */ - { in_line_eoln, 0 }, /* r */ { blk_close, 0 }, /* RE */ { blk_exp, MAN_EXPLICIT }, /* RS */ { in_line_eoln, 0 }, /* DT */ @@ -90,17 +89,19 @@ const struct man_macro * const man_macros = __man_macr /* * Warn when "n" is an explicit non-roff macro. */ -static int +static void rew_warn(struct man *m, struct man_node *n, enum mandocerr er) { if (er == MANDOCERR_MAX || MAN_BLOCK != n->type) - return(1); + return; if (MAN_VALID & n->flags) - return(1); + return; if ( ! (MAN_EXPLICIT & man_macros[n->tok].flags)) - return(1); - return(man_nmsg(m, n, er)); + return; + + assert(er < MANDOCERR_FATAL); + man_nmsg(m, n, er); } @@ -109,24 +110,30 @@ rew_warn(struct man *m, struct man_node *n, enum mando * will be used if an explicit block scope is being closed out. */ int -man_unscope(struct man *m, const struct man_node *n, +man_unscope(struct man *m, const struct man_node *to, enum mandocerr er) { + struct man_node *n; - assert(n); + assert(to); /* LINTED */ - while (m->last != n) { - if ( ! rew_warn(m, m->last, er)) - return(0); + while (m->last != to) { + /* + * Save the parent here, because we may delete the + * m->last node in the post-validation phase and reset + * it to m->last->parent, causing a step in the closing + * out to be lost. + */ + n = m->last->parent; + rew_warn(m, m->last, er); if ( ! man_valid_post(m)) return(0); - m->last = m->last->parent; + m->last = n; assert(m->last); } - if ( ! rew_warn(m, m->last, er)) - return(0); + rew_warn(m, m->last, er); if ( ! man_valid_post(m)) return(0); @@ -273,8 +280,7 @@ blk_close(MACRO_PROT_ARGS) break; if (NULL == nn) - if ( ! man_pmsg(m, line, ppos, MANDOCERR_NOSCOPE)) - return(0); + man_pmsg(m, line, ppos, MANDOCERR_NOSCOPE); if ( ! rew_scope(MAN_BODY, m, ntok)) return(0);