aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-04-08 16:53:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-04-08 16:53:45 +0000
commitef4cc03dbb7deeb4329a74e97c09433301435a54 (patch)
treebedbe5a71286d421ff550c416fdee18a8c9b6477
parentd4f0d5572c05de1a742d57235e79823be75f1475 (diff)
downloadmandoc-ef4cc03dbb7deeb4329a74e97c09433301435a54.tar.gz
mandoc-ef4cc03dbb7deeb4329a74e97c09433301435a54.tar.zst
mandoc-ef4cc03dbb7deeb4329a74e97c09433301435a54.zip
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>.
-rw-r--r--tbl_term.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tbl_term.c b/tbl_term.c
index eac12558..d83a97b8 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_term.c,v 1.75 2021/08/10 12:55:04 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.76 2022/04/08 16:53:45 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2021 Ingo Schwarze <schwarze@openbsd.org>
@@ -820,8 +820,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;