=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.348 retrieving revision 1.353 diff -u -p -r1.348 -r1.353 --- mandoc/mdoc_term.c 2017/04/14 19:35:22 1.348 +++ mandoc/mdoc_term.c 2017/05/05 02:06:19 1.353 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.348 2017/04/14 19:35:22 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.353 2017/05/05 02:06:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2017 Ingo Schwarze @@ -125,8 +125,7 @@ static int termp_vt_pre(DECL_ARGS); static int termp_xr_pre(DECL_ARGS); static int termp_xx_pre(DECL_ARGS); -static const struct termact termacts[MDOC_MAX] = { - { termp_ap_pre, NULL }, /* Ap */ +static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = { { NULL, NULL }, /* Dd */ { NULL, NULL }, /* Dt */ { NULL, NULL }, /* Os */ @@ -142,6 +141,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_it_pre, termp_it_post }, /* It */ { termp_under_pre, NULL }, /* Ad */ { termp_an_pre, NULL }, /* An */ + { termp_ap_pre, NULL }, /* Ap */ { termp_under_pre, NULL }, /* Ar */ { termp_cd_pre, NULL }, /* Cd */ { termp_bold_pre, NULL }, /* Cm */ @@ -244,15 +244,16 @@ static const struct termact termacts[MDOC_MAX] = { { termp_quote_pre, termp_quote_post }, /* En */ { termp_xx_pre, termp_xx_post }, /* Dx */ { NULL, termp____post }, /* %Q */ - { termp_sp_pre, NULL }, /* br */ { termp_sp_pre, NULL }, /* sp */ { NULL, termp____post }, /* %U */ { NULL, NULL }, /* Ta */ { termp_ll_pre, NULL }, /* ll */ }; +static const struct termact *const termacts = __termacts - MDOC_Dd; static int fn_prio; + void terminal_mdoc(void *arg, const struct roff_man *mdoc) { @@ -363,7 +364,13 @@ print_mdoc_node(DECL_ARGS) term_tbl(p, n->span); break; default: - if (termacts[n->tok].pre && + if (n->tok < ROFF_MAX) { + roff_term_pre(p, n); + chld = 0; + break; + } + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); + if (termacts[n->tok].pre != NULL && (n->end == ENDBODY_NOT || n->child != NULL)) chld = (*termacts[n->tok].pre) (p, &npair, meta, n); @@ -384,7 +391,9 @@ print_mdoc_node(DECL_ARGS) case ROFFT_EQN: break; default: - if ( ! termacts[n->tok].post || NODE_ENDED & n->flags) + if (n->tok < ROFF_MAX || + termacts[n->tok].post == NULL || + n->flags & NODE_ENDED) break; (void)(*termacts[n->tok].post)(p, &npair, meta, n); @@ -1502,7 +1511,7 @@ termp_bd_pre(DECL_ARGS) */ switch (nn->tok) { case MDOC_Sm: - case MDOC_br: + case ROFF_br: case MDOC_sp: case MDOC_Bl: case MDOC_D1: @@ -1664,7 +1673,7 @@ termp_sp_pre(DECL_ARGS) } else len = 1; break; - case MDOC_br: + case ROFF_br: len = 0; break; default: @@ -1995,12 +2004,13 @@ termp_lk_pre(DECL_ARGS) const struct roff_node *link, *descr; int display; - if (NULL == (link = n->child)) + if ((link = n->child) == NULL) return 0; - if (NULL != (descr = link->next)) { + /* Link text. */ + if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) { term_fontpush(p, TERMFONT_UNDER); - while (NULL != descr) { + while (descr != NULL && !(descr->flags & NODE_DELIMC)) { term_word(p, descr->string); descr = descr->next; } @@ -2009,19 +2019,24 @@ termp_lk_pre(DECL_ARGS) term_word(p, ":"); } + /* Link target. */ display = term_strlen(p, link->string) >= 26; if (display) { term_newln(p); p->offset += term_len(p, p->defindent + 1); } - term_fontpush(p, TERMFONT_BOLD); term_word(p, link->string); term_fontpop(p); + /* Trailing punctuation. */ + while (descr != NULL) { + p->flags |= TERMP_NOSPACE; + term_word(p, descr->string); + descr = descr->next; + } if (display) term_newln(p); - return 0; }