summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-08 16:53:41 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-08 16:53:41 +0000
commitf30d5236cd55d73b7268b3afb870812161b3932d (patch)
tree890388770550c67b4890de40852e7892d2d86b49 /usr.bin/mandoc
parentfcf43a28c454e00ca56fe86383cc33cbb0dc01c8 (diff)
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 <simonmbranch at gmail dot com>.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/tbl_term.c9
1 files changed, 6 insertions, 3 deletions
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 <kristaps@bsd.lv>
* Copyright (c) 2011-2021 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;