=================================================================== RCS file: /cvs/mandoc/mdoc_macro.c,v retrieving revision 1.98 retrieving revision 1.103 diff -u -p -r1.98 -r1.103 --- mandoc/mdoc_macro.c 2010/12/06 11:01:19 1.98 +++ mandoc/mdoc_macro.c 2011/03/17 11:30:23 1.103 @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.98 2010/12/06 11:01:19 kristaps Exp $ */ +/* $Id: mdoc_macro.c,v 1.103 2011/03/17 11:30:23 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -252,16 +252,26 @@ lookup_raw(const char *p) static int rew_last(struct mdoc *mdoc, const struct mdoc_node *to) { + struct mdoc_node *n, *np; assert(to); mdoc->next = MDOC_NEXT_SIBLING; /* LINTED */ while (mdoc->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. + */ + np = mdoc->last->parent; if ( ! mdoc_valid_post(mdoc)) return(0); - mdoc->last = mdoc->last->parent; + n = mdoc->last; + mdoc->last = np; assert(mdoc->last); + mdoc->last->last = n; } return(mdoc_valid_post(mdoc)); @@ -589,7 +599,7 @@ append_delims(struct mdoc *m, int line, int *pos, char else if (ARGS_EOLN == ac) break; - assert(DELIM_NONE != mdoc_isdelim(p)); + assert(DELIM_NONE != mandoc_isdelim(p)); if ( ! mdoc_word_alloc(m, line, la, p)) return(0); @@ -700,8 +710,7 @@ blk_exp_close(MACRO_PROT_ARGS) if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) { /* FIXME: do this in validate */ if (buf[*pos]) - if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_ARGSLOST)) - return(0); + mdoc_pmsg(m, line, ppos, MANDOCERR_ARGSLOST); if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos)) return(0); @@ -844,9 +853,9 @@ in_line(MACRO_PROT_ARGS) return(0); } else if ( ! nc && 0 == cnt) { mdoc_argv_free(arg); - if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY)) - return(0); + mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY); } + if ( ! mdoc_macro(m, ntok, line, la, pos, buf)) return(0); if ( ! nl) @@ -860,7 +869,7 @@ in_line(MACRO_PROT_ARGS) * the word. */ - d = ARGS_QWORD == ac ? DELIM_NONE : mdoc_isdelim(p); + d = ARGS_QWORD == ac ? DELIM_NONE : mandoc_isdelim(p); if (DELIM_NONE != d) { /* @@ -926,8 +935,7 @@ in_line(MACRO_PROT_ARGS) return(0); } else if ( ! nc && 0 == cnt) { mdoc_argv_free(arg); - if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY)) - return(0); + mdoc_pmsg(m, line, ppos, MANDOCERR_MACROEMPTY); } if ( ! nl) @@ -1051,7 +1059,7 @@ blk_full(MACRO_PROT_ARGS) ARGS_PHRASE != ac && ARGS_PPHRASE != ac && ARGS_QWORD != ac && - DELIM_OPEN == mdoc_isdelim(p)) { + DELIM_OPEN == mandoc_isdelim(p)) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1214,7 +1222,7 @@ blk_part_imp(MACRO_PROT_ARGS) break; if (NULL == body && ARGS_QWORD != ac && - DELIM_OPEN == mdoc_isdelim(p)) { + DELIM_OPEN == mandoc_isdelim(p)) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1289,9 +1297,9 @@ blk_part_imp(MACRO_PROT_ARGS) * is ugly behaviour nodding its head to OpenBSD's overwhelming * crufty use of `Op' breakage. */ - if (n != body && ! mdoc_vmsg(m, MANDOCERR_SCOPENEST, - line, ppos, "%s broken", mdoc_macronames[tok])) - return(0); + if (n != body) + mdoc_vmsg(m, MANDOCERR_SCOPENEST, line, ppos, + "%s broken", mdoc_macronames[tok]); if (n && ! rew_sub(MDOC_BODY, m, tok, line, ppos)) return(0); @@ -1345,7 +1353,7 @@ blk_part_exp(MACRO_PROT_ARGS) /* Flush out leading punctuation. */ if (NULL == head && ARGS_QWORD != ac && - DELIM_OPEN == mdoc_isdelim(p)) { + DELIM_OPEN == mandoc_isdelim(p)) { assert(NULL == body); if ( ! mdoc_word_alloc(m, line, la, p)) return(0); @@ -1451,6 +1459,8 @@ in_line_argn(MACRO_PROT_ARGS) case (MDOC_Ux): maxargs = 0; break; + case (MDOC_Bx): + /* FALLTHROUGH */ case (MDOC_Xr): maxargs = 2; break; @@ -1490,7 +1500,7 @@ in_line_argn(MACRO_PROT_ARGS) if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && ARGS_QWORD != ac && - 0 == j && DELIM_OPEN == mdoc_isdelim(p)) { + 0 == j && DELIM_OPEN == mandoc_isdelim(p)) { if ( ! mdoc_word_alloc(m, line, la, p)) return(0); continue; @@ -1519,7 +1529,7 @@ in_line_argn(MACRO_PROT_ARGS) if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && ARGS_QWORD != ac && ! flushed && - DELIM_NONE != mdoc_isdelim(p)) { + DELIM_NONE != mandoc_isdelim(p)) { if ( ! rew_elem(m, tok)) return(0); flushed = 1; @@ -1661,7 +1671,8 @@ static int obsolete(MACRO_PROT_ARGS) { - return(mdoc_pmsg(m, line, ppos, MANDOCERR_MACROOBS)); + mdoc_pmsg(m, line, ppos, MANDOCERR_MACROOBS); + return(1); }