source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: When all cells in a tbl(1) column are empty, set the column
@ 2019-12-31 22:58 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-12-31 22:58 UTC (permalink / raw)
  To: source

Log Message:
-----------
When all cells in a tbl(1) column are empty, set the column width
to 1n rather than to 0n, in the same way as groff does.
This fixes misformatting reported by bentley@ in xkeyboard-config(7).

Modified Files:
--------------
    mandoc:
        out.c
    mandoc/regress/tbl/layout:
        Makefile

Added Files:
-----------
    mandoc/regress/tbl/layout:
        emptycol.in
        emptycol.out_ascii

Revision Data
-------------
Index: out.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/out.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -Lout.c -Lout.c -u -p -r1.78 -r1.79
--- out.c
+++ out.c
@@ -209,13 +209,25 @@ tblcalc(struct rofftbl *tbl, const struc
 	}
 
 	/*
-	 * 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,
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/tbl/layout/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lregress/tbl/layout/Makefile -Lregress/tbl/layout/Makefile -u -p -r1.3 -r1.4
--- regress/tbl/layout/Makefile
+++ 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
 
--- /dev/null
+++ 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
--- /dev/null
+++ regress/tbl/layout/emptycol.out_ascii
@@ -0,0 +1,46 @@
+TBL-LAYOUT-EMPTYCOL(1)      General Commands Manual     TBL-LAYOUT-EMPTYCOL(1)
+
+
+
+N\bNA\bAM\bME\bE
+       tbl-layout-emptycol - empty columns in tables
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+       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)
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-31 22:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-31 22:58 mandoc: When all cells in a tbl(1) column are empty, set the column schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).