=================================================================== RCS file: /cvs/mandoc/Attic/macro.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -p -r1.20 -r1.21 --- mandoc/Attic/macro.c 2009/01/05 12:23:17 1.20 +++ mandoc/Attic/macro.c 2009/01/05 14:14:04 1.21 @@ -1,4 +1,4 @@ -/* $Id: macro.c,v 1.20 2009/01/05 12:23:17 kristaps Exp $ */ +/* $Id: macro.c,v 1.21 2009/01/05 14:14:04 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -49,7 +49,9 @@ rewind_elem(struct mdoc *mdoc, int ppos, int tok) mdoc->last = n; mdoc->next = MDOC_NEXT_SIBLING; - return(mdoc_valid_post(mdoc, tok, ppos)); + if ( ! mdoc_valid_post(mdoc, tok, ppos)) + return(0); + return(mdoc_action(mdoc, tok, ppos)); } @@ -72,6 +74,7 @@ rewind_line(struct mdoc *mdoc, int ppos, int tok) mdoc->last = n ? n : mdoc->last; mdoc->next = MDOC_NEXT_SIBLING; + /* XXX - no validation, we do this only for blocks/elements. */ return(1); } @@ -96,10 +99,39 @@ rewind_exp(struct mdoc *mdoc, int ppos, int tok, int t return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_NOCTX)); mdoc->next = MDOC_NEXT_SIBLING; - return(mdoc_valid_post(mdoc, tok, ppos)); + if ( ! mdoc_valid_post(mdoc, tok, ppos)) + return(0); + return(mdoc_action(mdoc, tok, ppos)); } +static int +rewind_imp(struct mdoc *mdoc, int ppos, int tok) +{ + struct mdoc_node *n; + int t; + + n = mdoc->last ? mdoc->last->parent : NULL; + + /* LINTED */ + for ( ; n; n = n->parent) { + if (MDOC_BLOCK != n->type) + continue; + if (tok == (t = n->data.block.tok)) + break; + if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags)) + continue; + return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); + } + + mdoc->last = n ? n : mdoc->last; + mdoc->next = MDOC_NEXT_SIBLING; + if ( ! mdoc_valid_post(mdoc, tok, ppos)) + return(0); + return(mdoc_action(mdoc, tok, ppos)); +} + + /* ARGSUSED */ int macro_close_explicit(MACRO_PROT_ARGS) @@ -131,32 +163,6 @@ macro_close_explicit(MACRO_PROT_ARGS) static int -rewind_imp(struct mdoc *mdoc, int ppos, int tok) -{ - struct mdoc_node *n; - int t; - - n = mdoc->last ? mdoc->last->parent : NULL; - - /* LINTED */ - for ( ; n; n = n->parent) { - if (MDOC_BLOCK != n->type) - continue; - if (tok == (t = n->data.block.tok)) - break; - if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags)) - continue; - return(mdoc_err(mdoc, tok, ppos, ERR_SCOPE_BREAK)); - } - - mdoc->last = n ? n : mdoc->last; - mdoc->next = MDOC_NEXT_SIBLING; - return(1); - /*return(mdoc_valid_post(mdoc, tok, ppos));*/ -} - - -static int append_delims(struct mdoc *mdoc, int tok, int *pos, char *buf) { int c, lastarg; @@ -542,7 +548,7 @@ macro_constant(MACRO_PROT_ARGS) break; mdoc_word_alloc(mdoc, lastarg, p); - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = MDOC_NEXT_SIBLING; } if (MDOC_LINEARG_MAX == sz + argc)