summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--regress/tbl/layout/span.in10
-rw-r--r--regress/tbl/layout/span.out_ascii8
-rw-r--r--tbl_term.c47
3 files changed, 49 insertions, 16 deletions
diff --git a/regress/tbl/layout/span.in b/regress/tbl/layout/span.in
index dc172dcd..e210437a 100644
--- a/regress/tbl/layout/span.in
+++ b/regress/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/tbl/layout/span.out_ascii b/regress/tbl/layout/span.out_ascii
index 0ffb9899..b2c6fcf3 100644
--- a/regress/tbl/layout/span.out_ascii
+++ b/regress/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/tbl_term.c b/tbl_term.c
index 13438fd7..d0228b32 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -219,29 +219,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;