diff options
author | 2012-07-16 21:28:12 +0000 | |
---|---|---|
committer | 2012-07-16 21:28:12 +0000 | |
commit | cde8dfc671e8d3db76b94665fcab54244ff17fa0 (patch) | |
tree | b0a395556e0f18eb2550e6955459239ff4bc5d5e | |
parent | test end-of-sentence handling (diff) | |
download | wireguard-openbsd-cde8dfc671e8d3db76b94665fcab54244ff17fa0.tar.xz wireguard-openbsd-cde8dfc671e8d3db76b94665fcab54244ff17fa0.zip |
Release polishing: finally fix the perl(1) SYNOPSIS.
In flush-left mode of both man(7) and mdoc(7), when an output line is broken
at the position of a literal tab, the tab indents the following line.
Reminded by deraadt@ in Pest, Ujlipotvaros, Csanady utza.
-rw-r--r-- | regress/usr.bin/mandoc/char/space/tab-man.in | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/tab-man.out_ascii | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/tab.in | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/char/space/tab.out_ascii | 2 | ||||
-rw-r--r-- | usr.bin/mandoc/term.c | 10 |
5 files changed, 19 insertions, 1 deletions
diff --git a/regress/usr.bin/mandoc/char/space/tab-man.in b/regress/usr.bin/mandoc/char/space/tab-man.in index 0a2ccafc851..165e59d1176 100644 --- a/regress/usr.bin/mandoc/char/space/tab-man.in +++ b/regress/usr.bin/mandoc/char/space/tab-man.in @@ -40,6 +40,9 @@ space tab .br tab .br + This line starts with a tab and comes close to the right margin. + The next line starts with a tab as well. +.br In a literal display: .nf 1 x diff --git a/regress/usr.bin/mandoc/char/space/tab-man.out_ascii b/regress/usr.bin/mandoc/char/space/tab-man.out_ascii index a9cbcce5f62..91c9481a255 100644 --- a/regress/usr.bin/mandoc/char/space/tab-man.out_ascii +++ b/regress/usr.bin/mandoc/char/space/tab-man.out_ascii @@ -25,6 +25,8 @@ DDEESSCCRRIIPPTTIIOONN space tab tab tab + This line starts with a tab and comes close to the right margin. + The next line starts with a tab as well. In a literal display: 1 x 22 x diff --git a/regress/usr.bin/mandoc/char/space/tab.in b/regress/usr.bin/mandoc/char/space/tab.in index 5db8621366c..e801cbd96c6 100644 --- a/regress/usr.bin/mandoc/char/space/tab.in +++ b/regress/usr.bin/mandoc/char/space/tab.in @@ -43,6 +43,9 @@ space tab .br tab .br + This line starts with a tab and comes close to the right margin. + The next line starts with a tab as well. +.br ragged display .Bd -ragged -offset 2n 1 x diff --git a/regress/usr.bin/mandoc/char/space/tab.out_ascii b/regress/usr.bin/mandoc/char/space/tab.out_ascii index 8fafb045304..a0f6192ce60 100644 --- a/regress/usr.bin/mandoc/char/space/tab.out_ascii +++ b/regress/usr.bin/mandoc/char/space/tab.out_ascii @@ -23,6 +23,8 @@ DDEESSCCRRIIPPTTIIOONN space tab tab tab + This line starts with a tab and comes close to the right margin. + The next line starts with a tab as well. ragged display 1 x diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index 43d33868b43..4a40dcf7840 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.65 2012/07/10 15:33:40 schwarze Exp $ */ +/* $Id: term.c,v 1.66 2012/07/16 21:28:12 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -102,6 +102,7 @@ void term_flushln(struct termp *p) { int i; /* current input position in p->buf */ + int ntab; /* number of tabs to prepend */ size_t vis; /* current visual position on output */ size_t vbl; /* number of blanks to prepend to output */ size_t vend; /* end of word visual position on output */ @@ -140,10 +141,12 @@ term_flushln(struct termp *p) * Handle literal tab characters: collapse all * subsequent tabs into a single huge set of spaces. */ + ntab = 0; while (i < p->col && '\t' == p->buf[i]) { vend = (vis / p->tabwidth + 1) * p->tabwidth; vbl += vend - vis; vis = vend; + ntab++; i++; } @@ -188,6 +191,11 @@ term_flushln(struct termp *p) } else vbl = p->offset; + /* use pending tabs on the new line */ + + if (0 < ntab) + vbl += ntab * p->tabwidth; + /* Remove the p->overstep width. */ bp += (size_t)p->overstep; |