summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-06-17 14:55:30 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-06-17 14:55:30 +0000
commitb22a929d117e71834f587cea03908a8196c8c4d0 (patch)
tree3221477a6d56ed4336a554f82a23f0bb3a68221c
parent8b829c3fb9f3b6e04849fd535eeb826b618e533a (diff)
downloadmandoc-b22a929d117e71834f587cea03908a8196c8c4d0.tar.gz
tables leak tab settings to subsequent text
-rw-r--r--regress/tbl/data/block_width.in4
-rw-r--r--regress/tbl/data/block_width.out_ascii3
-rw-r--r--regress/tbl/layout/center.in4
-rw-r--r--regress/tbl/layout/center.out_ascii3
-rw-r--r--regress/tbl/layout/span.in4
-rw-r--r--regress/tbl/layout/span.out_ascii3
-rw-r--r--regress/tbl/mod/expand.in6
-rw-r--r--regress/tbl/mod/expand.out_ascii3
-rw-r--r--regress/tbl/mod/font.in4
-rw-r--r--regress/tbl/mod/font.out_ascii3
-rw-r--r--regress/tbl/mod/font.out_lint4
-rw-r--r--tbl_term.c11
-rw-r--r--term.h1
-rw-r--r--term_tab.c15
14 files changed, 68 insertions, 0 deletions
diff --git a/regress/tbl/data/block_width.in b/regress/tbl/data/block_width.in
index 8c24a6f4..abff1555 100644
--- a/regress/tbl/data/block_width.in
+++ b/regress/tbl/data/block_width.in
@@ -100,3 +100,7 @@ a:b:c:d:e:f:g:T{
1234567 90
T}
.TE
+.sp
+leaked tab settings:
+.br
+\& b c d e f g h
diff --git a/regress/tbl/data/block_width.out_ascii b/regress/tbl/data/block_width.out_ascii
index b454c5d3..f386feff 100644
--- a/regress/tbl/data/block_width.out_ascii
+++ b/regress/tbl/data/block_width.out_ascii
@@ -60,4 +60,7 @@ DDEESSCCRRIIPPTTIIOONN
|a | b | c | d | e | f | g | 1234567 |
| | | | | | | | 90 |
+--+---+---+---+---+---+---+-----------+
+ leaked tab settings:
+ b c d e f g h
+
OpenBSD June 15, 2017 OpenBSD
diff --git a/regress/tbl/layout/center.in b/regress/tbl/layout/center.in
index d4ca166e..39533361 100644
--- a/regress/tbl/layout/center.in
+++ b/regress/tbl/layout/center.in
@@ -20,3 +20,7 @@ r c l .
****:****:****
*****:*****:*****
.TE
+.sp
+leaked tab settings:
+.br
+a b c de
diff --git a/regress/tbl/layout/center.out_ascii b/regress/tbl/layout/center.out_ascii
index 27e03c99..a77bb7b4 100644
--- a/regress/tbl/layout/center.out_ascii
+++ b/regress/tbl/layout/center.out_ascii
@@ -17,6 +17,9 @@ DDEESSCCRRIIPPTTIIOONN
**** **** ****
***** ***** *****
+ leaked tab settings:
+ a b c de
+
TBL-LAYOUT-CENTER(1)
diff --git a/regress/tbl/layout/span.in b/regress/tbl/layout/span.in
index e210437a..d5fef0c7 100644
--- a/regress/tbl/layout/span.in
+++ b/regress/tbl/layout/span.in
@@ -48,3 +48,7 @@ a:b:c:d:e
s1:s2
a:b:c:d:e
.TE
+.sp
+leaked tab settings:
+.br
+a b c d e f
diff --git a/regress/tbl/layout/span.out_ascii b/regress/tbl/layout/span.out_ascii
index b2c6fcf3..e439a766 100644
--- a/regress/tbl/layout/span.out_ascii
+++ b/regress/tbl/layout/span.out_ascii
@@ -36,6 +36,9 @@ DDEESSCCRRIIPPTTIIOONN
+--+---+---+---+---+
|a | b | c | d | e |
+--+---+---+---+---+
+ leaked tab settings:
+ a b c d e f
+
TBL-LAYOUT-SPAN(1)
diff --git a/regress/tbl/mod/expand.in b/regress/tbl/mod/expand.in
index dbb490f5..d51cd2a6 100644
--- a/regress/tbl/mod/expand.in
+++ b/regress/tbl/mod/expand.in
@@ -223,3 +223,9 @@ tab(:);
lx lx lx lx lx l rx.
x:x:x:x:x:123456789012345678901234567890123456789012:x
.TE
+.sp
+.nf
+leaked tab settings:
+.br
+a b c d e f g h
+.fi
diff --git a/regress/tbl/mod/expand.out_ascii b/regress/tbl/mod/expand.out_ascii
index 2b4d193a..41bf9869 100644
--- a/regress/tbl/mod/expand.out_ascii
+++ b/regress/tbl/mod/expand.out_ascii
@@ -96,6 +96,9 @@ DDEESSCCRRIIPPTTIIOONN
x x x x x 123456789012345678901234567890123456789012 x
+ leaked tab settings:
+ a b c d e f g h
+
OpenBSD January 27, 2015 TBL-MOD-EXPAND(1)
diff --git a/regress/tbl/mod/font.in b/regress/tbl/mod/font.in
index b371bfcb..448c1bf6 100644
--- a/regress/tbl/mod/font.in
+++ b/regress/tbl/mod/font.in
@@ -12,3 +12,7 @@ _
italic:roman:bold
and:so:on
.TE
+.sp
+leaked tab settings:
+.br
+a b c d e
diff --git a/regress/tbl/mod/font.out_ascii b/regress/tbl/mod/font.out_ascii
index 70438643..4e431870 100644
--- a/regress/tbl/mod/font.out_ascii
+++ b/regress/tbl/mod/font.out_ascii
@@ -14,6 +14,9 @@ DDEESSCCRRIIPPTTIIOONN
|_i_t_a_l_i_c | roman | bboolldd |
| _a_n_d | so | oonn |
+-------+-------+--------+
+ leaked tab settings:
+ a b c de
+
OpenBSD February 10, 2015 TBL-MOD-FONT(1)
diff --git a/regress/tbl/mod/font.out_lint b/regress/tbl/mod/font.out_lint
index 14506a51..d45d1896 100644
--- a/regress/tbl/mod/font.out_lint
+++ b/regress/tbl/mod/font.out_lint
@@ -1 +1,5 @@
mandoc: font.in:8:6: WARNING: unknown font, skipping request: TS fCW|ci
+mandoc: font.in:18:2: WARNING: tab in filled text
+mandoc: font.in:18:4: WARNING: tab in filled text
+mandoc: font.in:18:6: WARNING: tab in filled text
+mandoc: font.in:18:8: WARNING: tab in filled text
diff --git a/tbl_term.c b/tbl_term.c
index 020a1625..e8542d36 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -93,6 +93,17 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
tblcalc(&tp->tbl, sp, tp->tcol->offset, tp->tcol->rmargin);
+ /* Tables leak .ta settings to subsequent text. */
+
+ term_tab_set(tp, NULL);
+ coloff = sp->opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) ||
+ sp->opts->lvert;
+ for (ic = 0; ic < sp->opts->cols; ic++) {
+ coloff += tp->tbl.cols[ic].width;
+ term_tab_iset(coloff);
+ coloff += 3;
+ }
+
/* Center the table as a whole. */
offset = tp->tcol->offset;
diff --git a/term.h b/term.h
index a9131e46..54f60791 100644
--- a/term.h
+++ b/term.h
@@ -146,6 +146,7 @@ size_t term_strlen(const struct termp *, const char *);
size_t term_len(const struct termp *, size_t);
void term_tab_set(const struct termp *, const char *);
+void term_tab_iset(size_t);
size_t term_tab_next(size_t);
void term_fontpush(struct termp *, enum termfont);
diff --git a/term_tab.c b/term_tab.c
index 2acfd46a..5251a842 100644
--- a/term_tab.c
+++ b/term_tab.c
@@ -88,6 +88,21 @@ term_tab_set(const struct termp *p, const char *arg)
tl->n++;
}
+/*
+ * Simplified version without a parser,
+ * never incremental, never periodic, for use by tbl(7).
+ */
+void
+term_tab_iset(size_t inc)
+{
+ if (tabs.a.n >= tabs.a.s) {
+ tabs.a.s += 8;
+ tabs.a.t = mandoc_reallocarray(tabs.a.t, tabs.a.s,
+ sizeof(*tabs.a.t));
+ }
+ tabs.a.t[tabs.a.n++] = inc;
+}
+
size_t
term_tab_next(size_t prev)
{