summaryrefslogtreecommitdiffstatshomepage
path: root/macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-05 14:14:04 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-05 14:14:04 +0000
commitdffebd8f3a78d88f60b2dc8706c4b9227071f1de (patch)
tree01c98a966b94e2e57de520a5b6a995f317c2d733 /macro.c
parent6eb782b58c4ba0e676d14d922231664e884957bf (diff)
downloadmandoc-dffebd8f3a78d88f60b2dc8706c4b9227071f1de.tar.gz
mandoc-dffebd8f3a78d88f60b2dc8706c4b9227071f1de.tar.zst
mandoc-dffebd8f3a78d88f60b2dc8706c4b9227071f1de.zip
Actions and validations properly added.
Diffstat (limited to 'macro.c')
-rw-r--r--macro.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/macro.c b/macro.c
index a53cf4ab..d5ad4331 100644
--- a/macro.c
+++ b/macro.c
@@ -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 <kristaps@kth.se>
*
@@ -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));
}
@@ -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)