=================================================================== RCS file: /cvs/mandoc/mdoc_macro.c,v retrieving revision 1.135 retrieving revision 1.138 diff -u -p -r1.135 -r1.138 --- mandoc/mdoc_macro.c 2014/07/02 20:19:11 1.135 +++ mandoc/mdoc_macro.c 2014/07/30 17:06:26 1.138 @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.135 2014/07/02 20:19:11 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.138 2014/07/30 17:06:26 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013 Ingo Schwarze @@ -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; @@ -769,11 +774,12 @@ blk_exp_close(MACRO_PROT_ARGS) later = n; } - if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) { - /* FIXME: do this in validate */ - if (buf[*pos]) - mdoc_pmsg(mdoc, line, ppos, MANDOCERR_ARGSLOST); - + if ( ! (MDOC_PARSED & mdoc_macros[tok].flags)) { + if ('\0' != buf[*pos]) + mandoc_vmsg(MANDOCERR_ARG_SKIP, + mdoc->parse, line, ppos, + "%s %s", mdoc_macronames[tok], + buf + *pos); if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); return(rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)); @@ -1031,6 +1037,22 @@ 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) + 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)) { @@ -1762,7 +1784,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, NULL); return(1); }