From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout-kit-02.scc.kit.edu (scc-mailout-kit-02.scc.kit.edu [129.13.231.82]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id c9aaee77 for ; Tue, 31 Dec 2019 18:21:07 -0500 (EST) Received: from hekate.asta.kit.edu ([141.3.145.153] helo=hekate.usta.de) by scc-mailout-kit-02.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1imQoz-0004fZ-CX; Wed, 01 Jan 2020 00:21:06 +0100 Received: from donnerwolke.asta.kit.edu ([141.3.145.61] helo=donnerwolke.usta.de) by hekate.usta.de with esmtp (Exim 4.92.2) (envelope-from ) id 1imQoy-0007Dz-H0; Wed, 01 Jan 2020 00:21:04 +0100 Received: from athene.asta.kit.edu ([141.3.145.60] helo=athene.usta.de) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1imQoy-0008GO-BX; Wed, 01 Jan 2020 00:21:04 +0100 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id 116c7689; Wed, 1 Jan 2020 00:21:04 +0100 (CET) Date: Wed, 1 Jan 2020 00:21:04 +0100 From: Ingo Schwarze To: "Anthony J. Bentley" Cc: tech@mandoc.bsd.lv Subject: Re: Inconsistent table width Message-ID: <20191231232104.GI79009@athene.usta.de> References: <75672-1577734462.834261@FCbr.D2mH.5Uc3> X-Mailinglist: mandoc-tech Reply-To: tech@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <75672-1577734462.834261@FCbr.D2mH.5Uc3> User-Agent: Mutt/1.12.2 (2019-09-21) Hi Anthony, Anthony J. Bentley wrote on Mon, Dec 30, 2019 at 12:34:22PM -0700: > This table from xkeyboard-config(7) renders incorrectly. >=20 > .TS > left,box; > lB lB > ___ > lB l. > Model Description > pc101 Generic 101-key PC > .TE Yikes, what a mess. The "___" layout line forces the number of columns in the table to three because it contains three layout cell specifiers, even though all other lines in the layout and data sections only contain two cells. Having three columns is certainly not the author's intention. > groff: > +-------------------------------+ > |Model Description | > +-------------------------------+ > |pc101 Generic 101-key PC | > +-------------------------------+ You can actually see the last column in groff's output. Usually, there is one blank after the longest cell content in the rightmost column, i.e. between the "101-key PC" and the following "|". But here, the are five: 3 inter-column spacing 1 for column three 1 for spacing between the last column and the border You can also see the additional column if you change the "box" option to "allbox". > mandoc: > +-----------------------------+ > |Model Description | > +-----------------------------+ > |pc101 Generic 101-key PC | > +-----------------------------+ Mandoc mishandled columns consisting of nothing but zero-width cells. The following commit fixes the bug. Thank you for the report! Ingo 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 } =20 /* - * 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. */ =20 - for (icol =3D 0; icol <=3D maxcol; icol++) - if (tbl->cols[icol].spacing =3D=3D SIZE_MAX || icol =3D=3D maxcol) - tbl->cols[icol].spacing =3D 3; + if (maxcol < sp_first->opts->cols - 1) + maxcol =3D sp_first->opts->cols - 1; + for (icol =3D 0; icol <=3D maxcol; icol++) { + col =3D tbl->cols + icol; + if (col->width < 1) + col->width =3D 1; + + /* + * Column spacings are needed for span width + * calculations, so set the default values now. + */ + + if (col->spacing =3D=3D SIZE_MAX || icol =3D=3D maxcol) + col->spacing =3D 3; + } =20 /* * Replace the minimum widths with the missing widths, Index: Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 $ =20 -REGRESS_TARGETS =3D center complex empty emptyline +REGRESS_TARGETS =3D center complex empty emptycol emptyline REGRESS_TARGETS +=3D lines lines-nogroff numbers shortlines span LINT_TARGETS =3D complex empty =20 --- /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-EMPTYCO= L(1) + + + +N=08NA=08AM=08ME=08E + tbl-layout-emptycol - empty columns in tables + +D=08DE=08ES=08SC=08CR=08RI=08IP=08PT=08TI=08IO=08ON=08N + 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-EMPTYCO= L(1) -- To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv