diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-25 16:07:36 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-25 16:07:36 +0000 |
commit | 8747d57cb532849c7414532781921952821890ef (patch) | |
tree | c625b60ed28132927e965bcbc2515d35041f62ec /man_macro.c | |
parent | 33f7ee51d3c8ff72c2d828a8d5be302ad73cbbe9 (diff) | |
download | mandoc-8747d57cb532849c7414532781921952821890ef.tar.gz |
Actions in place for prologue parsing.
Diffstat (limited to 'man_macro.c')
-rw-r--r-- | man_macro.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/man_macro.c b/man_macro.c index 4431e1b0..87832e1c 100644 --- a/man_macro.c +++ b/man_macro.c @@ -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); |