summaryrefslogtreecommitdiffstatshomepage
path: root/macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-19 17:51:32 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-19 17:51:32 +0000
commit14b264ac5a6226fdf3065c90d26a2595186fa976 (patch)
tree5e94556f1f4f5dbdd726597b5e6c08f1167012b6 /macro.c
parent4d0e00fc396f69ea4575cca04855817cbf289670 (diff)
downloadmandoc-14b264ac5a6226fdf3065c90d26a2595186fa976.tar.gz
mandoc-14b264ac5a6226fdf3065c90d26a2595186fa976.tar.zst
mandoc-14b264ac5a6226fdf3065c90d26a2595186fa976.zip
More correct validation.
Elision of prologue macros from main tree.
Diffstat (limited to 'macro.c')
-rw-r--r--macro.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/macro.c b/macro.c
index 6ea7b58f..70cd340b 100644
--- a/macro.c
+++ b/macro.c
@@ -1,4 +1,4 @@
-/* $Id: macro.c,v 1.42 2009/01/19 17:02:58 kristaps Exp $ */
+/* $Id: macro.c,v 1.43 2009/01/19 17:51:32 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);
}