aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--out.c24
-rw-r--r--regress/tbl/layout/Makefile4
-rw-r--r--regress/tbl/layout/emptycol.in49
-rw-r--r--regress/tbl/layout/emptycol.out_ascii46
4 files changed, 115 insertions, 8 deletions
diff --git a/out.c b/out.c
index d0b0d0a2..4529d5b1 100644
--- a/out.c
+++ b/out.c
@@ -1,4 +1,4 @@
-/* $Id: out.c,v 1.78 2019/03/29 21:27:06 schwarze Exp $ */
+/* $Id: out.c,v 1.79 2019/12/31 22:58:41 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -209,13 +209,25 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp_first,
}
/*
- * Column spacings are needed for span width calculations,
- * so set the default values now.
+ * The minimum width of columns explicitly specified
+ * in the layout is 1n.
*/
- for (icol = 0; icol <= maxcol; icol++)
- if (tbl->cols[icol].spacing == SIZE_MAX || icol == maxcol)
- tbl->cols[icol].spacing = 3;
+ if (maxcol < sp_first->opts->cols - 1)
+ maxcol = sp_first->opts->cols - 1;
+ for (icol = 0; icol <= maxcol; icol++) {
+ col = tbl->cols + icol;
+ if (col->width < 1)
+ col->width = 1;
+
+ /*
+ * Column spacings are needed for span width
+ * calculations, so set the default values now.
+ */
+
+ if (col->spacing == SIZE_MAX || icol == maxcol)
+ col->spacing = 3;
+ }
/*
* Replace the minimum widths with the missing widths,
diff --git a/regress/tbl/layout/Makefile b/regress/tbl/layout/Makefile
index a56cbc2f..1009d96e 100644
--- a/regress/tbl/layout/Makefile
+++ b/regress/tbl/layout/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.4 2019/06/11 15:40:41 schwarze Exp $
+# $OpenBSD: Makefile,v 1.5 2019/12/31 22:49:17 schwarze Exp $
-REGRESS_TARGETS = center complex empty emptyline
+REGRESS_TARGETS = center complex empty emptycol emptyline
REGRESS_TARGETS += lines lines-nogroff numbers shortlines span
LINT_TARGETS = complex empty
diff --git a/regress/tbl/layout/emptycol.in b/regress/tbl/layout/emptycol.in
new file mode 100644
index 00000000..090d9004
--- /dev/null
+++ b/regress/tbl/layout/emptycol.in
@@ -0,0 +1,49 @@
+.\" $OpenBSD: emptycol.in,v 1.1 2019/12/31 22:49:17 schwarze Exp $
+.TH TBL-LAYOUT-EMPTYCOL 1 "December 31, 2019"
+.SH NAME
+tbl-layout-emptycol \- empty columns in tables
+.SH DESCRIPTION
+missing final column:
+.TS
+allbox tab(:);
+L L L
+L L.
+1:2
+a:b
+.TE
+.sp
+empty final column:
+.TS
+allbox tab(:);
+L L L
+L L.
+1:2:
+a:b
+.TE
+.sp
+final column with zero-width content:
+.TS
+allbox tab(:);
+L L L
+L L.
+1:2:\&
+a:b
+.TE
+.sp
+empty middle column:
+.TS
+allbox tab(:);
+L L L
+L.
+1::3
+a
+.TE
+.sp
+span crossing empty middle column:
+.TS
+allbox tab(:);
+L L L
+L S S.
+1::3
+span
+.TE
diff --git a/regress/tbl/layout/emptycol.out_ascii b/regress/tbl/layout/emptycol.out_ascii
new file mode 100644
index 00000000..b1372b7b
--- /dev/null
+++ b/regress/tbl/layout/emptycol.out_ascii
@@ -0,0 +1,46 @@
+TBL-LAYOUT-EMPTYCOL(1) General Commands Manual TBL-LAYOUT-EMPTYCOL(1)
+
+
+
+NNAAMMEE
+ tbl-layout-emptycol - empty columns in tables
+
+DDEESSCCRRIIPPTTIIOONN
+ missing final column:
+
+ +--+---+---+
+ |1 | 2 | |
+ +--+---+---+
+ |a | b | |
+ +--+---+---+
+ empty final column:
+
+ +--+---+---+
+ |1 | 2 | |
+ +--+---+---+
+ |a | b | |
+ +--+---+---+
+ final column with zero-width content:
+
+ +--+---+---+
+ |1 | 2 | |
+ +--+---+---+
+ |a | b | |
+ +--+---+---+
+ empty middle column:
+
+ +--+---+---+
+ |1 | | 3 |
+ +--+---+---+
+ |a | | |
+ +--+---+---+
+ span crossing empty middle column:
+
+ +--+---+---+
+ |1 | | 3 |
+ +--+---+---+
+ |span |
+ +----------+
+
+
+OpenBSD December 31, 2019 TBL-LAYOUT-EMPTYCOL(1)