tables leak tab settings to subsequent text
authorschwarze <schwarze@openbsd.org>
Sat, 17 Jun 2017 14:55:02 +0000 (14:55 +0000)
committerschwarze <schwarze@openbsd.org>
Sat, 17 Jun 2017 14:55:02 +0000 (14:55 +0000)
14 files changed:
regress/usr.bin/mandoc/tbl/data/block_width.in
regress/usr.bin/mandoc/tbl/data/block_width.out_ascii
regress/usr.bin/mandoc/tbl/layout/center.in
regress/usr.bin/mandoc/tbl/layout/center.out_ascii
regress/usr.bin/mandoc/tbl/layout/span.in
regress/usr.bin/mandoc/tbl/layout/span.out_ascii
regress/usr.bin/mandoc/tbl/mod/expand.in
regress/usr.bin/mandoc/tbl/mod/expand.out_ascii
regress/usr.bin/mandoc/tbl/mod/font.in
regress/usr.bin/mandoc/tbl/mod/font.out_ascii
regress/usr.bin/mandoc/tbl/mod/font.out_lint
usr.bin/mandoc/tbl_term.c
usr.bin/mandoc/term.h
usr.bin/mandoc/term_tab.c

index 8c24a6f..abff155 100644 (file)
@@ -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
index b454c5d..f386fef 100644 (file)
@@ -60,4 +60,7 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
      |a | b | c | d | e | f | g | 1234567   |
      |  |   |   |   |   |   |   | 90        |
      +--+---+---+---+---+---+---+-----------+
+     leaked tab settings:
+       b   c   d   e   f   g   h
+
 OpenBSD                          June 15, 2017                         OpenBSD
index d4ca166..3953336 100644 (file)
@@ -20,3 +20,7 @@ r c l .
 ****:****:****
 *****:*****:*****
 .TE
+.sp
+leaked tab settings:
+.br
+a      b       c       de
index 27e03c9..a77bb7b 100644 (file)
@@ -17,6 +17,9 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
         ****   ****    ****
        *****   *****   *****
 
+       leaked tab settings:
+       a    b       c       de
+
 
 
                                                           TBL-LAYOUT-CENTER(1)
index e210437..d5fef0c 100644 (file)
@@ -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
index b2c6fcf..e439a76 100644 (file)
@@ -36,6 +36,9 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        +--+---+---+---+---+
        |a | b | c | d | e |
        +--+---+---+---+---+
+       leaked tab settings:
+       a b   c   d   e   f
+
 
 
                                                             TBL-LAYOUT-SPAN(1)
index dbb490f..d51cd2a 100644 (file)
@@ -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
index 2b4d193..41bf986 100644 (file)
@@ -96,6 +96,9 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
 
        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)
index b371bfc..448c1bf 100644 (file)
@@ -12,3 +12,7 @@ _
 italic:roman:bold
 and:so:on
 .TE
+.sp
+leaked tab settings:
+.br
+a      b       c       d       e
index 7043864..4e43187 100644 (file)
@@ -14,6 +14,9 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        |_\bi_\bt_\ba_\bl_\bi_\bc | roman |  b\bbo\bol\bld\bd  |
        | _\ba_\bn_\bd   |  so   |   o\bon\bn   |
        +-------+-------+--------+
+       leaked tab settings:
+       a      b       c        de
+
 
 
 OpenBSD                        February 10, 2015               TBL-MOD-FONT(1)
index 14506a5..d45d189 100644 (file)
@@ -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
index ddc33a3..7466bfa 100644 (file)
@@ -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 <kristaps@bsd.lv>
  * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;
index 0042627..6a8ef60 100644 (file)
@@ -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 <kristaps@bsd.lv>
  * Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
index 3164840..0c80c72 100644 (file)
@@ -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 <schwarze@openbsd.org>
  *
@@ -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)
 {