summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2010-05-15 09:20:01 +0000
committerschwarze <schwarze@openbsd.org>2010-05-15 09:20:01 +0000
commit5234190c6faa6490c4c25eac05d1c62d802d1ee9 (patch)
treebea461f4cd5f6bd16f89f283aed492709b387b6d
parentAdd libsupc++-v3 (diff)
downloadwireguard-openbsd-5234190c6faa6490c4c25eac05d1c62d802d1ee9.tar.xz
wireguard-openbsd-5234190c6faa6490c4c25eac05d1c62d802d1ee9.zip
block-implicit macros now up-propogate end-of-sentence spacing;
from bsd.lv mandoc.c 1.13 and mdoc_macro.c 1.64
-rw-r--r--usr.bin/mandoc/mandoc.c5
-rw-r--r--usr.bin/mandoc/mdoc_macro.c22
2 files changed, 24 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index 34fa2029c48..6b04f5c983d 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.9 2010/05/14 19:52:43 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.10 2010/05/15 09:20:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -301,7 +301,8 @@ int
mandoc_eos(const char *p, size_t sz)
{
- assert(sz);
+ if (0 == sz)
+ return(0);
switch (p[(int)sz - 1]) {
case ('.'):
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 6ea3cbf4ec6..3f76b776175 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.38 2010/05/14 19:52:43 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.39 2010/05/15 09:20:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -22,6 +22,7 @@
#include <time.h>
#include "libmdoc.h"
+#include "libmandoc.h"
enum rew {
REWIND_REWIND,
@@ -1151,6 +1152,25 @@ blk_part_imp(MACRO_PROT_ARGS)
body = m->last;
}
+ for (n = body->child; n && n->next; n = n->next)
+ /* Do nothing. */ ;
+
+ /*
+ * End of sentence spacing: if the last node is a text node and
+ * has a trailing period, then mark it as being end-of-sentence.
+ */
+
+ if (n && MDOC_TEXT == n->type && n->string)
+ if (mandoc_eos(n->string, strlen(n->string)))
+ n->flags |= MDOC_EOS;
+
+ /* Up-propogate the end-of-space flag. */
+
+ if (n && (MDOC_EOS & n->flags)) {
+ body->flags |= MDOC_EOS;
+ body->parent->flags |= MDOC_EOS;
+ }
+
/*
* If we can't rewind to our body, then our scope has already
* been closed by another macro (like `Oc' closing `Op'). This