From: schwarze Date: Fri, 8 Apr 2022 16:53:40 +0000 (+0000) Subject: When calculating the with of spanned columns, which for example matters X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6497b0ad1c461edf3242587d675429d78faba41e;p=openbsd When calculating the with of spanned columns, which for example matters for centering text spanning multiple tbl(7) columns, correctly account for the spacing between columns instead of wrongly assuming the default spacing of 3n. Patch from Simon Branch . --- diff --git a/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c index 33504262e45..c054fde2e42 100644 --- a/usr.bin/mandoc/tbl_term.c +++ b/usr.bin/mandoc/tbl_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_term.c,v 1.63 2021/08/10 12:36:42 schwarze Exp $ */ +/* $OpenBSD: tbl_term.c,v 1.64 2022/04/08 16:53:40 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons * Copyright (c) 2011-2021 Ingo Schwarze @@ -818,8 +818,11 @@ tbl_literal(struct termp *tp, const struct tbl_dat *dp, width = col->width; ic = dp->layout->col; hspans = dp->hspans; - while (hspans--) - width += tp->tbl.cols[++ic].width + 3; + while (hspans--) { + width += tp->tbl.cols[ic].spacing; + ic++; + width += tp->tbl.cols[ic].width; + } padr = width > len ? width - len : 0; padl = 0;