=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.171 retrieving revision 1.172 diff -u -p -r1.171 -r1.172 --- mandoc/mdoc.c 2010/12/22 11:15:16 1.171 +++ mandoc/mdoc.c 2010/12/24 14:00:40 1.172 @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.171 2010/12/22 11:15:16 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.172 2010/12/24 14:00:40 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -328,6 +328,23 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p) p->parent->nchild++; + /* + * Copy over the normalised-data pointer of our parent. Not + * everybody has one, but copying a null pointer is fine. + */ + + switch (p->type) { + case (MDOC_BODY): + /* FALLTHROUGH */ + case (MDOC_TAIL): + /* FALLTHROUGH */ + case (MDOC_HEAD): + p->norm = p->parent->norm; + break; + default: + break; + } + if ( ! mdoc_valid_pre(mdoc, p)) return(0); @@ -460,6 +477,19 @@ mdoc_block_alloc(struct mdoc *m, int line, int pos, p->args = args; if (p->args) (args->refcnt)++; + + switch (tok) { + case (MDOC_Bd): + /* FALLTHROUGH */ + case (MDOC_Bf): + /* FALLTHROUGH */ + case (MDOC_Bl): + p->norm = mandoc_calloc(1, sizeof(union mdoc_data)); + break; + default: + break; + } + if ( ! node_append(m, p)) return(0); m->next = MDOC_NEXT_CHILD; @@ -477,6 +507,15 @@ mdoc_elem_alloc(struct mdoc *m, int line, int pos, p->args = args; if (p->args) (args->refcnt)++; + + switch (tok) { + case (MDOC_An): + p->norm = mandoc_calloc(1, sizeof(union mdoc_data)); + break; + default: + break; + } + if ( ! node_append(m, p)) return(0); m->next = MDOC_NEXT_CHILD; @@ -511,9 +550,8 @@ static void mdoc_node_free(struct mdoc_node *p) { - if (p->norm && 0 == --(p->norm->refcnt)) + if (MDOC_BLOCK == p->type || MDOC_ELEM == p->type) free(p->norm); - if (p->string) free(p->string); if (p->args) @@ -608,7 +646,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int of */ if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->norm->d.Bl.type) { + LIST_column == n->norm->Bl.type) { /* `Bl' is open without any children. */ m->flags |= MDOC_FREECOL; return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); @@ -617,7 +655,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int of if (MDOC_It == n->tok && MDOC_BLOCK == n->type && NULL != n->parent && MDOC_Bl == n->parent->tok && - LIST_column == n->parent->norm->d.Bl.type) { + LIST_column == n->parent->norm->Bl.type) { /* `Bl' has block-level `It' children. */ m->flags |= MDOC_FREECOL; return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); @@ -798,7 +836,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off */ if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->norm->d.Bl.type) { + LIST_column == n->norm->Bl.type) { m->flags |= MDOC_FREECOL; if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) goto err; @@ -814,7 +852,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off if (MDOC_It == n->tok && MDOC_BLOCK == n->type && NULL != n->parent && MDOC_Bl == n->parent->tok && - LIST_column == n->parent->norm->d.Bl.type) { + LIST_column == n->parent->norm->Bl.type) { m->flags |= MDOC_FREECOL; if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) goto err;