summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-12 16:01:01 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-12 16:01:01 +0000
commit60aba25148a5a3280bb5e9816867afa8659b7a81 (patch)
treea8b197dcc64f8e48c5011a13913da0293b35838f
parent2e08684b6f7079837888e14e0a2129df281b31e8 (diff)
downloadmandoc-60aba25148a5a3280bb5e9816867afa8659b7a81.tar.gz
Tiny EOS patch. Back-end cues front-end through flag. Front-end cues output engine with flag.
-rw-r--r--mdoc.c28
-rw-r--r--mdoc.h1
-rw-r--r--mdoc_term.c3
-rw-r--r--term.c7
-rw-r--r--term.h1
5 files changed, 38 insertions, 2 deletions
diff --git a/mdoc.c b/mdoc.c
index 08064f34..efa18631 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -689,7 +689,33 @@ mdoc_ptext(struct mdoc *m, int line, char *buf)
/* Allocate the whole word. */
- return(mdoc_word_alloc(m, line, 0, buf));
+ if ( ! mdoc_word_alloc(m, line, 0, buf))
+ return(0);
+
+ /*
+ * End-of-sentence check. If the last character is an unescaped
+ * EOS character, then flag the node as being the end of a
+ * sentence. The front-end will know how to interpret this.
+ */
+
+ assert(i);
+
+ switch (buf[i - 1]) {
+ case ('.'):
+ if (i > 1 && '\\' == buf[i - 2])
+ break;
+ /* FALLTHROUGH */
+ case ('!'):
+ /* FALLTHROUGH */
+ case ('?'):
+ m->last->flags |= MDOC_EOS;
+ break;
+ default:
+ break;
+
+ }
+
+ return(1);
}
diff --git a/mdoc.h b/mdoc.h
index 911c88ec..9246b2a3 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -260,6 +260,7 @@ struct mdoc_node {
int flags;
#define MDOC_VALID (1 << 0)
#define MDOC_ACTED (1 << 1)
+#define MDOC_EOS (1 << 2)
enum mdoc_type type;
enum mdoc_sec sec;
diff --git a/mdoc_term.c b/mdoc_term.c
index b175c784..de9af97e 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -337,6 +337,9 @@ print_mdoc_node(DECL_ARGS)
if (termacts[n->tok].post)
(*termacts[n->tok].post)(p, &npair, m, n);
+ if (MDOC_EOS & n->flags)
+ p->flags |= TERMP_SENTENCE;
+
p->offset = offset;
p->rmargin = rmargin;
}
diff --git a/term.c b/term.c
index cf068e44..bdd3d38c 100644
--- a/term.c
+++ b/term.c
@@ -445,12 +445,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) {
diff --git a/term.h b/term.h
index f048e091..62da4174 100644
--- a/term.h
+++ b/term.h
@@ -39,6 +39,7 @@ struct termp {
size_t col; /* Bytes in buf. */
int overstep; /* See termp_flushln(). */
int flags;
+#define TERMP_SENTENCE (1 << 1) /* Space before a sentence. */
#define TERMP_NOSPACE (1 << 2) /* No space before words. */
#define TERMP_NOLPAD (1 << 3) /* See term_flushln(). */
#define TERMP_NOBREAK (1 << 4) /* See term_flushln(). */