From c18aa4a98ecd884d3653d629d281c11204fce5a9 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sat, 17 Jun 2017 14:55:02 +0000 Subject: [PATCH] tables leak tab settings to subsequent text --- regress/usr.bin/mandoc/tbl/data/block_width.in | 4 ++++ .../mandoc/tbl/data/block_width.out_ascii | 3 +++ regress/usr.bin/mandoc/tbl/layout/center.in | 4 ++++ .../usr.bin/mandoc/tbl/layout/center.out_ascii | 3 +++ regress/usr.bin/mandoc/tbl/layout/span.in | 4 ++++ .../usr.bin/mandoc/tbl/layout/span.out_ascii | 3 +++ regress/usr.bin/mandoc/tbl/mod/expand.in | 6 ++++++ regress/usr.bin/mandoc/tbl/mod/expand.out_ascii | 3 +++ regress/usr.bin/mandoc/tbl/mod/font.in | 4 ++++ regress/usr.bin/mandoc/tbl/mod/font.out_ascii | 3 +++ regress/usr.bin/mandoc/tbl/mod/font.out_lint | 4 ++++ usr.bin/mandoc/tbl_term.c | 13 ++++++++++++- usr.bin/mandoc/term.h | 3 ++- usr.bin/mandoc/term_tab.c | 17 ++++++++++++++++- 14 files changed, 71 insertions(+), 3 deletions(-) diff --git a/regress/usr.bin/mandoc/tbl/data/block_width.in b/regress/usr.bin/mandoc/tbl/data/block_width.in index 8c24a6f4151..abff1555a0e 100644 --- a/regress/usr.bin/mandoc/tbl/data/block_width.in +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/data/block_width.out_ascii b/regress/usr.bin/mandoc/tbl/data/block_width.out_ascii index b454c5d3470..f386feff0d0 100644 --- a/regress/usr.bin/mandoc/tbl/data/block_width.out_ascii +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/layout/center.in b/regress/usr.bin/mandoc/tbl/layout/center.in index d4ca166e5fe..39533361dde 100644 --- a/regress/usr.bin/mandoc/tbl/layout/center.in +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/layout/center.out_ascii b/regress/usr.bin/mandoc/tbl/layout/center.out_ascii index 27e03c990e1..a77bb7b4e78 100644 --- a/regress/usr.bin/mandoc/tbl/layout/center.out_ascii +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/layout/span.in b/regress/usr.bin/mandoc/tbl/layout/span.in index e210437af32..d5fef0c7f15 100644 --- a/regress/usr.bin/mandoc/tbl/layout/span.in +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/layout/span.out_ascii b/regress/usr.bin/mandoc/tbl/layout/span.out_ascii index b2c6fcf36ed..e439a766430 100644 --- a/regress/usr.bin/mandoc/tbl/layout/span.out_ascii +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/mod/expand.in b/regress/usr.bin/mandoc/tbl/mod/expand.in index dbb490f5463..d51cd2a6182 100644 --- a/regress/usr.bin/mandoc/tbl/mod/expand.in +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/mod/expand.out_ascii b/regress/usr.bin/mandoc/tbl/mod/expand.out_ascii index 2b4d193a5d6..41bf9869d06 100644 --- a/regress/usr.bin/mandoc/tbl/mod/expand.out_ascii +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/mod/font.in b/regress/usr.bin/mandoc/tbl/mod/font.in index b371bfcb3cc..448c1bf674d 100644 --- a/regress/usr.bin/mandoc/tbl/mod/font.in +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/mod/font.out_ascii b/regress/usr.bin/mandoc/tbl/mod/font.out_ascii index 70438643820..4e43187012b 100644 --- a/regress/usr.bin/mandoc/tbl/mod/font.out_ascii +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl/mod/font.out_lint b/regress/usr.bin/mandoc/tbl/mod/font.out_lint index 14506a511d9..d45d18964cf 100644 --- a/regress/usr.bin/mandoc/tbl/mod/font.out_lint +++ b/regress/usr.bin/mandoc/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/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c index ddc33a31027..7466bfa7f93 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.41 2017/06/16 20:00:41 schwarze Exp $ */ +/* $OpenBSD: tbl_term.c,v 1.42 2017/06/17 14:55:02 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze @@ -91,6 +91,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/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h index 0042627cc82..6a8ef603ba2 100644 --- a/usr.bin/mandoc/term.h +++ b/usr.bin/mandoc/term.h @@ -1,4 +1,4 @@ -/* $OpenBSD: term.h,v 1.72 2017/06/14 17:50:43 schwarze Exp $ */ +/* $OpenBSD: term.h,v 1.73 2017/06/17 14:55:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017 Ingo Schwarze @@ -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/usr.bin/mandoc/term_tab.c b/usr.bin/mandoc/term_tab.c index 31648407388..0c80c72563c 100644 --- a/usr.bin/mandoc/term_tab.c +++ b/usr.bin/mandoc/term_tab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: term_tab.c,v 1.3 2017/06/14 17:50:43 schwarze Exp $ */ +/* $OpenBSD: term_tab.c,v 1.4 2017/06/17 14:55:02 schwarze Exp $ */ /* * Copyright (c) 2017 Ingo Schwarze * @@ -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) { -- 2.20.1