=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.173 retrieving revision 1.182 diff -u -p -r1.173 -r1.182 --- mandoc/mdoc_term.c 2010/07/07 15:04:54 1.173 +++ mandoc/mdoc_term.c 2010/08/20 22:51:29 1.182 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.173 2010/07/07 15:04:54 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.182 2010/08/20 22:51:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -151,7 +151,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_bl_pre, termp_bl_post }, /* Bl */ { NULL, NULL }, /* El */ { termp_it_pre, termp_it_post }, /* It */ - { NULL, NULL }, /* Ad */ + { termp_under_pre, NULL }, /* Ad */ { termp_an_pre, termp_an_post }, /* An */ { termp_under_pre, NULL }, /* Ar */ { termp_cd_pre, NULL }, /* Cd */ @@ -208,7 +208,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_under_pre, NULL }, /* Em */ { NULL, NULL }, /* Eo */ { termp_xx_pre, NULL }, /* Fx */ - { termp_bold_pre, NULL }, /* Ms */ /* FIXME: convert to symbol? */ + { termp_bold_pre, NULL }, /* Ms */ { NULL, NULL }, /* No */ { termp_ns_pre, NULL }, /* Ns */ { termp_xx_pre, NULL }, /* Nx */ @@ -842,6 +842,8 @@ termp_it_pre(DECL_ARGS) if (MDOC_BODY == n->prev->type) p->flags |= TERMP_NOLPAD; + p->flags |= TERMP_IGNDELIM; + break; case (LIST_diag): if (MDOC_HEAD == n->type) @@ -1000,6 +1002,13 @@ termp_it_post(DECL_ARGS) p->flags &= ~TERMP_TWOSPACE; p->flags &= ~TERMP_NOLPAD; p->flags &= ~TERMP_HANG; + + /* + * TERMP_IGNDELIM is also set by `Pf', but it is safe + * to clear it here because `Pf' cannot contain `It'. + */ + + p->flags &= ~TERMP_IGNDELIM; } @@ -1026,7 +1035,8 @@ termp_nm_pre(DECL_ARGS) if (NULL == n->child && NULL == m->name) return(0); - synopsis_pre(p, n); + if (MDOC_HEAD == n->type) + synopsis_pre(p, n->parent); if (MDOC_HEAD == n->type && n->next->child) { p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_HANG; @@ -1620,8 +1630,7 @@ termp_fa_pre(DECL_ARGS) static int termp_bd_pre(DECL_ARGS) { - size_t tabwidth; - size_t rm, rmax; + size_t tabwidth, rm, rmax; const struct mdoc_node *nn; if (MDOC_BLOCK == n->type) { @@ -1653,12 +1662,11 @@ termp_bd_pre(DECL_ARGS) p->rmargin = p->maxrmargin = TERM_MAXMARGIN; for (nn = n->child; nn; nn = nn->next) { - p->flags |= TERMP_NOSPACE; print_mdoc_node(p, pair, m, nn); - if (NULL == nn->prev || - nn->prev->line < nn->line || - NULL == nn->next) - term_flushln(p); + if (nn->next && nn->next->line == nn->line) + continue; + term_flushln(p); + p->flags |= TERMP_NOSPACE; } p->tabwidth = tabwidth; @@ -1805,6 +1813,10 @@ static void termp_pf_post(DECL_ARGS) { + /* + * XXX Resetting TERMP_IGNDELIM here is not safe + * because `Pf' can be used inside `Bl -column'. + */ p->flags &= ~TERMP_IGNDELIM; p->flags |= TERMP_NOSPACE; } @@ -1905,6 +1917,11 @@ termp_sp_pre(DECL_ARGS) len = 0; break; default: + assert(n->parent); + if ((NULL == n->next || NULL == n->prev) && + (MDOC_Ss == n->parent->tok || + MDOC_Sh == n->parent->tok)) + return(0); len = 1; break; } @@ -2066,9 +2083,11 @@ termp_sm_pre(DECL_ARGS) { assert(n->child && MDOC_TEXT == n->child->type); - if (0 == strcmp("on", n->child->string)) + if (0 == strcmp("on", n->child->string)) { + if (p->col) + p->flags &= ~TERMP_NOSPACE; p->flags &= ~TERMP_NONOSPACE; - else + } else p->flags |= TERMP_NONOSPACE; return(0); @@ -2113,23 +2132,25 @@ termp_li_pre(DECL_ARGS) static int termp_lk_pre(DECL_ARGS) { - const struct mdoc_node *nn; + const struct mdoc_node *nn, *sv; term_fontpush(p, TERMFONT_UNDER); - nn = n->child; + nn = sv = n->child; + if (NULL == nn->next) return(1); - term_word(p, nn->string); + for (nn = nn->next; nn; nn = nn->next) + term_word(p, nn->string); + term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, ":"); term_fontpush(p, TERMFONT_BOLD); - for (nn = nn->next; nn; nn = nn->next) - term_word(p, nn->string); + term_word(p, sv->string); term_fontpop(p); return(0);