summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-03-13 19:23:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-03-13 19:23:50 +0000
commitd8c40dbb7a90802c294a84afbbb0ecadbafae87b (patch)
tree214b1222a5d0b765cf14245de05ff257cf332b2c /term.c
parentdc07642eedacb8edaeb34d51f9a4464efee267ee (diff)
downloadmandoc-d8c40dbb7a90802c294a84afbbb0ecadbafae87b.tar.gz
In -Tutf8 mode, make sure that hyphens get counted against the output line
length even when they are breakable. Before this, a line containing N breakable hyphens could get up to N characters wider than the right margin in -Tutf8 output mode. Issue reported by tedu@ on <bugs at OpenBSD>.
Diffstat (limited to 'term.c')
-rw-r--r--term.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/term.c b/term.c
index 01d6ed60..97efc3ee 100644
--- a/term.c
+++ b/term.c
@@ -183,6 +183,13 @@ term_flushln(struct termp *p)
ASCII_BREAK == p->buf[j]))
jhy = j;
+ /*
+ * Hyphenation now decided, put back a real
+ * hyphen such that we get the correct width.
+ */
+ if (ASCII_HYPH == p->buf[j])
+ p->buf[j] = '-';
+
vend += (*p->width)(p, p->buf[j]);
}
@@ -248,12 +255,6 @@ term_flushln(struct termp *p)
vbl = 0;
}
- if (ASCII_HYPH == p->buf[i]) {
- (*p->letter)(p, '-');
- p->viscol += (*p->width)(p, '-');
- continue;
- }
-
(*p->letter)(p, p->buf[i]);
if (8 == p->buf[i])
p->viscol -= (*p->width)(p, p->buf[i-1]);