=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.143 retrieving revision 1.147 diff -u -p -r1.143 -r1.147 --- mandoc/mdoc_term.c 2010/06/07 11:01:15 1.143 +++ mandoc/mdoc_term.c 2010/06/12 10:09:19 1.147 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.143 2010/06/07 11:01:15 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.147 2010/06/12 10:09:19 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -60,14 +60,13 @@ static int arg_hasattr(int, const struct mdoc_node * static int arg_getattrs(const int *, int *, size_t, const struct mdoc_node *); static int arg_getattr(int, const struct mdoc_node *); -static int arg_disptype(const struct mdoc_node *); static void print_bvspace(struct termp *, const struct mdoc_node *, const struct mdoc_node *); static void print_mdoc_node(DECL_ARGS); -static void print_mdoc_head(DECL_ARGS); static void print_mdoc_nodelist(DECL_ARGS); -static void print_foot(DECL_ARGS); +static void print_mdoc_head(struct termp *, const void *); +static void print_mdoc_foot(struct termp *, const void *); static void synopsis_pre(struct termp *, const struct mdoc_node *); @@ -289,10 +288,12 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc) n = mdoc_node(mdoc); m = mdoc_meta(mdoc); - print_mdoc_head(p, NULL, m, n); + term_begin(p, print_mdoc_head, print_mdoc_foot, m); + if (n->child) print_mdoc_nodelist(p, NULL, m, n->child); - print_foot(p, NULL, m, n); + + term_end(p); } @@ -346,12 +347,14 @@ print_mdoc_node(DECL_ARGS) } -/* ARGSUSED */ static void -print_foot(DECL_ARGS) +print_mdoc_foot(struct termp *p, const void *arg) { char buf[DATESIZ], os[BUFSIZ]; + const struct mdoc_meta *m; + m = (const struct mdoc_meta *)arg; + term_fontrepl(p, TERMFONT_NONE); /* @@ -395,12 +398,14 @@ print_foot(DECL_ARGS) } -/* ARGSUSED */ static void -print_mdoc_head(DECL_ARGS) +print_mdoc_head(struct termp *p, const void *arg) { char buf[BUFSIZ], title[BUFSIZ]; + const struct mdoc_meta *m; + m = (const struct mdoc_meta *)arg; + p->rmargin = p->maxrmargin; p->offset = 0; @@ -483,35 +488,6 @@ a2width(const struct mdoc_argv *arg, int pos) } -static int -arg_disptype(const struct mdoc_node *n) -{ - int i, len; - - assert(MDOC_BLOCK == n->type); - - len = (int)(n->args ? n->args->argc : 0); - - for (i = 0; i < len; i++) - switch (n->args->argv[i].arg) { - case (MDOC_Centred): - /* FALLTHROUGH */ - case (MDOC_Ragged): - /* FALLTHROUGH */ - case (MDOC_Filled): - /* FALLTHROUGH */ - case (MDOC_Unfilled): - /* FALLTHROUGH */ - case (MDOC_Literal): - return(n->args->argv[i].arg); - default: - break; - } - - return(-1); -} - - static size_t a2offs(const struct mdoc_argv *arg) { @@ -1626,7 +1602,7 @@ static int termp_bd_pre(DECL_ARGS) { size_t tabwidth; - int i, type; + int i; size_t rm, rmax; const struct mdoc_node *nn; @@ -1638,9 +1614,6 @@ termp_bd_pre(DECL_ARGS) nn = n->parent; - type = arg_disptype(nn); - assert(-1 != type); - if (-1 != (i = arg_getattr(MDOC_Offset, nn))) p->offset += a2offs(&nn->args->argv[i]); @@ -1652,7 +1625,8 @@ termp_bd_pre(DECL_ARGS) * lines are allowed. */ - if (MDOC_Literal != type && MDOC_Unfilled != type) + if (DISP_literal != n->data.disp && + DISP_unfilled != n->data.disp) return(1); tabwidth = p->tabwidth; @@ -1669,8 +1643,8 @@ termp_bd_pre(DECL_ARGS) NULL == nn->next) term_flushln(p); } - p->tabwidth = tabwidth; + p->tabwidth = tabwidth; p->rmargin = rm; p->maxrmargin = rmax; return(0); @@ -1681,19 +1655,16 @@ termp_bd_pre(DECL_ARGS) static void termp_bd_post(DECL_ARGS) { - int type; size_t rm, rmax; if (MDOC_BODY != n->type) return; - type = arg_disptype(n->parent); - assert(-1 != type); - rm = p->rmargin; rmax = p->maxrmargin; - if (MDOC_Literal == type || MDOC_Unfilled == type) + if (DISP_literal == n->data.disp || + DISP_unfilled == n->data.disp) p->rmargin = p->maxrmargin = TERM_MAXMARGIN; p->flags |= TERMP_NOSPACE;