=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/tbl_term.c,v retrieving revision 1.42 retrieving revision 1.43 diff -c -r1.42 -r1.43 *** src/usr.bin/mandoc/tbl_term.c 2017/06/17 14:55:02 1.42 --- src/usr.bin/mandoc/tbl_term.c 2017/06/27 18:23:29 1.43 *************** *** 1,4 **** ! /* $OpenBSD: tbl_term.c,v 1.42 2017/06/17 14:55:02 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: tbl_term.c,v 1.43 2017/06/27 18:23:29 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze *************** *** 99,105 **** for (ic = 0; ic < sp->opts->cols; ic++) { coloff += tp->tbl.cols[ic].width; term_tab_iset(coloff); ! coloff += 3; } /* Center the table as a whole. */ --- 99,105 ---- for (ic = 0; ic < sp->opts->cols; ic++) { coloff += tp->tbl.cols[ic].width; term_tab_iset(coloff); ! coloff += tp->tbl.cols[ic].spacing; } /* Center the table as a whole. */ *************** *** 108,116 **** if (sp->opts->opts & TBL_OPT_CENTRE) { tsz = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) ? 2 : !!sp->opts->lvert + !!sp->opts->rvert; ! for (ic = 0; ic < sp->opts->cols; ic++) ! tsz += tp->tbl.cols[ic].width + 3; ! tsz -= 3; if (offset + tsz > tp->tcol->rmargin) tsz -= 1; tp->tcol->offset = offset + tp->tcol->rmargin > tsz ? --- 108,118 ---- if (sp->opts->opts & TBL_OPT_CENTRE) { tsz = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) ? 2 : !!sp->opts->lvert + !!sp->opts->rvert; ! for (ic = 0; ic + 1 < sp->opts->cols; ic++) ! tsz += tp->tbl.cols[ic].width + ! tp->tbl.cols[ic].spacing; ! if (sp->opts->cols) ! tsz += tp->tbl.cols[sp->opts->cols - 1].width; if (offset + tsz > tp->tcol->rmargin) tsz -= 1; tp->tcol->offset = offset + tp->tcol->rmargin > tsz ? *************** *** 157,165 **** } coloff += tp->tbl.cols[ic].width; tp->tcol->rmargin = coloff; - coloff++; if (ic + 1 < sp->opts->cols) ! coloff += 2; if (spans) { spans--; continue; --- 159,166 ---- } coloff += tp->tbl.cols[ic].width; tp->tcol->rmargin = coloff; if (ic + 1 < sp->opts->cols) ! coloff += tp->tbl.cols[ic].spacing; if (spans) { spans--; continue; *************** *** 173,179 **** /* Set up a column for a right vertical frame. */ tp->tcol++; ! tp->tcol->offset = coloff; tp->tcol->rmargin = tp->maxrmargin; /* Spans may have reduced the number of columns. */ --- 174,180 ---- /* Set up a column for a right vertical frame. */ tp->tcol++; ! tp->tcol->offset = coloff + 1; tp->tcol->rmargin = tp->maxrmargin; /* Spans may have reduced the number of columns. */ *************** *** 325,337 **** tp->tcol + 1 == tp->tcols + tp->lasttcol)) continue; ! if (tp->tcol->rmargin > tp->viscol) { (*tp->advance)(tp, tp->tcol->rmargin - tp->viscol); tp->viscol = tp->tcol->rmargin; } ! ! if (tp->tcol->rmargin + 1 > tp->viscol) { (*tp->letter)(tp, fc); tp->viscol++; } --- 326,338 ---- tp->tcol + 1 == tp->tcols + tp->lasttcol)) continue; ! if (tp->viscol < tp->tcol->rmargin) { (*tp->advance)(tp, tp->tcol->rmargin - tp->viscol); tp->viscol = tp->tcol->rmargin; } ! while (tp->viscol < tp->tcol->rmargin + ! tp->tbl.cols[ic].spacing / 2) { (*tp->letter)(tp, fc); tp->viscol++; } *************** *** 351,361 **** break; } } - (*tp->letter)(tp, - fc == ' ' ? '|' : vert ? '+' : fc); - tp->viscol++; - if (fc != ' ') { if (cp != NULL && cp->pos == TBL_CELL_HORIZ) --- 352,363 ---- break; } } + if (tp->tbl.cols[ic].spacing) { + (*tp->letter)(tp, fc == ' ' ? '|' : + vert ? '+' : fc); + tp->viscol++; + } if (fc != ' ') { if (cp != NULL && cp->pos == TBL_CELL_HORIZ) *************** *** 366,372 **** else fc = ' '; } ! if (vert > 1 || fc != ' ') { (*tp->letter)(tp, fc == ' ' ? '|' : vert > 1 ? '+' : fc); tp->viscol++; --- 368,375 ---- else fc = ' '; } ! if (tp->tbl.cols[ic].spacing > 2 && ! (vert > 1 || fc != ' ')) { (*tp->letter)(tp, fc == ' ' ? '|' : vert > 1 ? '+' : fc); tp->viscol++; *************** *** 446,451 **** --- 449,455 ---- tbl_hrule(struct termp *tp, const struct tbl_span *sp, int kind) { const struct tbl_cell *cp, *cpn, *cpp; + const struct roffcol *col; int vert; char line, cross; *************** *** 462,468 **** if (cpn == cp) cpn = NULL; for (;;) { ! tbl_char(tp, line, tp->tbl.cols[cp->col].width + 1); vert = cp->vert; if ((cp = cp->next) == NULL) break; --- 466,473 ---- if (cpn == cp) cpn = NULL; for (;;) { ! col = tp->tbl.cols + cp->col; ! tbl_char(tp, line, col->width + col->spacing / 2); vert = cp->vert; if ((cp = cp->next) == NULL) break; *************** *** 478,487 **** } if (sp->opts->opts & TBL_OPT_ALLBOX && !vert) vert = 1; ! if (vert) ! tbl_char(tp, cross, vert); ! if (vert < 2) ! tbl_char(tp, line, 2 - vert); } if (kind) { term_word(tp, "+"); --- 483,494 ---- } if (sp->opts->opts & TBL_OPT_ALLBOX && !vert) vert = 1; ! if (col->spacing) ! tbl_char(tp, vert ? cross : line, 1); ! if (col->spacing > 2) ! tbl_char(tp, vert > 1 ? cross : line, 1); ! if (col->spacing > 4) ! tbl_char(tp, line, (col->spacing - 3) / 2); } if (kind) { term_word(tp, "+");