=================================================================== RCS file: /cvs/mandoc/mdoc_macro.c,v retrieving revision 1.136 retrieving revision 1.141 diff -u -p -r1.136 -r1.141 --- mandoc/mdoc_macro.c 2014/07/04 16:12:08 1.136 +++ mandoc/mdoc_macro.c 2014/08/16 19:50:37 1.141 @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.136 2014/07/04 16:12:08 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.141 2014/08/16 19:50:37 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013 Ingo Schwarze @@ -15,10 +15,10 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif +#include + #include #include #include @@ -234,7 +234,8 @@ mdoc_macroend(struct mdoc *mdoc) for ( ; n; n = n->parent) if (MDOC_BLOCK == n->type && MDOC_EXPLICIT & mdoc_macros[n->tok].flags) - mdoc_nmsg(mdoc, n, MANDOCERR_SCOPEEXIT); + mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse, + n->line, n->pos, mdoc_macronames[n->tok]); /* Rewind to the first. */ @@ -423,6 +424,8 @@ rew_dohalt(enum mdoct tok, enum mdoc_type type, return(REWIND_NONE); /* FALLTHROUGH */ case MDOC_Sh: + if (MDOC_ROOT == p->parent->type) + return(REWIND_THIS); if (MDOC_Nd == p->tok || MDOC_Ss == p->tok || MDOC_Sh == p->tok) return(REWIND_MORE); @@ -528,7 +531,7 @@ make_pending(struct mdoc_node *broken, enum mdoct tok, taker->pending = broken->pending; } broken->pending = breaker; - mandoc_vmsg(MANDOCERR_BLOCK_NEST, mdoc->parse, line, ppos, + mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse, line, ppos, "%s breaks %s", mdoc_macronames[tok], mdoc_macronames[broken->tok]); return(1); @@ -558,7 +561,7 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc, ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)); break; case REWIND_FORCE: - mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse, + mandoc_vmsg(MANDOCERR_BLK_BROKEN, mdoc->parse, line, ppos, "%s breaks %s", mdoc_macronames[tok], mdoc_macronames[n->tok]); @@ -574,7 +577,9 @@ rew_sub(enum mdoc_type t, struct mdoc *mdoc, return(1); /* FALLTHROUGH */ case REWIND_ERROR: - mdoc_pmsg(mdoc, line, ppos, MANDOCERR_NOSCOPE); + mandoc_msg(MANDOCERR_BLK_NOTOPEN, + mdoc->parse, line, ppos, + mdoc_macronames[tok]); return(1); } break; @@ -1032,6 +1037,23 @@ blk_full(MACRO_PROT_ARGS) nl = MDOC_NEWLINE & mdoc->flags; + /* Skip items outside lists. */ + + if (tok == MDOC_It) { + for (n = mdoc->last; n; n = n->parent) + if (n->tok == MDOC_Bl && + ! (n->flags & MDOC_VALID)) + break; + if (n == NULL) { + mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse, + line, ppos, "It %s", buf + *pos); + if ( ! mdoc_elem_alloc(mdoc, line, ppos, + MDOC_br, NULL)) + return(0); + return(rew_elem(mdoc, MDOC_br)); + } + } + /* Close out prior implicit scope. */ if ( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)) { @@ -1763,7 +1785,8 @@ phrase_ta(MACRO_PROT_ARGS) while (NULL != n && MDOC_Bl != n->tok) n = n->parent; if (NULL == n || LIST_column != n->norm->Bl.type) { - mdoc_pmsg(mdoc, line, ppos, MANDOCERR_STRAYTA); + mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse, + line, ppos, "Ta"); return(1); }