diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-12 16:01:01 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-12 16:01:01 +0000 |
commit | 60aba25148a5a3280bb5e9816867afa8659b7a81 (patch) | |
tree | a8b197dcc64f8e48c5011a13913da0293b35838f | |
parent | 2e08684b6f7079837888e14e0a2129df281b31e8 (diff) | |
download | mandoc-60aba25148a5a3280bb5e9816867afa8659b7a81.tar.gz |
Tiny EOS patch. Back-end cues front-end through flag. Front-end cues output engine with flag.
-rw-r--r-- | mdoc.c | 28 | ||||
-rw-r--r-- | mdoc.h | 1 | ||||
-rw-r--r-- | mdoc_term.c | 3 | ||||
-rw-r--r-- | term.c | 7 | ||||
-rw-r--r-- | term.h | 1 |
5 files changed, 38 insertions, 2 deletions
@@ -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); } @@ -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; } @@ -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) { @@ -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(). */ |