diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-19 17:51:32 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-19 17:51:32 +0000 |
commit | 2e32d8081f19a0adc0f1c4091cc0e6720b1a24fe (patch) | |
tree | 308da3c4fc54485ffb916bd71b5a04b848513d70 /macro.c | |
parent | d427476d5c4b9bd0804fa51647671e6b18e07afa (diff) | |
download | mandoc-2e32d8081f19a0adc0f1c4091cc0e6720b1a24fe.tar.gz |
More correct validation.
Elision of prologue macros from main tree.
Diffstat (limited to 'macro.c')
-rw-r--r-- | macro.c | 33 |
1 files changed, 29 insertions, 4 deletions
@@ -961,9 +961,10 @@ macro_constant_delimited(MACRO_PROT_ARGS) int macro_constant(MACRO_PROT_ARGS) { - int c, lastarg, argc, fl; - struct mdoc_arg argv[MDOC_LINEARG_MAX]; - char *p; + int c, lastarg, argc, fl; + struct mdoc_arg argv[MDOC_LINEARG_MAX]; + char *p; + struct mdoc_node *n; fl = 0; if (MDOC_QUOTABLE & mdoc_macros[tok].flags) @@ -1019,7 +1020,31 @@ macro_constant(MACRO_PROT_ARGS) mdoc->next = MDOC_NEXT_SIBLING; } - return(rewind_elem(mdoc, tok)); + if ( ! rewind_elem(mdoc, tok)) + return(0); + if ( ! (MDOC_NOKEEP & mdoc_macros[tok].flags)) + return(1); + + assert(mdoc->last->tok == tok); + if (mdoc->last->parent->child == mdoc->last) + mdoc->last->parent->child = mdoc->last->prev; + if (mdoc->last->prev) + mdoc->last->prev->next = NULL; + + n = mdoc->last; + assert(NULL == mdoc->last->next); + + if (mdoc->last->prev) { + mdoc->last = mdoc->last->prev; + mdoc->next = MDOC_NEXT_SIBLING; + } else { + mdoc->last = mdoc->last->parent; + mdoc->next = MDOC_NEXT_CHILD; + } + + mdoc_node_freelist(n); + + return(1); } |