summaryrefslogtreecommitdiffstats
path: root/man_macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-07 05:42:32 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-07 05:42:32 +0000
commitc90e17bfe549f6a33060192d25fc7faa7dd1fa9f (patch)
tree6287aecf1f42a5e3b511d7fef432c0102ea42052 /man_macro.c
parent58203ef0eda5f512dfe95aed2433ffe3d7ac59c7 (diff)
downloadmandoc-c90e17bfe549f6a33060192d25fc7faa7dd1fa9f.tar.gz
Fix a bug in the -man parser where deleting nodes (such as `PP' or `LP'
in certain situations) caused the next macros to be assigned as siblings instead of child nodes to the original parent. Noticed and ok by schwarze@.
Diffstat (limited to 'man_macro.c')
-rw-r--r--man_macro.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/man_macro.c b/man_macro.c
index e320a6e2..10611669 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -120,6 +120,9 @@ man_unscope(struct man *m, const struct man_node *to,
assert(to);
+ assert(MAN_ROOT != m->last->type);
+ m->next = MAN_NEXT_SIBLING;
+
/* LINTED */
while (m->last != to) {
/*
@@ -140,9 +143,6 @@ man_unscope(struct man *m, const struct man_node *to,
if ( ! man_valid_post(m))
return(0);
- m->next = MAN_ROOT == m->last->type ?
- MAN_NEXT_CHILD : MAN_NEXT_SIBLING;
-
return(1);
}
@@ -428,6 +428,9 @@ in_line_eoln(MACRO_PROT_ARGS)
assert( ! (MAN_SCOPED & man_macros[tok].flags));
m->flags |= MAN_ILINE;
}
+
+ assert(MAN_ROOT != m->last->type);
+ m->next = MAN_NEXT_SIBLING;
/*
* Rewind our element scope. Note that when TH is pruned, we'll
@@ -453,9 +456,6 @@ in_line_eoln(MACRO_PROT_ARGS)
if (m->last->type != MAN_ROOT && ! man_valid_post(m))
return(0);
- m->next = MAN_ROOT == m->last->type ?
- MAN_NEXT_CHILD : MAN_NEXT_SIBLING;
-
return(1);
}