diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-05-14 19:52:44 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-05-14 19:52:44 +0000 |
commit | 3cce8de3c5ac3b5f6a69a551cd7f542ea28ce781 (patch) | |
tree | ccf8b10982fe7aeb28b4829db92824206e362dc1 /usr.bin/mandoc/mdoc.c | |
parent | 91f46c931780d7b547ff88e7f5860d322a57cfca (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/mdoc.c')
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index a19720547b1..e745ec86774 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.47 2010/05/14 14:47:44 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.48 2010/05/14 19:52:43 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -120,7 +120,7 @@ const char *const __mdoc_macronames[MDOC_MAX] = { /* LINTED */ "Dx", "%Q", "br", "sp", /* LINTED */ - "%U", "eos" + "%U" }; const char *const __mdoc_argnames[MDOC_ARG_MAX] = { @@ -688,20 +688,21 @@ mdoc_ptext(struct mdoc *m, int line, char *buf) } /* Allocate the whole word. */ + if ( ! mdoc_word_alloc(m, line, 0, buf)) return(0); /* - * Mark the end of a sentence. Only works when you respect - * Jason's rule: "new sentence, new line". + * 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. */ - if ('.' == buf[i-1] || '!' == buf[i-1] || '?' == buf[i-1]) { - m->next = MDOC_NEXT_SIBLING; - if ( ! mdoc_elem_alloc(m, line, i, MDOC_eos, NULL)) - return(0); - } - m->next = MDOC_NEXT_SIBLING; + assert(i); + + if (mandoc_eos(buf, (size_t)i)) + m->last->flags |= MDOC_EOS; + return(1); } @@ -727,8 +728,6 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf) enum mdoct tok; int i, j, sv; char mac[5]; - struct mdoc_node *n; - char *t; /* Empty lines are ignored. */ @@ -799,29 +798,6 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf) if ( ! mdoc_macro(m, tok, ln, sv, &i, buf)) goto err; - /* - * Mark the end of a sentence, but be careful not to insert - * markers into reference blocks and after ellipses in - * function definitions. - */ - n = m->last; - if (n->child) - n = n->child; - while (n->next) - n = n->next; - if (MDOC_TEXT == n->type && - MDOC_Fn != n->parent->tok && - MDOC_Rs != m->last->parent->tok) { - t = n->string; - while (t[0] && t[1]) - t++; - if ('.' == *t || '!' == *t || '?' == *t) { - if ( ! mdoc_elem_alloc(m, ln, i, MDOC_eos, NULL)) - return(0); - m->next = MDOC_NEXT_SIBLING; - } - } - return(1); err: /* Error out. */ |