summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2010-05-15 15:37:53 +0000
committerschwarze <schwarze@openbsd.org>2010-05-15 15:37:53 +0000
commitc9513b01c8993037cd684a11e8008be2decef448 (patch)
tree0e5d0e6921e09de0d4c98668eff8053cf884bbbc
parentRepair identification of P4 bwtwo on 4/330 and 4/370 models, which got broken (diff)
downloadwireguard-openbsd-c9513b01c8993037cd684a11e8008be2decef448.tar.xz
wireguard-openbsd-c9513b01c8993037cd684a11e8008be2decef448.zip
more end-of-sentence (EOS) handling:
* recognize the end of quoted sentences, and of those in parantheses * detect EOS in append_delims, so it works after all macros by kristaps@
-rw-r--r--usr.bin/mandoc/man.713
-rw-r--r--usr.bin/mandoc/mandoc.c42
-rw-r--r--usr.bin/mandoc/mdoc.717
-rw-r--r--usr.bin/mandoc/mdoc_macro.c28
4 files changed, 73 insertions, 27 deletions
diff --git a/usr.bin/mandoc/man.7 b/usr.bin/mandoc/man.7
index df94dbf704b..5ac1fb1a56e 100644
--- a/usr.bin/mandoc/man.7
+++ b/usr.bin/mandoc/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.23 2010/05/14 19:52:43 schwarze Exp $
+.\" $Id: man.7,v 1.24 2010/05/15 15:37:53 schwarze Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 14 2010 $
+.Dd $Mdocdate: May 15 2010 $
.Dt MAN 7
.Os
.Sh NAME
@@ -216,8 +216,13 @@ literal text.
When composing a manual, make sure that your sentences end at the end of
a line.
By doing so, front-ends will be able to apply the proper amount of
-spacing after the end of sentence (unescaped) period, exclamation, or question
-mark.
+spacing after the end of sentence (unescaped) period, exclamation mark,
+or question mark followed by zero or more non-sentence closing
+delimiters (
+.Ns Sq \&) ,
+.Sq \&] ,
+.Sq \&' ,
+.Sq \&" ) .
.Sh MANUAL STRUCTURE
Each
.Nm
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index 6b04f5c983d..92c65e9d2e1 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.10 2010/05/15 09:20:01 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.11 2010/05/15 15:37:53 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -304,19 +304,35 @@ mandoc_eos(const char *p, size_t sz)
if (0 == sz)
return(0);
- switch (p[(int)sz - 1]) {
- case ('.'):
- /* Escaped periods. */
- if (sz > 1 && '\\' == p[(int)sz - 2])
+ /*
+ * End-of-sentence recognition must include situations where
+ * some symbols, such as `)', allow prior EOS punctuation to
+ * propogate outward.
+ */
+
+ for ( ; sz; sz--) {
+ switch (p[(int)sz - 1]) {
+ case ('\"'):
+ /* FALLTHROUGH */
+ case ('\''):
+ /* FALLTHROUGH */
+ case (']'):
+ /* FALLTHROUGH */
+ case (')'):
+ break;
+ case ('.'):
+ /* Escaped periods. */
+ if (sz > 1 && '\\' == p[(int)sz - 2])
+ return(0);
+ /* FALLTHROUGH */
+ case ('!'):
+ /* FALLTHROUGH */
+ case ('?'):
+ return(1);
+ default:
return(0);
- /* FALLTHROUGH */
- case ('!'):
- /* FALLTHROUGH */
- case ('?'):
- break;
- default:
- return(0);
+ }
}
- return(1);
+ return(0);
}
diff --git a/usr.bin/mandoc/mdoc.7 b/usr.bin/mandoc/mdoc.7
index aecae284574..d9e3578c063 100644
--- a/usr.bin/mandoc/mdoc.7
+++ b/usr.bin/mandoc/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.28 2010/05/14 19:52:43 schwarze Exp $
+.\" $Id: mdoc.7,v 1.29 2010/05/15 15:37:53 schwarze Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 14 2010 $
+.Dd $Mdocdate: May 15 2010 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -301,7 +301,18 @@ When composing a manual, make sure that your sentences end at the end of
a line.
By doing so, front-ends will be able to apply the proper amount of
spacing after the end of sentence (unescaped) period, exclamation mark,
-or question mark.
+or question mark followed by zero or more non-sentence closing
+delimiters (
+.Ns Sq \&) ,
+.Sq \&] ,
+.Sq \&' ,
+.Sq \&" ) .
+.Pp
+The proper spacing is also intelligently preserved if a sentence ends at
+the boundary of a macro line, e.g.,
+.Pp
+.D1 \&Xr mandoc 1 \.
+.D1 \&Fl T \&Ns \&Cm ascii \.
.Sh MANUAL STRUCTURE
A well-formed
.Nm
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 4f24b9adb77..df5ee6cec90 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.41 2010/05/15 13:12:55 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.42 2010/05/15 15:37:53 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -615,26 +615,40 @@ rew_sub(enum mdoc_type t, struct mdoc *m,
static int
-append_delims(struct mdoc *mdoc, int line, int *pos, char *buf)
+append_delims(struct mdoc *m, int line, int *pos, char *buf)
{
- int lastarg;
+ int la;
enum margserr ac;
char *p;
- if (0 == buf[*pos])
+ if ('\0' == buf[*pos])
return(1);
for (;;) {
- lastarg = *pos;
- ac = mdoc_zargs(mdoc, line, pos, buf, ARGS_NOWARN, &p);
+ la = *pos;
+ ac = mdoc_zargs(m, line, pos, buf, ARGS_NOWARN, &p);
if (ARGS_ERROR == ac)
return(0);
else if (ARGS_EOLN == ac)
break;
+
assert(DELIM_NONE != mdoc_isdelim(p));
- if ( ! mdoc_word_alloc(mdoc, line, lastarg, p))
+ if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
+ /*
+ * If we encounter end-of-sentence symbols, then trigger
+ * the double-space.
+ *
+ * XXX: it's easy to allow this to propogate outward to
+ * the last symbol, such that `. )' will cause the
+ * correct double-spacing. However, (1) groff isn't
+ * smart enough to do this and (2) it would require
+ * knowing which symbols break this behaviour, for
+ * example, `. ;' shouldn't propogate the double-space.
+ */
+ if (mandoc_eos(p, strlen(p)))
+ m->last->flags |= MDOC_EOS;
}
return(1);