=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.205 retrieving revision 1.212 diff -u -p -r1.205 -r1.212 --- mandoc/mdoc_term.c 2010/12/25 23:27:50 1.205 +++ mandoc/mdoc_term.c 2011/01/25 15:28:56 1.212 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.205 2010/12/25 23:27:50 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.212 2011/01/25 15:28:56 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -73,7 +73,6 @@ static void termp_an_post(DECL_ARGS); static void termp_bd_post(DECL_ARGS); static void termp_bk_post(DECL_ARGS); static void termp_bl_post(DECL_ARGS); -static void termp_bx_post(DECL_ARGS); static void termp_d1_post(DECL_ARGS); static void termp_fo_post(DECL_ARGS); static void termp_in_post(DECL_ARGS); @@ -95,6 +94,7 @@ static int termp_bk_pre(DECL_ARGS); static int termp_bl_pre(DECL_ARGS); static int termp_bold_pre(DECL_ARGS); static int termp_bt_pre(DECL_ARGS); +static int termp_bx_pre(DECL_ARGS); static int termp_cd_pre(DECL_ARGS); static int termp_d1_pre(DECL_ARGS); static int termp_ex_pre(DECL_ARGS); @@ -187,7 +187,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_quote_pre, termp_quote_post }, /* Bo */ { termp_quote_pre, termp_quote_post }, /* Bq */ { termp_xx_pre, NULL }, /* Bsx */ - { NULL, termp_bx_post }, /* Bx */ + { termp_bx_pre, NULL }, /* Bx */ { NULL, NULL }, /* Db */ { NULL, NULL }, /* Dc */ { termp_quote_pre, termp_quote_post }, /* Do */ @@ -312,12 +312,23 @@ print_mdoc_node(DECL_ARGS) memset(&npair, 0, sizeof(struct termpair)); npair.ppair = pair; + + switch (n->type) { + case (MDOC_TEXT): + if (' ' == *n->string && MDOC_LINE & n->flags) + term_newln(p); + term_word(p, n->string); + break; + case (MDOC_TBL): + term_tbl(p, n->span); + break; + default: + if (termacts[n->tok].pre && ENDBODY_NOT == n->end) + chld = (*termacts[n->tok].pre) + (p, &npair, m, n); + break; + } - if (MDOC_TEXT == n->type) - term_word(p, n->string); - else if (termacts[n->tok].pre && ENDBODY_NOT == n->end) - chld = (*termacts[n->tok].pre)(p, &npair, m, n); - /* * Keeps only work until the end of a line. If a keep was * invoked in a prior line, revert it to PREKEEP. @@ -353,8 +364,14 @@ print_mdoc_node(DECL_ARGS) term_fontpopq(p, font); - if (MDOC_TEXT != n->type && termacts[n->tok].post && - ! (MDOC_ENDED & n->flags)) { + switch (n->type) { + case (MDOC_TEXT): + break; + case (MDOC_TBL): + break; + default: + if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags) + break; (void)(*termacts[n->tok].post)(p, &npair, m, n); /* @@ -372,6 +389,7 @@ print_mdoc_node(DECL_ARGS) */ if (ENDBODY_NOSPACE == n->end) p->flags |= TERMP_NOSPACE; + break; } if (MDOC_EOS & n->flags) @@ -1583,7 +1601,9 @@ termp_bd_pre(DECL_ARGS) return(1); tabwidth = p->tabwidth; - p->tabwidth = term_len(p, 8); + if (DISP_literal == n->norm->Bd.type) + p->tabwidth = term_len(p, 8); + rm = p->rmargin; rmax = p->maxrmargin; p->rmargin = p->maxrmargin = TERM_MAXMARGIN; @@ -1654,13 +1674,32 @@ termp_bd_post(DECL_ARGS) /* ARGSUSED */ -static void -termp_bx_post(DECL_ARGS) +static int +termp_bx_pre(DECL_ARGS) { + char buf[3]; - if (n->child) + if (NULL != (n = n->child)) { + term_word(p, n->string); p->flags |= TERMP_NOSPACE; - term_word(p, "BSD"); + term_word(p, "BSD"); + } else { + term_word(p, "BSD"); + return(0); + } + + if (NULL != (n = n->next)) { + buf[0] = '-'; + buf[1] = toupper((unsigned char)*n->string); + buf[2] = '\0'; + + p->flags |= TERMP_NOSPACE; + term_word(p, buf); + p->flags |= TERMP_NOSPACE; + term_word(p, n->string + 1); + } + + return(0); } @@ -2149,7 +2188,7 @@ termp__t_post(DECL_ARGS) * us instead of underlining us (for disambiguation). */ if (n->parent && MDOC_Rs == n->parent->tok && - n->parent->norm->Rs.child_J) + n->parent->norm->Rs.quote_T) termp_quote_post(p, pair, m, n); termp____post(p, pair, m, n); @@ -2165,7 +2204,7 @@ termp__t_pre(DECL_ARGS) * us instead of underlining us (for disambiguation). */ if (n->parent && MDOC_Rs == n->parent->tok && - n->parent->norm->Rs.child_J) + n->parent->norm->Rs.quote_T) return(termp_quote_pre(p, pair, m, n)); term_fontpush(p, TERMFONT_UNDER);