aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-07-16 21:30:42 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-07-16 21:30:42 +0000
commit39070b5ef533e98051bf2861547f00117148516f (patch)
tree57911bcc459017b920c4a0ad7fddda9197c73b6b
parent8daf535665567d8c6c82a47d0e56bc6e1fdcd9e0 (diff)
downloadmandoc-39070b5ef533e98051bf2861547f00117148516f.tar.gz
mandoc-39070b5ef533e98051bf2861547f00117148516f.tar.zst
mandoc-39070b5ef533e98051bf2861547f00117148516f.zip
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.
-rw-r--r--TODO5
-rw-r--r--term.c10
2 files changed, 10 insertions, 5 deletions
diff --git a/TODO b/TODO
index d2c69aa5..ea5dc952 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.136 2012/06/12 20:21:04 kristaps Exp $
+* $Id: TODO,v 1.137 2012/07/16 21:30:42 schwarze Exp $
************************************************************************
************************************************************************
@@ -169,9 +169,6 @@
so far, we only have it in roff(7) and man(7)
reminded by millert@ Thu, 09 Dec 2010 17:29:52 -0500
-- perl(1) SYNOPSIS looks bad; reported by deraadt@
- 1) man(7) seems to need SYNOPSIS .Nm blocks, too
-
- In .Bl -column,
.It Em Authentication<tab>Key Length
ought to render "Key Length" with emphasis, too,
diff --git a/term.c b/term.c
index 26292b98..15f8812f 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.204 2012/07/10 15:35:41 schwarze Exp $ */
+/* $Id: term.c,v 1.205 2012/07/16 21:30:42 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;