diff options
author | 2017-02-16 14:38:07 +0000 | |
---|---|---|
committer | 2017-02-16 14:38:07 +0000 | |
commit | d43cc8c25b197260eb71cfe6139e67ffdccc9e28 (patch) | |
tree | f8dc3c82a3725beaace67af11101ebf61e256699 | |
parent | Remove an unnecessary NULL pointer check. (diff) | |
download | wireguard-openbsd-d43cc8c25b197260eb71cfe6139e67ffdccc9e28.tar.xz wireguard-openbsd-d43cc8c25b197260eb71cfe6139e67ffdccc9e28.zip |
Surprisingly, groff does not support scaling units in .Bl -column
column width specifiers, so stop supporting them, too.
As a side effect, this fixes an assertion failure that tb@ found
with afl(1), triggered by: .Bl -column -4n
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bl/breakingTa.in | 2 | ||||
-rw-r--r-- | share/man/man7/mdoc.7 | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 16 |
3 files changed, 16 insertions, 12 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/breakingTa.in b/regress/usr.bin/mandoc/mdoc/Bl/breakingTa.in index ca8e57691b1..80192b6c3a2 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/breakingTa.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/breakingTa.in @@ -7,7 +7,7 @@ .Sh DESCRIPTION .\" Crashed before mdoc_macro.c OpenBSD rev. 1.172 initial text -.Bl -column 6n 6n +.Bl -column 123456 123456 .It it Aq aq Ta ta Bo bo bc .Bc Pq pq .El diff --git a/share/man/man7/mdoc.7 b/share/man/man7/mdoc.7 index 486091f6b86..bee51ea28fd 100644 --- a/share/man/man7/mdoc.7 +++ b/share/man/man7/mdoc.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mdoc.7,v 1.149 2017/02/05 22:30:16 schwarze Exp $ +.\" $OpenBSD: mdoc.7,v 1.150 2017/02/16 14:38:07 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2010, 2011, 2013-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 5 2017 $ +.Dd $Mdocdate: February 16 2017 $ .Dt MDOC 7 .Os .Sh NAME @@ -974,10 +974,8 @@ argument. A columnated list. The .Fl width -argument has no effect; instead, each argument specifies the width -of one column, using either the scaling width syntax described in -.Xr roff 7 -or the string length of the argument. +argument has no effect; instead, the string length of each argument +specifies the width of one column. If the first line of the body of a .Fl column list is not an diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 7e703011082..cc52257bd04 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_term.c,v 1.243 2017/02/16 02:59:42 schwarze Exp $ */ +/* $OpenBSD: mdoc_term.c,v 1.244 2017/02/16 14:38:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -604,6 +604,7 @@ termp_ll_pre(DECL_ARGS) static int termp_it_pre(DECL_ARGS) { + struct roffsu su; char buf[24]; const struct roff_node *bl, *nn; size_t ncols, dcol; @@ -681,9 +682,12 @@ termp_it_pre(DECL_ARGS) for (i = 0, nn = n->prev; nn->prev && i < (int)ncols; - nn = nn->prev, i++) - offset += dcol + a2width(p, - bl->norm->Bl.cols[i]); + nn = nn->prev, i++) { + SCALE_HS_INIT(&su, + term_strlen(p, bl->norm->Bl.cols[i])); + su.scale /= term_strlen(p, "0"); + offset += term_hspan(p, &su) / 24 + dcol; + } /* * When exceeding the declared number of columns, leave @@ -698,7 +702,9 @@ termp_it_pre(DECL_ARGS) * Use the declared column widths, extended as explained * in the preceding paragraph. */ - width = a2width(p, bl->norm->Bl.cols[i]) + dcol; + SCALE_HS_INIT(&su, term_strlen(p, bl->norm->Bl.cols[i])); + su.scale /= term_strlen(p, "0"); + width = term_hspan(p, &su) / 24 + dcol; break; default: if (NULL == bl->norm->Bl.width) |