=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.191 retrieving revision 1.199 diff -u -p -r1.191 -r1.199 --- mandoc/mdoc_term.c 2010/09/27 23:03:44 1.191 +++ mandoc/mdoc_term.c 2010/12/16 17:14:48 1.199 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.191 2010/09/27 23:03:44 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.199 2010/12/16 17:14:48 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -102,6 +102,7 @@ static int termp_fl_pre(DECL_ARGS); static int termp_fn_pre(DECL_ARGS); static int termp_fo_pre(DECL_ARGS); static int termp_ft_pre(DECL_ARGS); +static int termp_igndelim_pre(DECL_ARGS); static int termp_in_pre(DECL_ARGS); static int termp_it_pre(DECL_ARGS); static int termp_li_pre(DECL_ARGS); @@ -109,7 +110,6 @@ static int termp_lk_pre(DECL_ARGS); static int termp_nd_pre(DECL_ARGS); static int termp_nm_pre(DECL_ARGS); static int termp_ns_pre(DECL_ARGS); -static int termp_pf_pre(DECL_ARGS); static int termp_quote_pre(DECL_ARGS); static int termp_rs_pre(DECL_ARGS); static int termp_rv_pre(DECL_ARGS); @@ -196,12 +196,12 @@ static const struct termact termacts[MDOC_MAX] = { { NULL, NULL }, /* Eo */ { termp_xx_pre, NULL }, /* Fx */ { termp_bold_pre, NULL }, /* Ms */ - { NULL, NULL }, /* No */ + { termp_igndelim_pre, NULL }, /* No */ { termp_ns_pre, NULL }, /* Ns */ { termp_xx_pre, NULL }, /* Nx */ { termp_xx_pre, NULL }, /* Ox */ { NULL, NULL }, /* Pc */ - { termp_pf_pre, termp_pf_post }, /* Pf */ + { termp_igndelim_pre, termp_pf_post }, /* Pf */ { termp_quote_pre, termp_quote_post }, /* Po */ { termp_quote_pre, termp_quote_post }, /* Pq */ { NULL, NULL }, /* Qc */ @@ -319,9 +319,12 @@ print_mdoc_node(DECL_ARGS) /* * Keeps only work until the end of a line. If a keep was * invoked in a prior line, revert it to PREKEEP. + * + * Also let SYNPRETTY sections behave as if they were wrapped + * in a `Bk' block. */ - if (TERMP_KEEP & p->flags) { + if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) { if (n->prev && n->prev->line != n->line) { p->flags &= ~TERMP_KEEP; p->flags |= TERMP_PREKEEP; @@ -333,6 +336,16 @@ print_mdoc_node(DECL_ARGS) } } + /* + * Since SYNPRETTY sections aren't "turned off" with `Ek', + * we have to intuit whether we should disable formatting. + */ + + if ( ! (MDOC_SYNPRETTY & n->flags) && + ((n->prev && MDOC_SYNPRETTY & n->prev->flags) || + (n->parent && MDOC_SYNPRETTY & n->parent->flags))) + p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); + if (chld && n->child) print_mdoc_nodelist(p, &npair, m, n->child); @@ -1103,10 +1116,10 @@ termp_an_post(DECL_ARGS) return; } - if (AUTH_split == n->data.An.auth) { + if (AUTH_split == n->data.An->auth) { p->flags &= ~TERMP_NOSPLIT; p->flags |= TERMP_SPLIT; - } else if (AUTH_nosplit == n->data.An.auth) { + } else if (AUTH_nosplit == n->data.An->auth) { p->flags &= ~TERMP_SPLIT; p->flags |= TERMP_NOSPLIT; } @@ -1584,12 +1597,18 @@ termp_bd_pre(DECL_ARGS) * anyway, so don't sweat it. */ switch (nn->tok) { + case (MDOC_Sm): + /* FALLTHROUGH */ case (MDOC_br): /* FALLTHROUGH */ case (MDOC_sp): /* FALLTHROUGH */ case (MDOC_Bl): /* FALLTHROUGH */ + case (MDOC_D1): + /* FALLTHROUGH */ + case (MDOC_Dl): + /* FALLTHROUGH */ case (MDOC_Lp): /* FALLTHROUGH */ case (MDOC_Pp): @@ -1655,7 +1674,7 @@ termp_xx_pre(DECL_ARGS) pp = NULL; switch (n->tok) { case (MDOC_Bsx): - pp = "BSDI BSD/OS"; + pp = "BSD/OS"; break; case (MDOC_Dx): pp = "DragonFly"; @@ -1684,7 +1703,7 @@ termp_xx_pre(DECL_ARGS) /* ARGSUSED */ static int -termp_pf_pre(DECL_ARGS) +termp_igndelim_pre(DECL_ARGS) { p->flags |= TERMP_IGNDELIM; @@ -1697,7 +1716,6 @@ static void termp_pf_post(DECL_ARGS) { - p->flags &= ~TERMP_IGNDELIM; p->flags |= TERMP_NOSPACE; } @@ -1797,11 +1815,6 @@ 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; } @@ -2075,7 +2088,7 @@ termp_lk_pre(DECL_ARGS) nn = sv = n->child; - if (NULL == nn->next) + if (NULL == nn || NULL == nn->next) return(1); for (nn = nn->next; nn; nn = nn->next)