aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--man_term.c6
-rw-r--r--mdoc_term.c6
-rw-r--r--term.c8
-rw-r--r--term.h15
4 files changed, 21 insertions, 14 deletions
diff --git a/man_term.c b/man_term.c
index a79e5e27..d3fdafef 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.183 2015/04/19 19:44:21 schwarze Exp $ */
+/* $Id: man_term.c,v 1.184 2015/09/21 13:25:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -671,7 +671,7 @@ pre_TP(DECL_ARGS)
switch (n->type) {
case ROFFT_HEAD:
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRTRSP;
p->trailspace = 1;
break;
case ROFFT_BODY:
@@ -723,7 +723,7 @@ pre_TP(DECL_ARGS)
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin;
p->trailspace = 0;
- p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
break;
default:
break;
diff --git a/mdoc_term.c b/mdoc_term.c
index dabbabba..c61a13de 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.325 2015/09/14 12:57:47 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.326 2015/09/21 13:25:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -802,7 +802,7 @@ termp_it_pre(DECL_ARGS)
if (n->type != ROFFT_HEAD)
break;
- p->flags |= TERMP_NOBREAK | TERMP_BRIND;
+ p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND;
p->trailspace = 2;
if (NULL == n->next || NULL == n->next->child)
@@ -974,7 +974,7 @@ termp_it_post(DECL_ARGS)
* has munged them in the meanwhile.
*/
- p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND |
TERMP_DANGLE | TERMP_HANG);
p->trailspace = 0;
}
diff --git a/term.c b/term.c
index 7070d09b..559f6caa 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.249 2015/08/30 21:10:56 schwarze Exp $ */
+/* $Id: term.c,v 1.250 2015/09/21 13:25:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -78,6 +78,8 @@ term_end(struct termp *p)
* the next column. However, if less than p->trailspace blanks,
* which can be 0, 1, or 2, remain to the right margin, the line
* will be broken.
+ * - TERMP_BRTRSP: Consider trailing whitespace significant
+ * when deciding whether the chunk fits or not.
* - TERMP_BRIND: If the chunk does not fit and the output line has
* to be broken, start the next line at the right margin instead
* of at the offset. Used together with TERMP_NOBREAK for the tags
@@ -291,6 +293,10 @@ term_flushln(struct termp *p)
} else if (TERMP_DANGLE & p->flags)
return;
+ /* Trailing whitespace is significant in some columns. */
+ if (vis && vbl && (TERMP_BRTRSP & p->flags))
+ vis += vbl;
+
/* If the column was overrun, break the line. */
if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) {
(*p->endline)(p);
diff --git a/term.h b/term.h
index 2db32864..15898856 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.115 2015/07/17 22:38:29 schwarze Exp $ */
+/* $Id: term.h,v 1.116 2015/09/21 13:25:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,12 +77,13 @@ struct termp {
#define TERMP_BACKAFTER (1 << 6) /* Back up after next character. */
#define TERMP_BACKBEFORE (1 << 7) /* Back up before next character. */
#define TERMP_NOBREAK (1 << 8) /* See term_flushln(). */
-#define TERMP_BRIND (1 << 9) /* See term_flushln(). */
-#define TERMP_DANGLE (1 << 10) /* See term_flushln(). */
-#define TERMP_HANG (1 << 11) /* See term_flushln(). */
-#define TERMP_NOSPLIT (1 << 12) /* Do not break line before .An. */
-#define TERMP_SPLIT (1 << 13) /* Break line before .An. */
-#define TERMP_NONEWLINE (1 << 14) /* No line break in nofill mode. */
+#define TERMP_BRTRSP (1 << 9) /* See term_flushln(). */
+#define TERMP_BRIND (1 << 10) /* See term_flushln(). */
+#define TERMP_DANGLE (1 << 11) /* See term_flushln(). */
+#define TERMP_HANG (1 << 12) /* See term_flushln(). */
+#define TERMP_NOSPLIT (1 << 13) /* Do not break line before .An. */
+#define TERMP_SPLIT (1 << 14) /* Break line before .An. */
+#define TERMP_NONEWLINE (1 << 15) /* No line break in nofill mode. */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
const struct mchars *symtab; /* Character table. */