From af1a16ee46c535e7e97fe26fc4c6c05844de41e2 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sat, 12 Jun 2010 11:21:44 +0000 Subject: Cache all of `Bd's resolved arguments into mdoc_bd, which is stashed in the "data" union in mdoc_node. Allows me to remove some ugly loops in the front-end and duplicate tests in mdoc_action.c. Add a regression test to make sure we're not doing anything bad (more to come). --- mdoc_html.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'mdoc_html.c') diff --git a/mdoc_html.c b/mdoc_html.c index 0df11dc3..302cecb8 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.79 2010/06/12 10:09:19 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.80 2010/06/12 11:21:44 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -1353,31 +1353,19 @@ static int mdoc_bd_pre(MDOC_ARGS) { struct htmlpair tag[2]; - int comp, i; - const struct mdoc_node *bl, *nn; + int comp; + const struct mdoc_node *nn; struct roffsu su; - if (MDOC_BLOCK == n->type) - bl = n; - else if (MDOC_HEAD == n->type) + if (MDOC_HEAD == n->type) return(0); - else - bl = n->parent; SCALE_VS_INIT(&su, 0); - comp = 0; - for (i = 0; bl->args && i < (int)bl->args->argc; i++) - switch (bl->args->argv[i].arg) { - case (MDOC_Offset): - a2offs(bl->args->argv[i].value[0], &su); - break; - case (MDOC_Compact): - comp = 1; - break; - default: - break; - } + if (n->data.Bd.offs) + a2offs(n->data.Bd.offs, &su); + + comp = n->data.Bd.comp; /* FIXME: -centered, etc. formatting. */ /* FIXME: does not respect -offset ??? */ @@ -1404,8 +1392,8 @@ mdoc_bd_pre(MDOC_ARGS) return(1); } - if (DISP_unfilled != n->data.disp && - DISP_literal != n->data.disp) + if (DISP_unfilled != n->data.Bd.type && + DISP_literal != n->data.Bd.type) return(1); PAIR_CLASS_INIT(&tag[0], "lit"); -- cgit v1.2.3-56-ge451