summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-14 19:52:44 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-14 19:52:44 +0000
commit3cce8de3c5ac3b5f6a69a551cd7f542ea28ce781 (patch)
treeccf8b10982fe7aeb28b4829db92824206e362dc1 /usr.bin/mandoc/term.c
parent91f46c931780d7b547ff88e7f5860d322a57cfca (diff)
Integrate kristaps@' end-of-sentence (EOS) framework
which is simpler and more powerful than mine, and remove mine. * man(7) now has EOS handling, too * put EOS detection into its own function in libmandoc * use node and termp flags to communicate the EOS condition * no more EOS pseudo-macro * no more non-printable EOS marker character on the formatter level This slightly breaks EOS detection after trailing punctuation in mdoc(7) macros, but that will be restored soon.
Diffstat (limited to 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 45191b5e3da..55b7593942b 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.30 2010/04/23 00:23:47 schwarze Exp $ */
+/* $Id: term.c,v 1.31 2010/05/14 19:52:43 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -163,8 +163,7 @@ term_flushln(struct termp *p)
* beginning of a line, one between words -- but do not
* actually write them yet.
*/
- vbl = (size_t)(ASCII_EOS == p->buf[i] ? 2 :
- (0 == vis ? 0 : 1));
+ vbl = (size_t)(0 == vis ? 0 : 1);
vis += vbl;
vend = vis;
@@ -195,7 +194,7 @@ term_flushln(struct termp *p)
break;
else if (8 == p->buf[j])
vend--;
- else if (ASCII_EOS != p->buf[j]) {
+ else {
if (vend > vis && vend < bp &&
'-' == p->buf[j])
jhy = j;
@@ -204,13 +203,6 @@ term_flushln(struct termp *p)
}
/*
- * Skip empty words. This happens due to the ASCII_EOS
- * after the end of the final sentence of a paragraph.
- */
- if (vend == vis && j == (int)p->col)
- break;
-
- /*
* Usually, indent the first line of each paragraph.
*/
if (0 == i && ! (p->flags & TERMP_NOLPAD)) {
@@ -268,7 +260,7 @@ term_flushln(struct termp *p)
}
if (ASCII_NBRSP == p->buf[i])
putchar(' ');
- else if (ASCII_EOS != p->buf[i])
+ else
putchar(p->buf[i]);
}
p->viscol += vend - vis;
@@ -487,12 +479,17 @@ term_word(struct termp *p, const char *word)
break;
}
- if ( ! (TERMP_NOSPACE & p->flags))
+ if ( ! (TERMP_NOSPACE & p->flags)) {
bufferc(p, ' ');
+ if (TERMP_SENTENCE & p->flags)
+ bufferc(p, ' ');
+ }
if ( ! (p->flags & TERMP_NONOSPACE))
p->flags &= ~TERMP_NOSPACE;
+ p->flags &= ~TERMP_SENTENCE;
+
/* FIXME: use strcspn. */
while (*word) {
@@ -533,6 +530,10 @@ term_word(struct termp *p, const char *word)
p->flags |= TERMP_NOSPACE;
}
+ /*
+ * Note that we don't process the pipe: the parser sees it as
+ * punctuation, but we don't in terms of typography.
+ */
if (sv[0] && 0 == sv[1])
switch (sv[0]) {
case('('):