summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-26 02:39:59 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-26 02:39:59 +0000
commit71c147c136372d4309b120eda4306853560b848a (patch)
tree1b4efa482538f8fc7431ab27c2147a028931f03e /usr.bin/mandoc/term.c
parentc03090c978c31a26b24683e4bbdef4271bbf5b3a (diff)
When a word does not fully fit onto the output line, but it contains
at least one hyphen, we already had support for breaking the line a the last fitting hyphen. This patch improves this functionality by only breaking at hyphens in free-form text, and by not breaking at hyphens * at the beginning or end of a word or * immediately preceded or followed by another hyphen or * escaped by a preceding backslash. Before this patch, differences in break-at-hyphen support were one of the major sources of noise in automatic comparisons to mdoc(7) groff output. Now, the remaining differences are hard to find among the noise coming from other sources. Where there are still differences, what we do seems to be better than what groff does, see e.g. the chio(1) exchange and position commands for one of the now rare examples. idea and coding by kristaps@ Besides, this was the last substantial code difference left between bsd.lv and openbsd.org. We are now in full sync.
Diffstat (limited to 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 75fa28e3396..28799b3d0ac 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.34 2010/05/23 22:45:01 schwarze Exp $ */
+/* $Id: term.c,v 1.35 2010/05/26 02:39:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -190,14 +190,13 @@ term_flushln(struct termp *p)
for (jhy = 0; j < (int)p->col; j++) {
if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j])
break;
- if (8 == p->buf[j])
- vend--;
- else {
+ if (8 != p->buf[j]) {
if (vend > vis && vend < bp &&
- '-' == p->buf[j])
+ ASCII_HYPH == p->buf[j])
jhy = j;
vend++;
- }
+ } else
+ vend--;
}
/*
@@ -259,7 +258,12 @@ term_flushln(struct termp *p)
p->viscol += vbl;
vbl = 0;
}
- putchar(p->buf[i]);
+
+ if (ASCII_HYPH == p->buf[i])
+ putchar('-');
+ else
+ putchar(p->buf[i]);
+
p->viscol += 1;
}
vend += vbl;