summaryrefslogtreecommitdiffstatshomepage
path: root/man_macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 16:07:36 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 16:07:36 +0000
commitbd26da950b7144cb234ef8d0864173a897d2fd28 (patch)
treecd40d8e822f8edde6f380f6063d093ac0b8be1dd /man_macro.c
parentc1e7dc6253e70fb184882bdb155d380f00698ce9 (diff)
downloadmandoc-bd26da950b7144cb234ef8d0864173a897d2fd28.tar.gz
mandoc-bd26da950b7144cb234ef8d0864173a897d2fd28.tar.zst
mandoc-bd26da950b7144cb234ef8d0864173a897d2fd28.zip
Actions in place for prologue parsing.
Diffstat (limited to 'man_macro.c')
-rw-r--r--man_macro.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/man_macro.c b/man_macro.c
index d03d12c5..7121e490 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.6 2009/03/25 15:36:05 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.7 2009/03/25 16:07:36 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -56,8 +56,16 @@ man_macro(struct man *man, int tok, int line,
man->next = MAN_NEXT_SIBLING;
}
- for ( ; man->last && man->last != n;
- man->last = man->last->parent) {
+ /*
+ * Note that when TH is pruned, we'll be back at the root, so
+ * make sure that we don't clobber as its sibling.
+ */
+
+ for ( ; man->last; man->last = man->last->parent) {
+ if (man->last == n)
+ break;
+ if (man->last->type == MAN_ROOT)
+ break;
if ( ! man_valid_post(man))
return(0);
if ( ! man_action_post(man))
@@ -66,12 +74,16 @@ man_macro(struct man *man, int tok, int line,
assert(man->last);
- if ( ! man_valid_post(man))
+ /*
+ * Same here regarding whether we're back at the root.
+ */
+
+ if (man->last->type != MAN_ROOT && ! man_valid_post(man))
return(0);
- if ( ! man_action_post(man))
+ if (man->last->type != MAN_ROOT && ! man_action_post(man))
return(0);
-
- man->next = MAN_NEXT_SIBLING;
+ if (man->last->type != MAN_ROOT)
+ man->next = MAN_NEXT_SIBLING;
return(1);
}
@@ -88,6 +100,7 @@ man_macroend(struct man *m)
if ( ! man_action_post(m))
return(0);
}
+ assert(m->last == m->first);
if ( ! man_valid_post(m))
return(0);