diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2012-07-16 21:30:42 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2012-07-16 21:30:42 +0000 |
commit | 281bbbb1c13720b538920e460b3ebfe1362b5f90 (patch) | |
tree | f4ed9fbf507a91478cc4c4909d75fcf1f33310b1 /term.c | |
parent | 7260a61d39e92ac325832b9dfbb203ebc0eb2a88 (diff) | |
download | mandoc-281bbbb1c13720b538920e460b3ebfe1362b5f90.tar.gz |
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.
Fixes the perl(1) SYNOPSIS; reminded by deraadt@; OpenBSD rev. 1.66.
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -106,6 +106,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 */ @@ -144,10 +145,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++; } @@ -192,6 +195,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; |