aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-01 22:56:17 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-01 22:56:17 +0000
commitf813f185be40796eacad83ea709b1ba0374a67c1 (patch)
tree1e588554fee5273076627d525b9303ba919d21e4
parente552a5cef0219ea63fb9521677e1a8a05ad35727 (diff)
downloadmandoc-f813f185be40796eacad83ea709b1ba0374a67c1.tar.gz
mandoc-f813f185be40796eacad83ea709b1ba0374a67c1.tar.zst
mandoc-f813f185be40796eacad83ea709b1ba0374a67c1.zip
Make struct_bl and struct_bd into pointers. This removes the need to do
copying on internals after modification. Even more importantly, if an ENDBODY token is provided, it would have been impossible for post-change copying of the data to take place in the BLOCK. This allows it to happen by dint of pointers. Also did some bikeshedding in mdoc_term.c: checking against enum type and explicitly casting to the "post" function to void. This is for my own readability.
-rw-r--r--mdoc.c18
-rw-r--r--mdoc.h6
-rw-r--r--mdoc_action.c37
-rw-r--r--mdoc_argv.c5
-rw-r--r--mdoc_html.c31
-rw-r--r--mdoc_term.c48
-rw-r--r--mdoc_validate.c119
7 files changed, 139 insertions, 125 deletions
diff --git a/mdoc.c b/mdoc.c
index 0526f5bd..ea1fa47f 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.153 2010/07/01 22:35:54 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.154 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -514,10 +514,18 @@ mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p)
}
+/* FIXME: put in mdoc_node_delete(). */
void
mdoc_node_free(struct mdoc_node *p)
{
+ if (MDOC_Bd == p->tok && MDOC_BLOCK == p->type)
+ if (p->data.Bd)
+ free(p->data.Bd);
+ if (MDOC_Bl == p->tok && MDOC_BLOCK == p->type)
+ if (p->data.Bl)
+ free(p->data.Bl);
+
if (p->string)
free(p->string);
if (p->args)
@@ -610,7 +618,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->data.Bl.type) {
+ LIST_column == n->data.Bl->type) {
/* `Bl' is open without any children. */
m->flags |= MDOC_FREECOL;
return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
@@ -619,7 +627,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
NULL != n->parent &&
MDOC_Bl == n->parent->tok &&
- LIST_column == n->parent->data.Bl.type) {
+ LIST_column == n->parent->data.Bl->type) {
/* `Bl' has block-level `It' children. */
m->flags |= MDOC_FREECOL;
return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
@@ -825,7 +833,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->data.Bl.type) {
+ LIST_column == n->data.Bl->type) {
m->flags |= MDOC_FREECOL;
if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf))
goto err;
@@ -841,7 +849,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
NULL != n->parent &&
MDOC_Bl == n->parent->tok &&
- LIST_column == n->parent->data.Bl.type) {
+ LIST_column == n->parent->data.Bl->type) {
m->flags |= MDOC_FREECOL;
if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf))
goto err;
diff --git a/mdoc.h b/mdoc.h
index 06f97688..0250b07e 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.95 2010/06/29 19:20:38 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.96 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -321,8 +321,8 @@ struct mdoc_node {
enum mdoc_endbody end; /* BODY */
union {
- struct mdoc_bl Bl;
- struct mdoc_bd Bd;
+ struct mdoc_bl *Bl;
+ struct mdoc_bd *Bd;
} data;
};
diff --git a/mdoc_action.c b/mdoc_action.c
index e4eed904..0618f3ea 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.73 2010/07/01 22:35:54 schwarze Exp $ */
+/* $Id: mdoc_action.c,v 1.74 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -696,7 +696,7 @@ post_bl_tagwidth(POST_ARGS)
n->args->argv[i].value[0] = mandoc_strdup(buf);
/* Set our width! */
- n->data.Bl.width = n->args->argv[i].value[0];
+ n->data.Bl->width = n->args->argv[i].value[0];
return(1);
}
@@ -719,9 +719,9 @@ post_bl_width(POST_ARGS)
* the macro's width as set in share/tmac/mdoc/doc-common.
*/
- if (0 == strcmp(n->data.Bl.width, "Ds"))
+ if (0 == strcmp(n->data.Bl->width, "Ds"))
width = 6;
- else if (MDOC_MAX == (tok = mdoc_hash_find(n->data.Bl.width)))
+ else if (MDOC_MAX == (tok = mdoc_hash_find(n->data.Bl->width)))
return(1);
else if (0 == (width = mdoc_macro2len(tok)))
return(mdoc_nmsg(m, n, MANDOCERR_BADWIDTH));
@@ -741,7 +741,7 @@ post_bl_width(POST_ARGS)
n->args->argv[i].value[0] = mandoc_strdup(buf);
/* Set our width! */
- n->data.Bl.width = n->args->argv[i].value[0];
+ n->data.Bl->width = n->args->argv[i].value[0];
return(1);
}
@@ -757,7 +757,7 @@ post_bl_head(POST_ARGS)
int i, c;
struct mdoc_node *np, *nn, *nnp;
- if (LIST_column != n->data.Bl.type)
+ if (LIST_column != n->data.Bl->type)
return(1);
else if (NULL == n->child)
return(1);
@@ -799,8 +799,6 @@ post_bl_head(POST_ARGS)
static int
post_bl(POST_ARGS)
{
- struct mdoc_node *nn;
- const char *ww;
if (MDOC_HEAD == n->type)
return(post_bl_head(m, n));
@@ -815,28 +813,16 @@ post_bl(POST_ARGS)
* rewritten into real lengths).
*/
- ww = n->data.Bl.width;
-
- if (LIST_tag == n->data.Bl.type && NULL == n->data.Bl.width) {
+ if (LIST_tag == n->data.Bl->type && NULL == n->data.Bl->width) {
if ( ! post_bl_tagwidth(m, n))
return(0);
- } else if (NULL != n->data.Bl.width) {
+ } else if (NULL != n->data.Bl->width) {
if ( ! post_bl_width(m, n))
return(0);
} else
return(1);
- assert(n->data.Bl.width);
-
- /* If it has changed, propogate new width to children. */
-
- if (ww == n->data.Bl.width)
- return(1);
-
- for (nn = n->child; nn; nn = nn->next)
- if (MDOC_Bl == nn->tok)
- nn->data.Bl.width = n->data.Bl.width;
-
+ assert(n->data.Bl->width);
return(1);
}
@@ -967,9 +953,10 @@ pre_bd(PRE_ARGS)
if (MDOC_BODY != n->type)
return(1);
- if (DISP_literal == n->data.Bd.type)
+ assert(n->data.Bd);
+ if (DISP_literal == n->data.Bd->type)
m->flags |= MDOC_LITERAL;
- if (DISP_unfilled == n->data.Bd.type)
+ if (DISP_unfilled == n->data.Bd->type)
m->flags |= MDOC_LITERAL;
return(1);
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 700d558a..379f458d 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.54 2010/06/19 20:46:28 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.55 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -359,7 +359,8 @@ mdoc_args(struct mdoc *m, int line, int *pos,
if (MDOC_Bl == n->tok)
break;
- if (n && LIST_column == n->data.Bl.type) {
+ assert(n->data.Bl);
+ if (n && LIST_column == n->data.Bl->type) {
fl |= ARGS_TABSEP;
fl &= ~ARGS_DELIM;
}
diff --git a/mdoc_html.c b/mdoc_html.c
index 1b521c6a..1277a765 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.89 2010/07/01 14:34:03 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.90 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -1038,11 +1038,12 @@ mdoc_it_pre(MDOC_ARGS)
SCALE_HS_INIT(&offs, 0);
- type = bl->data.Bl.type;
- comp = bl->data.Bl.comp;
+ assert(bl->data.Bl);
+ type = bl->data.Bl->type;
+ comp = bl->data.Bl->comp;
- if (bl->data.Bl.offs)
- a2offs(bl->data.Bl.offs, &offs);
+ if (bl->data.Bl->offs)
+ a2offs(bl->data.Bl->offs, &offs);
switch (type) {
case (LIST_enum):
@@ -1059,8 +1060,8 @@ mdoc_it_pre(MDOC_ARGS)
break;
}
- if (bl->data.Bl.width)
- a2width(bl->data.Bl.width, &width);
+ if (bl->data.Bl->width)
+ a2width(bl->data.Bl->width, &width);
wp = -1;
for (i = 0; bl->args && i < (int)bl->args->argc; i++)
@@ -1118,7 +1119,8 @@ mdoc_bl_pre(MDOC_ARGS)
return(0);
if (MDOC_BLOCK != n->type)
return(1);
- if (LIST_enum != n->data.Bl.type)
+ assert(n->data.Bl);
+ if (LIST_enum != n->data.Bl->type)
return(1);
ord = malloc(sizeof(struct ord));
@@ -1142,7 +1144,7 @@ mdoc_bl_post(MDOC_ARGS)
if (MDOC_BLOCK != n->type)
return;
- if (LIST_enum != n->data.Bl.type)
+ if (LIST_enum != n->data.Bl->type)
return;
ord = h->ords.head;
@@ -1357,10 +1359,11 @@ mdoc_bd_pre(MDOC_ARGS)
SCALE_VS_INIT(&su, 0);
- if (n->data.Bd.offs)
- a2offs(n->data.Bd.offs, &su);
+ assert(n->data.Bd);
+ if (n->data.Bd->offs)
+ a2offs(n->data.Bd->offs, &su);
- comp = n->data.Bd.comp;
+ comp = n->data.Bd->comp;
/* FIXME: -centered, etc. formatting. */
/* FIXME: does not respect -offset ??? */
@@ -1387,8 +1390,8 @@ mdoc_bd_pre(MDOC_ARGS)
return(1);
}
- if (DISP_unfilled != n->data.Bd.type &&
- DISP_literal != n->data.Bd.type)
+ if (DISP_unfilled != n->data.Bd->type &&
+ DISP_literal != n->data.Bd->type)
return(1);
PAIR_CLASS_INIT(&tag[0], "lit");
diff --git a/mdoc_term.c b/mdoc_term.c
index 338e3c72..1dc3cfd2 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.164 2010/07/01 15:38:56 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.165 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -336,17 +336,16 @@ print_mdoc_node(DECL_ARGS)
term_fontpopq(p, font);
- if (MDOC_TEXT != n->type &&
- termacts[n->tok].post &&
- ! (MDOC_ENDED & n->flags)) {
- (*termacts[n->tok].post)(p, &npair, m, n);
+ if (MDOC_TEXT != n->type && termacts[n->tok].post &&
+ ! (MDOC_ENDED & n->flags)) {
+ (void)(*termacts[n->tok].post)(p, &npair, m, n);
/*
* Explicit end tokens not only call the post
* handler, but also tell the respective block
* that it must not call the post handler again.
*/
- if (n->end)
+ if (ENDBODY_NOT != n->end)
n->pending->flags |= MDOC_ENDED;
/*
@@ -574,9 +573,9 @@ print_bvspace(struct termp *p,
term_newln(p);
- if (MDOC_Bd == bl->tok && bl->data.Bd.comp)
+ if (MDOC_Bd == bl->tok && bl->data.Bd->comp)
return;
- if (MDOC_Bl == bl->tok && bl->data.Bl.comp)
+ if (MDOC_Bl == bl->tok && bl->data.Bl->comp)
return;
/* Do not vspace directly after Ss/Sh. */
@@ -595,13 +594,13 @@ print_bvspace(struct termp *p,
/* A `-column' does not assert vspace within the list. */
- if (MDOC_Bl == bl->tok && LIST_column == bl->data.Bl.type)
+ if (MDOC_Bl == bl->tok && LIST_column == bl->data.Bl->type)
if (n->prev && MDOC_It == n->prev->tok)
return;
/* A `-diag' without body does not vspace. */
- if (MDOC_Bl == bl->tok && LIST_diag == bl->data.Bl.type)
+ if (MDOC_Bl == bl->tok && LIST_diag == bl->data.Bl->type)
if (n->prev && MDOC_It == n->prev->tok) {
assert(n->prev->body);
if (NULL == n->prev->body->child)
@@ -655,7 +654,8 @@ termp_it_pre(DECL_ARGS)
}
bl = n->parent->parent->parent;
- type = bl->data.Bl.type;
+ assert(bl->data.Bl);
+ type = bl->data.Bl->type;
/*
* First calculate width and offset. This is pretty easy unless
@@ -665,8 +665,8 @@ termp_it_pre(DECL_ARGS)
width = offset = 0;
- if (bl->data.Bl.offs)
- offset = a2offs(p, bl->data.Bl.offs);
+ if (bl->data.Bl->offs)
+ offset = a2offs(p, bl->data.Bl->offs);
switch (type) {
case (LIST_column):
@@ -716,7 +716,7 @@ termp_it_pre(DECL_ARGS)
width = a2width(p, bl->args->argv[col].value[i]) + dcol;
break;
default:
- if (NULL == bl->data.Bl.width)
+ if (NULL == bl->data.Bl->width)
break;
/*
@@ -724,8 +724,8 @@ termp_it_pre(DECL_ARGS)
* number for buffering single arguments. See the above
* handling for column for how this changes.
*/
- assert(bl->data.Bl.width);
- width = a2width(p, bl->data.Bl.width) + term_len(p, 2);
+ assert(bl->data.Bl->width);
+ width = a2width(p, bl->data.Bl->width) + term_len(p, 2);
break;
}
@@ -987,7 +987,7 @@ termp_it_post(DECL_ARGS)
if (MDOC_BLOCK == n->type)
return;
- type = n->parent->parent->parent->data.Bl.type;
+ type = n->parent->parent->parent->data.Bl->type;
switch (type) {
case (LIST_item):
@@ -1648,8 +1648,9 @@ termp_bd_pre(DECL_ARGS)
} else if (MDOC_HEAD == n->type)
return(0);
- if (n->data.Bd.offs)
- p->offset += a2offs(p, n->data.Bd.offs);
+ assert(n->data.Bd);
+ if (n->data.Bd->offs)
+ p->offset += a2offs(p, n->data.Bd->offs);
/*
* If -ragged or -filled are specified, the block does nothing
@@ -1659,8 +1660,8 @@ termp_bd_pre(DECL_ARGS)
* lines are allowed.
*/
- if (DISP_literal != n->data.Bd.type &&
- DISP_unfilled != n->data.Bd.type)
+ if (DISP_literal != n->data.Bd->type &&
+ DISP_unfilled != n->data.Bd->type)
return(1);
tabwidth = p->tabwidth;
@@ -1697,8 +1698,9 @@ termp_bd_post(DECL_ARGS)
rm = p->rmargin;
rmax = p->maxrmargin;
- if (DISP_literal == n->data.Bd.type ||
- DISP_unfilled == n->data.Bd.type)
+ assert(n->data.Bd);
+ if (DISP_literal == n->data.Bd->type ||
+ DISP_unfilled == n->data.Bd->type)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index f9d5b2a0..d9de3f9f 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.103 2010/07/01 21:44:47 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.104 2010/07/01 22:56:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -154,7 +154,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_notext }, /* Pp */
{ pres_d1, posts_wline }, /* D1 */
{ pres_d1, posts_wline }, /* Dl */
- { pres_bd, posts_bd_bk }, /* Bd */
+ { pres_bd, posts_bd_bk }, /* Bd */
{ NULL, NULL }, /* Ed */
{ pres_bl, posts_bl }, /* Bl */
{ NULL, NULL }, /* El */
@@ -537,19 +537,23 @@ pre_display(PRE_ARGS)
static int
pre_bl(PRE_ARGS)
{
- int i, comp, dup;
- const char *offs, *width;
- enum mdoc_list lt;
+ int i, comp, dup;
+ const char *offs, *width;
+ enum mdoc_list lt;
+ struct mdoc_node *np;
if (MDOC_BLOCK != n->type) {
- assert(n->parent);
- if (ENDBODY_NOT != n->end)
- return(1);
- assert(MDOC_BLOCK == n->parent->type);
- assert(MDOC_Bl == n->parent->tok);
- assert(LIST__NONE != n->parent->data.Bl.type);
- memcpy(&n->data.Bl, &n->parent->data.Bl,
- sizeof(struct mdoc_bl));
+ if (ENDBODY_NOT != n->end) {
+ assert(n->pending);
+ np = n->pending->parent;
+ } else
+ np = n->parent;
+
+ assert(np);
+ assert(MDOC_BLOCK == np->type);
+ assert(MDOC_Bl == np->tok);
+ assert(np->data.Bl);
+ n->data.Bl = np->data.Bl;
return(1);
}
@@ -559,7 +563,8 @@ pre_bl(PRE_ARGS)
* ones. If we find no list type, we default to LIST_item.
*/
- assert(LIST__NONE == n->data.Bl.type);
+ assert(NULL == n->data.Bl);
+ n->data.Bl = mandoc_calloc(1, sizeof(struct mdoc_bl));
/* LINTED */
for (i = 0; n->args && i < (int)n->args->argc; i++) {
@@ -603,18 +608,18 @@ pre_bl(PRE_ARGS)
break;
/* Set list arguments. */
case (MDOC_Compact):
- dup = n->data.Bl.comp;
+ dup = n->data.Bl->comp;
comp = 1;
break;
case (MDOC_Width):
- dup = (NULL != n->data.Bl.width);
+ dup = (NULL != n->data.Bl->width);
width = n->args->argv[i].value[0];
break;
case (MDOC_Offset):
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
offs = n->args->argv[i].value[0];
- dup = (NULL != n->data.Bl.offs);
+ dup = (NULL != n->data.Bl->offs);
break;
}
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))
@@ -628,29 +633,29 @@ pre_bl(PRE_ARGS)
return(0);
if (comp && ! dup)
- n->data.Bl.comp = comp;
+ n->data.Bl->comp = comp;
if (offs && ! dup)
- n->data.Bl.offs = offs;
+ n->data.Bl->offs = offs;
if (width && ! dup)
- n->data.Bl.width = width;
+ n->data.Bl->width = width;
/* Check: multiple list types. */
- if (LIST__NONE != lt && n->data.Bl.type != LIST__NONE)
+ if (LIST__NONE != lt && n->data.Bl->type != LIST__NONE)
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))
return(0);
/* Assign list type. */
- if (LIST__NONE != lt && n->data.Bl.type == LIST__NONE)
- n->data.Bl.type = lt;
+ if (LIST__NONE != lt && n->data.Bl->type == LIST__NONE)
+ n->data.Bl->type = lt;
/* The list type should come first. */
- if (n->data.Bl.type == LIST__NONE)
- if (n->data.Bl.width ||
- n->data.Bl.offs ||
- n->data.Bl.comp)
+ if (n->data.Bl->type == LIST__NONE)
+ if (n->data.Bl->width ||
+ n->data.Bl->offs ||
+ n->data.Bl->comp)
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
return(0);
@@ -659,10 +664,10 @@ pre_bl(PRE_ARGS)
/* Allow lists to default to LIST_item. */
- if (LIST__NONE == n->data.Bl.type) {
+ if (LIST__NONE == n->data.Bl->type) {
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE))
return(0);
- n->data.Bl.type = LIST_item;
+ n->data.Bl->type = LIST_item;
}
/*
@@ -671,9 +676,9 @@ pre_bl(PRE_ARGS)
* and must also be warned.
*/
- switch (n->data.Bl.type) {
+ switch (n->data.Bl->type) {
case (LIST_tag):
- if (n->data.Bl.width)
+ if (n->data.Bl->width)
break;
if (mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG))
break;
@@ -687,7 +692,7 @@ pre_bl(PRE_ARGS)
case (LIST_inset):
/* FALLTHROUGH */
case (LIST_item):
- if (NULL == n->data.Bl.width)
+ if (NULL == n->data.Bl->width)
break;
if (mdoc_nmsg(mdoc, n, MANDOCERR_WIDTHARG))
break;
@@ -703,21 +708,28 @@ pre_bl(PRE_ARGS)
static int
pre_bd(PRE_ARGS)
{
- int i, dup, comp;
- enum mdoc_disp dt;
- const char *offs;
+ int i, dup, comp;
+ enum mdoc_disp dt;
+ const char *offs;
+ struct mdoc_node *np;
if (MDOC_BLOCK != n->type) {
- assert(n->parent);
- assert(MDOC_BLOCK == n->parent->type);
- assert(MDOC_Bd == n->parent->tok);
- assert(DISP__NONE != n->parent->data.Bd.type);
- memcpy(&n->data.Bd, &n->parent->data.Bd,
- sizeof(struct mdoc_bd));
+ if (ENDBODY_NOT != n->end) {
+ assert(n->pending);
+ np = n->pending->parent;
+ } else
+ np = n->parent;
+
+ assert(np);
+ assert(MDOC_BLOCK == np->type);
+ assert(MDOC_Bd == np->tok);
+ assert(np->data.Bd);
+ n->data.Bd = np->data.Bd;
return(1);
}
- assert(DISP__NONE == n->data.Bd.type);
+ assert(NULL == n->data.Bd);
+ n->data.Bd = mandoc_calloc(1, sizeof(struct mdoc_bd));
/* LINTED */
for (i = 0; n->args && i < (int)n->args->argc; i++) {
@@ -748,7 +760,7 @@ pre_bd(PRE_ARGS)
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
offs = n->args->argv[i].value[0];
- dup = (NULL != n->data.Bd.offs);
+ dup = (NULL != n->data.Bd->offs);
break;
}
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV))
@@ -756,7 +768,7 @@ pre_bd(PRE_ARGS)
break;
case (MDOC_Compact):
comp = 1;
- dup = n->data.Bd.comp;
+ dup = n->data.Bd->comp;
break;
default:
abort();
@@ -771,26 +783,26 @@ pre_bd(PRE_ARGS)
/* Make our auxiliary assignments. */
if (offs && ! dup)
- n->data.Bd.offs = offs;
+ n->data.Bd->offs = offs;
if (comp && ! dup)
- n->data.Bd.comp = comp;
+ n->data.Bd->comp = comp;
/* Check whether a type has already been assigned. */
- if (DISP__NONE != dt && n->data.Bd.type != DISP__NONE)
+ if (DISP__NONE != dt && n->data.Bd->type != DISP__NONE)
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP))
return(0);
/* Make our type assignment. */
- if (DISP__NONE != dt && n->data.Bd.type == DISP__NONE)
- n->data.Bd.type = dt;
+ if (DISP__NONE != dt && n->data.Bd->type == DISP__NONE)
+ n->data.Bd->type = dt;
}
- if (DISP__NONE == n->data.Bd.type) {
+ if (DISP__NONE == n->data.Bd->type) {
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE))
return(0);
- n->data.Bd.type = DISP_ragged;
+ n->data.Bd->type = DISP_ragged;
}
return(1);
@@ -1053,7 +1065,8 @@ post_it(POST_ARGS)
return(1);
n = mdoc->last->parent->parent;
- lt = n->data.Bl.type;
+ assert(n->data.Bl);
+ lt = n->data.Bl->type;
if (LIST__NONE == lt) {
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
@@ -1145,7 +1158,7 @@ post_bl_head(POST_ARGS)
assert(mdoc->last->parent);
n = mdoc->last->parent;
- if (LIST_column == n->data.Bl.type) {
+ if (LIST_column == n->data.Bl->type) {
for (i = 0; i < (int)n->args->argc; i++)
if (MDOC_Column == n->args->argv[i].arg)
break;