summaryrefslogtreecommitdiffstatshomepage
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
commited1a9f25e07b6ba9355192a1ca8ebedd5495e953 (patch)
treef76105ec4fa9d034fefaaef81d969d0549ecd196
parent9f11efb0307eb4c4dbb4a8fff243321100e27573 (diff)
downloadmandoc-ed1a9f25e07b6ba9355192a1ca8ebedd5495e953.tar.gz
mandoc-ed1a9f25e07b6ba9355192a1ca8ebedd5495e953.tar.zst
mandoc-ed1a9f25e07b6ba9355192a1ca8ebedd5495e953.zip
Tiny EOS patch. Back-end cues front-end through flag. Front-end cues output engine with flag.
-rw-r--r--mdoc.c30
-rw-r--r--mdoc.h3
-rw-r--r--mdoc_term.c5
-rw-r--r--term.c9
-rw-r--r--term.h3
5 files changed, 43 insertions, 7 deletions
diff --git a/mdoc.c b/mdoc.c
index aa6891fd..a00feaaf 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.127 2010/05/08 10:25:27 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.128 2010/05/12 16:01:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 44641612..2d2267a2 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.76 2010/05/12 08:41:17 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.77 2010/05/12 16:01:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 4f625a58..490c3e47 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.120 2010/05/10 08:05:17 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.121 2010/05/12 16:01:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 2b6dd203..be1ffcc7 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.132 2010/05/07 04:50:44 kristaps Exp $ */
+/* $Id: term.c,v 1.133 2010/05/12 16:01:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 7c10ff4f..3b9beb01 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.53 2010/05/10 08:05:17 kristaps Exp $ */
+/* $Id: term.h,v 1.54 2010/05/12 16:01:01 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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(). */