=================================================================== RCS file: /cvs/mandoc/man_term.c,v retrieving revision 1.138 retrieving revision 1.143 diff -u -p -r1.138 -r1.143 --- mandoc/man_term.c 2013/11/11 00:37:55 1.138 +++ mandoc/man_term.c 2014/03/30 19:47:48 1.143 @@ -1,7 +1,7 @@ -/* $Id: man_term.c,v 1.138 2013/11/11 00:37:55 schwarze Exp $ */ +/* $Id: man_term.c,v 1.143 2014/03/30 19:47:48 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010-2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -84,6 +84,7 @@ static int pre_ft(DECL_ARGS); static int pre_ign(DECL_ARGS); static int pre_in(DECL_ARGS); static int pre_literal(DECL_ARGS); +static int pre_ll(DECL_ARGS); static int pre_sp(DECL_ARGS); static void post_IP(DECL_ARGS); @@ -133,6 +134,7 @@ static const struct termact termacts[MAN_MAX] = { { pre_literal, NULL, 0 }, /* EE */ { pre_UR, post_UR, 0 }, /* UR */ { NULL, NULL, 0 }, /* UE */ + { pre_ll, NULL, MAN_NOTEXT }, /* ll */ }; @@ -237,6 +239,16 @@ pre_ign(DECL_ARGS) /* ARGSUSED */ static int +pre_ll(DECL_ARGS) +{ + + (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + return(0); +} + + +/* ARGSUSED */ +static int pre_I(DECL_ARGS) { @@ -265,7 +277,8 @@ pre_literal(DECL_ARGS) if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) { p->offset = p->rmargin; p->rmargin = p->maxrmargin; - p->flags &= ~(TERMP_NOBREAK | TERMP_TWOSPACE); + p->trailspace = 0; + p->flags &= ~TERMP_NOBREAK; p->flags |= TERMP_NOSPACE; } @@ -535,7 +548,7 @@ pre_HP(DECL_ARGS) if ( ! (MANT_LITERAL & mt->fl)) { p->flags |= TERMP_NOBREAK; - p->flags |= TERMP_TWOSPACE; + p->trailspace = 2; } len = mt->lmargin[mt->lmargincur]; @@ -570,7 +583,7 @@ post_HP(DECL_ARGS) case (MAN_BODY): term_newln(p); p->flags &= ~TERMP_NOBREAK; - p->flags &= ~TERMP_TWOSPACE; + p->trailspace = 0; p->offset = mt->offset; p->rmargin = p->maxrmargin; break; @@ -613,6 +626,7 @@ pre_IP(DECL_ARGS) break; case (MAN_HEAD): p->flags |= TERMP_NOBREAK; + p->trailspace = 1; break; case (MAN_BLOCK): print_bvspace(p, n, mt->pardist); @@ -656,7 +670,8 @@ pre_IP(DECL_ARGS) return(0); case (MAN_BODY): p->offset = mt->offset + len; - p->rmargin = p->maxrmargin; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; break; default: break; @@ -675,6 +690,7 @@ post_IP(DECL_ARGS) case (MAN_HEAD): term_flushln(p); p->flags &= ~TERMP_NOBREAK; + p->trailspace = 0; p->rmargin = p->maxrmargin; break; case (MAN_BODY): @@ -698,6 +714,7 @@ pre_TP(DECL_ARGS) switch (n->type) { case (MAN_HEAD): p->flags |= TERMP_NOBREAK; + p->trailspace = 1; break; case (MAN_BODY): p->flags |= TERMP_NOSPACE; @@ -715,7 +732,7 @@ pre_TP(DECL_ARGS) /* Calculate offset. */ if (NULL != (nn = n->parent->head->child)) - if (nn->string && nn->parent->line == nn->line) + if (nn->string && 0 == (MAN_LINE & nn->flags)) if ((ival = a2width(p, nn->string)) >= 0) len = (size_t)ival; @@ -732,10 +749,15 @@ pre_TP(DECL_ARGS) mt->fl &= ~MANT_LITERAL; /* Don't print same-line elements. */ - for (nn = n->child; nn; nn = nn->next) - if (nn->line > n->line) - print_man_node(p, mt, nn, meta); + nn = n->child; + while (NULL != nn && 0 == (MAN_LINE & nn->flags)) + nn = nn->next; + while (NULL != nn) { + print_man_node(p, mt, nn, meta); + nn = nn->next; + } + if (savelit) mt->fl |= MANT_LITERAL; if (ival >= 0) @@ -744,9 +766,10 @@ pre_TP(DECL_ARGS) return(0); case (MAN_BODY): p->offset = mt->offset + len; - p->rmargin = p->maxrmargin; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; + p->trailspace = 0; p->flags &= ~TERMP_NOBREAK; - p->flags &= ~TERMP_TWOSPACE; break; default: break; @@ -905,8 +928,9 @@ pre_RS(DECL_ARGS) sz = (size_t)ival; mt->offset += sz; - p->rmargin = p->maxrmargin; - p->offset = mt->offset < p->rmargin ? mt->offset : p->rmargin; + p->offset = mt->offset; + p->rmargin = p->maxrmargin > p->offset ? + p->maxrmargin : p->offset; if (++mt->lmarginsz < MAXMARGINS) mt->lmargincur = mt->lmarginsz; @@ -1033,7 +1057,7 @@ out: * more specific than this. */ if (MANT_LITERAL & mt->fl && ! (TERMP_NOBREAK & p->flags) && - (NULL == n->next || n->next->line > n->line)) { + (NULL == n->next || MAN_LINE & n->next->flags)) { rm = p->rmargin; rmax = p->maxrmargin; p->rmargin = p->maxrmargin = TERM_MAXMARGIN; @@ -1101,6 +1125,7 @@ print_man_foot(struct termp *p, const void *arg) /* Bottom left corner: manual source. */ p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; + p->trailspace = 1; p->offset = 0; p->rmargin = (p->maxrmargin - datelen + term_len(p, 1)) / 2; @@ -1123,6 +1148,7 @@ print_man_foot(struct termp *p, const void *arg) p->flags &= ~TERMP_NOBREAK; p->flags |= TERMP_NOSPACE; + p->trailspace = 0; p->offset = p->rmargin; p->rmargin = p->maxrmargin; @@ -1154,6 +1180,7 @@ print_man_head(struct termp *p, const void *arg) titlen = term_strlen(p, title); p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; + p->trailspace = 1; p->offset = 0; p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ? (p->maxrmargin - @@ -1176,6 +1203,7 @@ print_man_head(struct termp *p, const void *arg) /* Top right corner: title and section, again. */ p->flags &= ~TERMP_NOBREAK; + p->trailspace = 0; if (p->rmargin + titlen <= p->maxrmargin) { p->flags |= TERMP_NOSPACE; p->offset = p->rmargin;