=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.257 retrieving revision 1.263 diff -u -p -r1.257 -r1.263 --- mandoc/mdoc_term.c 2013/12/25 15:12:45 1.257 +++ mandoc/mdoc_term.c 2014/04/08 07:13:12 1.263 @@ -1,7 +1,7 @@ -/* $Id: mdoc_term.c,v 1.257 2013/12/25 15:12:45 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.263 2014/04/08 07:13:12 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze * Copyright (c) 2013 Franco Fichtner * * Permission to use, copy, modify, and distribute this software for any @@ -104,6 +104,7 @@ static int termp_ft_pre(DECL_ARGS); static int termp_in_pre(DECL_ARGS); static int termp_it_pre(DECL_ARGS); static int termp_li_pre(DECL_ARGS); +static int termp_ll_pre(DECL_ARGS); static int termp_lk_pre(DECL_ARGS); static int termp_nd_pre(DECL_ARGS); static int termp_nm_pre(DECL_ARGS); @@ -244,6 +245,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_sp_pre, NULL }, /* sp */ { NULL, termp____post }, /* %U */ { NULL, NULL }, /* Ta */ + { termp_ll_pre, NULL }, /* ll */ }; @@ -384,8 +386,10 @@ print_mdoc_node(DECL_ARGS) if (MDOC_EOS & n->flags) p->flags |= TERMP_SENTENCE; - p->offset = offset; - p->rmargin = rmargin; + if (MDOC_ll != n->tok) { + p->offset = offset; + p->rmargin = rmargin; + } } @@ -615,6 +619,16 @@ print_bvspace(struct termp *p, /* ARGSUSED */ static int +termp_ll_pre(DECL_ARGS) +{ + + term_setwidth(p, n->nchild ? n->child->string : NULL); + return(0); +} + + +/* ARGSUSED */ +static int termp_it_pre(DECL_ARGS) { const struct mdoc_node *bl, *nn; @@ -805,14 +819,14 @@ termp_it_pre(DECL_ARGS) MDOC_Bd == n->next->child->tok)) break; - p->flags |= TERMP_NOBREAK | TERMP_HANG; + p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; p->trailspace = 1; break; case (LIST_tag): if (MDOC_HEAD != n->type) break; - p->flags |= TERMP_NOBREAK; + p->flags |= TERMP_NOBREAK | TERMP_BRIND; p->trailspace = 2; if (NULL == n->next || NULL == n->next->child) @@ -834,7 +848,7 @@ termp_it_pre(DECL_ARGS) case (LIST_diag): if (MDOC_HEAD != n->type) break; - p->flags |= TERMP_NOBREAK; + p->flags |= TERMP_NOBREAK | TERMP_BRIND; p->trailspace = 1; break; default: @@ -873,8 +887,11 @@ termp_it_pre(DECL_ARGS) assert(width); if (MDOC_HEAD == n->type) p->rmargin = p->offset + width; - else + else { p->offset += width; + if (p->rmargin < p->offset) + p->rmargin = p->offset; + } break; case (LIST_column): assert(width); @@ -985,9 +1002,8 @@ termp_it_post(DECL_ARGS) * has munged them in the meanwhile. */ - p->flags &= ~TERMP_DANGLE; - p->flags &= ~TERMP_NOBREAK; - p->flags &= ~TERMP_HANG; + p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | + TERMP_DANGLE | TERMP_HANG); p->trailspace = 0; } @@ -1012,6 +1028,8 @@ termp_nm_pre(DECL_ARGS) MDOC_TEXT == n->prev->child->type ? term_strlen(p, n->prev->child->string) : term_len(p, 5)); + if (p->rmargin < p->offset) + p->rmargin = p->offset; return(1); } @@ -1022,7 +1040,7 @@ termp_nm_pre(DECL_ARGS) synopsis_pre(p, n->parent); if (MDOC_HEAD == n->type && n->next->child) { - p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; + p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND; p->trailspace = 1; p->rmargin = p->offset + term_len(p, 1); if (NULL == n->child) { @@ -1053,7 +1071,7 @@ termp_nm_post(DECL_ARGS) p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); } else if (MDOC_HEAD == n->type && n->next->child) { term_flushln(p); - p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); + p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); p->trailspace = 0; } else if (MDOC_BODY == n->type && n->child) term_flushln(p); @@ -1542,7 +1560,7 @@ termp_fn_pre(DECL_ARGS) if (pretty) { rmargin = p->rmargin; p->rmargin = p->offset + term_len(p, 4); - p->flags |= TERMP_NOBREAK | TERMP_HANG; + p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; } assert(MDOC_TEXT == n->type); @@ -1552,7 +1570,7 @@ termp_fn_pre(DECL_ARGS) if (pretty) { term_flushln(p); - p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); + p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); p->offset = p->rmargin; p->rmargin = rmargin; } @@ -1601,8 +1619,7 @@ termp_fa_pre(DECL_ARGS) for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_UNDER); - if (MDOC_SYNPRETTY & n->flags) - p->flags |= TERMP_NBRWORD; + p->flags |= TERMP_NBRWORD; term_word(p, nn->string); term_fontpop(p); @@ -2045,14 +2062,16 @@ termp_fo_pre(DECL_ARGS) if (pretty) { rmargin = p->rmargin; p->rmargin = p->offset + term_len(p, 4); - p->flags |= TERMP_NOBREAK | TERMP_HANG; + p->flags |= TERMP_NOBREAK | TERMP_BRIND | + TERMP_HANG; } p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; if (pretty) { term_flushln(p); - p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); + p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | + TERMP_HANG); p->offset = p->rmargin; p->rmargin = rmargin; }