aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit517aac06093f32752f40e67b9987a09fb33ac2e4 (patch)
treed25ef3ffea73d4a0cf275e027cdf352a01502687 /man_macro.c
parent0e818890715b02cfc9193a512e76aa36d7aa28db (diff)
downloadmandoc-517aac06093f32752f40e67b9987a09fb33ac2e4.tar.gz
mandoc-517aac06093f32752f40e67b9987a09fb33ac2e4.tar.zst
mandoc-517aac06093f32752f40e67b9987a09fb33ac2e4.zip
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.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/man_macro.c b/man_macro.c
index c5a7d4ab..1d0a431b 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.63 2011/06/18 17:36:52 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.64 2011/07/07 05:42:32 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);
}