source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Make struct_bl and struct_bd into pointers.
@ 2010-07-01 22:56 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-07-01 22:56 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        mdoc.c
        mdoc.h
        mdoc_action.c
        mdoc_argv.c
        mdoc_html.c
        mdoc_term.c
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.103 -r1.104
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -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;
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.89 -r1.90
--- mdoc_html.c
+++ mdoc_html.c
@@ -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");
Index: mdoc_action.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_action.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -Lmdoc_action.c -Lmdoc_action.c -u -p -r1.73 -r1.74
--- mdoc_action.c
+++ mdoc_action.c
@@ -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);
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.164
retrieving revision 1.165
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.164 -r1.165
--- mdoc_term.c
+++ mdoc_term.c
@@ -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;
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -Lmdoc.h -Lmdoc.h -u -p -r1.95 -r1.96
--- mdoc.h
+++ mdoc.h
@@ -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;
 };
 
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -Lmdoc.c -Lmdoc.c -u -p -r1.153 -r1.154
--- mdoc.c
+++ mdoc.c
@@ -514,10 +514,18 @@ mdoc_word_alloc(struct mdoc *m, int line
 }
 
 
+/* 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, cha
 	 */
 
 	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, cha
 	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
 	 */
 
 	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
 	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;
Index: mdoc_argv.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_argv.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.54 -r1.55
--- mdoc_argv.c
+++ mdoc_argv.c
@@ -359,7 +359,8 @@ mdoc_args(struct mdoc *m, int line, int 
 		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;
 	}
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-01 22:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-01 22:56 mdocml: Make struct_bl and struct_bd into pointers kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).