From af139bb8a38b36a5e3c8b1ce4b6455e65fcbb2e5 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 5 Jan 2009 14:14:04 +0000 Subject: Actions and validations properly added. --- macro.c | 64 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'macro.c') diff --git a/macro.c b/macro.c index e3ed70a7..89cd3a5c 100644 --- a/macro.c +++ b/macro.c @@ -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,7 +99,36 @@ rewind_exp(struct mdoc *mdoc, int ppos, int tok, int tt) 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)); } @@ -130,32 +162,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) { @@ -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) -- cgit