aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
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 /mdoc.c
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.
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c18
1 files changed, 13 insertions, 5 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;