From ae2c777447f81e8955bb6e0f758b92d95e3b451e Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 1 May 2015 16:01:53 +0000 Subject: [PATCH] Setting the "last" member of struct roff_node was done at an extremely weird place. Move it to the obviously correct place. Surprisingly, this didn't cause any misformatting in the test suite or in any base system manuals, but i cannot believe the code was really correct for all conceivable input, and it would be very hard to verify. At the very least, it cannot have worked for man(7). --- usr.bin/mandoc/mdoc_macro.c | 6 ++---- usr.bin/mandoc/roff.c | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index fb33821ae94..eb1630ac148 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.154 2015/05/01 15:27:17 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.155 2015/05/01 16:01:53 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -256,7 +256,7 @@ lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p) static void rew_last(struct roff_man *mdoc, const struct roff_node *to) { - struct roff_node *n, *np; + struct roff_node *np; if (to->flags & MDOC_VALID) return; @@ -271,10 +271,8 @@ rew_last(struct roff_man *mdoc, const struct roff_node *to) */ np = mdoc->last->parent; mdoc_valid_post(mdoc); - n = mdoc->last; mdoc->last = np; assert(mdoc->last); - mdoc->last->last = n; } mdoc_valid_post(mdoc); } diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index d82eb79552b..f99246a7686 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.141 2015/04/23 16:17:04 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.142 2015/05/01 16:01:53 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -1020,6 +1020,7 @@ roff_node_append(struct roff_man *man, struct roff_node *n) /* NOTREACHED */ } n->parent->nchild++; + n->parent->last = n; /* * Copy over the normalised-data pointer of our parent. Not -- 2.20.1