=================================================================== RCS file: /cvs/mandoc/tbl_term.c,v retrieving revision 1.47 retrieving revision 1.52 diff -u -p -r1.47 -r1.52 --- mandoc/tbl_term.c 2017/06/12 19:05:47 1.47 +++ mandoc/tbl_term.c 2017/06/14 17:51:15 1.52 @@ -1,4 +1,4 @@ -/* $Id: tbl_term.c,v 1.47 2017/06/12 19:05:47 schwarze Exp $ */ +/* $Id: tbl_term.c,v 1.52 2017/06/14 17:51:15 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze @@ -47,7 +47,7 @@ static void tbl_word(struct termp *, const struct tbl_ static size_t term_tbl_sulen(const struct roffsu *su, void *arg) { - return term_hspan((const struct termp *)arg, su) / 24; + return term_hen((const struct termp *)arg, su); } static size_t @@ -87,7 +87,7 @@ term_tbl(struct termp *tp, const struct tbl_span *sp) tp->tbl.sulen = term_tbl_sulen; tp->tbl.arg = tp; - tblcalc(&tp->tbl, sp, tp->tcol->rmargin - tp->tcol->offset); + tblcalc(&tp->tbl, sp, tp->tcol->offset, tp->tcol->rmargin); /* Center the table as a whole. */ @@ -219,29 +219,47 @@ term_tbl(struct termp *tp, const struct tbl_span *sp) dp = sp->first; spans = 0; for (ic = 0; ic < sp->opts->cols; ic++) { - if (spans == 0) { - tp->tcol++; - if (dp != NULL) { - spans = dp->spans; - dp = dp->next; - } - if (tp->tcol->col < tp->tcol->lastcol) - term_flushln(tp); - if (tp->tcol->col < tp->tcol->lastcol) - more = 1; - if (tp->tcol + 1 == - tp->tcols + tp->lasttcol) - continue; - } else - spans--; - /* Vertical frames between data cells. */ + /* Advance to next layout cell. */ if (cp != NULL) { vert = cp->vert; cp = cp->next; } else vert = 0; + + /* Skip later cells in a span. */ + + if (spans) { + spans--; + continue; + } + + /* Advance to next data cell. */ + + if (dp != NULL) { + spans = dp->spans; + dp = dp->next; + } + + /* Print one line of text in the cell. */ + + tp->tcol++; + if (tp->tcol->col < tp->tcol->lastcol) + term_flushln(tp); + if (tp->tcol->col < tp->tcol->lastcol) + more = 1; + + /* + * Vertical frames between data cells, + * but not after the last column. + */ + + if (tp->tcol + 1 == tp->tcols + tp->lasttcol) + continue; + if (vert == 0 && + sp->opts->opts & TBL_OPT_ALLBOX) + vert = 1; if (vert == 0) continue; @@ -300,7 +318,11 @@ term_tbl(struct termp *tp, const struct tbl_span *sp) free(tp->tbl.cols); tp->tbl.cols = NULL; tp->tcol->offset = offset; - } + } else if (horiz == 0 && sp->opts->opts & TBL_OPT_ALLBOX && + (sp->next == NULL || sp->next->pos == TBL_SPAN_DATA || + sp->next->next != NULL)) + tbl_hrule(tp, sp, 1); + tp->flags &= ~TERMP_NONOSPACE; } @@ -336,6 +358,8 @@ tbl_hrule(struct termp *tp, const struct tbl_span *sp, vert = c2->vert; c2 = c2->next; } + if (sp->opts->opts & TBL_OPT_ALLBOX && !vert) + vert = 1; if (vert) tbl_char(tp, cross, vert); if (vert < 2)