aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit9cf00cccdad95ea6408c16f3e4f7dad9be35dcc3 (patch)
treea5da5105c4ae81389bbe49216687bb554877febd /term.c
parent784761c6ff66bb8d9b89b18b4a583a51af8522ec (diff)
downloadmandoc-9cf00cccdad95ea6408c16f3e4f7dad9be35dcc3.tar.gz
mandoc-9cf00cccdad95ea6408c16f3e4f7dad9be35dcc3.tar.zst
mandoc-9cf00cccdad95ea6408c16f3e4f7dad9be35dcc3.zip
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.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/term.c b/term.c
index 0d5eafd8..d3b21774 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.216 2014/01/22 20:58:39 schwarze Exp $ */
+/* $Id: term.c,v 1.217 2014/03/13 19:23:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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]);