diff options
author | 2010-07-01 22:56:17 +0000 | |
---|---|---|
committer | 2010-07-01 22:56:17 +0000 | |
commit | f813f185be40796eacad83ea709b1ba0374a67c1 (patch) | |
tree | 1e588554fee5273076627d525b9303ba919d21e4 /mdoc_action.c | |
parent | e552a5cef0219ea63fb9521677e1a8a05ad35727 (diff) | |
download | mandoc-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_action.c')
-rw-r--r-- | mdoc_action.c | 37 |
1 files changed, 12 insertions, 25 deletions
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); |