summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-13 14:38:39 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-13 14:38:39 +0000
commite7dab9772a875d20a9406379a4608eb63a30fa40 (patch)
treec05a00bb2cf0ce12ee4624e77d5cde24b475f581
parente5271db11f5167a259bfd09d2e8b62acccf6bea1 (diff)
fix the interaction of the allbox option with spanned cells in the layout
-rw-r--r--regress/usr.bin/mandoc/tbl/layout/span.in10
-rw-r--r--regress/usr.bin/mandoc/tbl/layout/span.out_ascii8
-rw-r--r--usr.bin/mandoc/tbl_term.c49
3 files changed, 50 insertions, 17 deletions
diff --git a/regress/usr.bin/mandoc/tbl/layout/span.in b/regress/usr.bin/mandoc/tbl/layout/span.in
index dc172dcd952..e210437af32 100644
--- a/regress/usr.bin/mandoc/tbl/layout/span.in
+++ b/regress/usr.bin/mandoc/tbl/layout/span.in
@@ -38,3 +38,13 @@ s:c:d
a:s:d
a:b:s
.TE
+.sp
+.TS
+allbox tab(:);
+L L L L L
+C S S C S
+R R R R R.
+a:b:c:d:e
+s1:s2
+a:b:c:d:e
+.TE
diff --git a/regress/usr.bin/mandoc/tbl/layout/span.out_ascii b/regress/usr.bin/mandoc/tbl/layout/span.out_ascii
index 0ffb9899e92..b2c6fcf36ed 100644
--- a/regress/usr.bin/mandoc/tbl/layout/span.out_ascii
+++ b/regress/usr.bin/mandoc/tbl/layout/span.out_ascii
@@ -29,5 +29,13 @@ DDEESSCCRRIIPPTTIIOONN
|a b s |
+--------------+
+ +--+---+---+---+---+
+ |a | b | c | d | e |
+ +--+---+---+---+---+
+ | s1 | s2 |
+ +--+---+---+---+---+
+ |a | b | c | d | e |
+ +--+---+---+---+---+
+
TBL-LAYOUT-SPAN(1)
diff --git a/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c
index 9c5d8aec5f2..8011095d221 100644
--- a/usr.bin/mandoc/tbl_term.c
+++ b/usr.bin/mandoc/tbl_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tbl_term.c,v 1.38 2017/06/12 22:48:52 schwarze Exp $ */
+/* $OpenBSD: tbl_term.c,v 1.39 2017/06/13 14:38:38 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -217,29 +217,44 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
dp = sp->first;
spans = 0;
for (ic = 0; ic < sp->opts->cols; ic++) {
- if (spans == 0) {
- tp->tcol++;
- if (dp != NULL) {
- spans = dp->spans;
- dp = dp->next;
- }
- if (tp->tcol->col < tp->tcol->lastcol)
- term_flushln(tp);
- if (tp->tcol->col < tp->tcol->lastcol)
- more = 1;
- if (tp->tcol + 1 ==
- tp->tcols + tp->lasttcol)
- continue;
- } else
- spans--;
- /* Vertical frames between data cells. */
+ /* Advance to next layout cell. */
if (cp != NULL) {
vert = cp->vert;
cp = cp->next;
} else
vert = 0;
+
+ /* Skip later cells in a span. */
+
+ if (spans) {
+ spans--;
+ continue;
+ }
+
+ /* Advance to next data cell. */
+
+ if (dp != NULL) {
+ spans = dp->spans;
+ dp = dp->next;
+ }
+
+ /* Print one line of text in the cell. */
+
+ tp->tcol++;
+ if (tp->tcol->col < tp->tcol->lastcol)
+ term_flushln(tp);
+ if (tp->tcol->col < tp->tcol->lastcol)
+ more = 1;
+
+ /*
+ * Vertical frames between data cells,
+ * but not after the last column.
+ */
+
+ if (tp->tcol + 1 == tp->tcols + tp->lasttcol)
+ continue;
if (vert == 0 &&
sp->opts->opts & TBL_OPT_ALLBOX)
vert = 1;