From e6d4e95440b4b342ffaa5653a9501f07b62f1436 Mon Sep 17 00:00:00 2001 From: schwarze Date: Thu, 15 Jun 2017 00:27:22 +0000 Subject: [PATCH] round default width of tbl(7) text blocks in the same way as groff --- regress/usr.bin/mandoc/tbl/data/Makefile | 4 +- .../usr.bin/mandoc/tbl/data/block_width.in | 102 ++++++++++++++++++ .../mandoc/tbl/data/block_width.out_ascii | 63 +++++++++++ usr.bin/mandoc/out.c | 5 +- 4 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 regress/usr.bin/mandoc/tbl/data/block_width.in create mode 100644 regress/usr.bin/mandoc/tbl/data/block_width.out_ascii diff --git a/regress/usr.bin/mandoc/tbl/data/Makefile b/regress/usr.bin/mandoc/tbl/data/Makefile index ad2a28e915d..52f6d305083 100644 --- a/regress/usr.bin/mandoc/tbl/data/Makefile +++ b/regress/usr.bin/mandoc/tbl/data/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.2 2017/06/12 22:50:02 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2017/06/15 00:27:23 schwarze Exp $ -REGRESS_TARGETS = blankline block_unclosed block_wrap empty +REGRESS_TARGETS = blankline block_unclosed block_width block_wrap empty LINT_TARGETS = block_unclosed empty # groff-1.22.3 defect: diff --git a/regress/usr.bin/mandoc/tbl/data/block_width.in b/regress/usr.bin/mandoc/tbl/data/block_width.in new file mode 100644 index 00000000000..8c24a6f4151 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/data/block_width.in @@ -0,0 +1,102 @@ +.Dd June 15, 2017 +.Dt TBL-DATA-BLOCK_WIDTH 1 +.Os OpenBSD +.Sh NAME +.Nm tbl-data-block_width +.Nd default width of text blocks +.Sh DESCRIPTION +one column: +.TS +allbox tab(:); +l. +T{ +1234567890123456789012345678901234567 9 +T} +T{ +1234567890123456789012345678901234567 90 +T} +.TE +.sp +two columns: +.TS +allbox tab(:); +l l. +a:T{ +123456789012345678901234 6 +T} +a:T{ +123456789012345678901234 67 +T} +.TE +.sp +three columns: +.TS +allbox tab(:); +l l l. +a:b:T{ +12345678901234567 9 +T} +a:b:T{ +12345678901234567 90 +T} +.TE +.sp +four columns: +.TS +allbox tab(:); +l l l l. +a:b:c:T{ +12345678901234 6 +T} +a:b:c:T{ +12345678901234 67 +T} +.TE +.sp +five columns: +.TS +allbox tab(:); +l l l l l. +a:b:c:d:T{ +12345678901 3 +T} +a:b:c:d:T{ +12345678901 34 +T} +.TE +.sp +six columns: +.TS +allbox tab(:); +l l l l l l. +a:b:c:d:e:T{ +123456789 1 +T} +a:b:c:d:e:T{ +123456789 12 +T} +.TE +.sp +seven columns: +.TS +allbox tab(:); +l l l l l l l. +a:b:c:d:e:f:T{ +12345678 0 +T} +a:b:c:d:e:f:T{ +12345678 01 +T} +.TE +.sp +eight columns: +.TS +allbox tab(:); +l l l l l l l l. +a:b:c:d:e:f:g:T{ +1234567 9 +T} +a:b:c:d:e:f:g:T{ +1234567 90 +T} +.TE diff --git a/regress/usr.bin/mandoc/tbl/data/block_width.out_ascii b/regress/usr.bin/mandoc/tbl/data/block_width.out_ascii new file mode 100644 index 00000000000..b454c5d3470 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/data/block_width.out_ascii @@ -0,0 +1,63 @@ +TBL-DATA-BLOCK_WIDTH(1) General Commands Manual TBL-DATA-BLOCK_WIDTH(1) + +NNAAMMEE + ttbbll--ddaattaa--bblloocckk__wwiiddtthh - default width of text blocks + +DDEESSCCRRIIPPTTIIOONN + one column: + +----------------------------------------+ + |1234567890123456789012345678901234567 9 | + +----------------------------------------+ + |1234567890123456789012345678901234567 | + |90 | + +----------------------------------------+ + two columns: + +--+----------------------------+ + |a | 123456789012345678901234 6 | + +--+----------------------------+ + |a | 123456789012345678901234 | + | | 67 | + +--+----------------------------+ + three columns: + +--+---+---------------------+ + |a | b | 12345678901234567 9 | + +--+---+---------------------+ + |a | b | 12345678901234567 | + | | | 90 | + +--+---+---------------------+ + four columns: + +--+---+---+------------------+ + |a | b | c | 12345678901234 6 | + +--+---+---+------------------+ + |a | b | c | 12345678901234 | + | | | | 67 | + +--+---+---+------------------+ + five columns: + +--+---+---+---+---------------+ + |a | b | c | d | 12345678901 3 | + +--+---+---+---+---------------+ + |a | b | c | d | 12345678901 | + | | | | | 34 | + +--+---+---+---+---------------+ + six columns: + +--+---+---+---+---+-------------+ + |a | b | c | d | e | 123456789 1 | + +--+---+---+---+---+-------------+ + |a | b | c | d | e | 123456789 | + | | | | | | 12 | + +--+---+---+---+---+-------------+ + seven columns: + +--+---+---+---+---+---+------------+ + |a | b | c | d | e | f | 12345678 0 | + +--+---+---+---+---+---+------------+ + |a | b | c | d | e | f | 12345678 | + | | | | | | | 01 | + +--+---+---+---+---+---+------------+ + eight columns: + +--+---+---+---+---+---+---+-----------+ + |a | b | c | d | e | f | g | 1234567 9 | + +--+---+---+---+---+---+---+-----------+ + |a | b | c | d | e | f | g | 1234567 | + | | | | | | | | 90 | + +--+---+---+---+---+---+---+-----------+ +OpenBSD June 15, 2017 OpenBSD diff --git a/usr.bin/mandoc/out.c b/usr.bin/mandoc/out.c index a0607fdf076..0a6daf4bfc7 100644 --- a/usr.bin/mandoc/out.c +++ b/usr.bin/mandoc/out.c @@ -1,4 +1,4 @@ -/* $OpenBSD: out.c,v 1.40 2017/06/14 18:23:26 schwarze Exp $ */ +/* $OpenBSD: out.c,v 1.41 2017/06/15 00:27:22 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2014, 2015, 2017 Ingo Schwarze @@ -155,7 +155,8 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp, tblcalc_data(tbl, col, opts, dp, dp->block == 0 ? 0 : dp->layout->width ? dp->layout->width : - rmargin ? rmargin / (sp->opts->cols + 1) : 0); + rmargin ? (rmargin + sp->opts->cols / 2) + / (sp->opts->cols + 1) : 0); } } -- 2.20.1