summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/libmandoc.h6
-rw-r--r--usr.bin/mandoc/man.c4
-rw-r--r--usr.bin/mandoc/mandoc.c24
-rw-r--r--usr.bin/mandoc/mdoc.c4
-rw-r--r--usr.bin/mandoc/mdoc_macro.c6
5 files changed, 23 insertions, 21 deletions
diff --git a/usr.bin/mandoc/libmandoc.h b/usr.bin/mandoc/libmandoc.h
index 9001dc797d7..c79a3c46689 100644
--- a/usr.bin/mandoc/libmandoc.h
+++ b/usr.bin/mandoc/libmandoc.h
@@ -1,6 +1,6 @@
-/* $Id: libmandoc.h,v 1.6 2010/06/26 17:56:43 schwarze Exp $ */
+/* $Id: libmandoc.h,v 1.7 2010/07/16 00:34:33 schwarze Exp $ */
/*
- * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -29,7 +29,7 @@ time_t mandoc_a2time(int, const char *);
#define MTIME_REDUCED (1 << 1)
#define MTIME_MDOCDATE (1 << 2)
#define MTIME_ISO_8601 (1 << 3)
-int mandoc_eos(const char *, size_t);
+int mandoc_eos(const char *, size_t, int);
int mandoc_hyph(const char *, const char *);
__END_DECLS
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 9ac7f5f9ad9..cb994e86653 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.36 2010/07/13 01:09:13 schwarze Exp $ */
+/* $Id: man.c,v 1.37 2010/07/16 00:34:33 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -405,7 +405,7 @@ man_ptext(struct man *m, int line, char *buf, int offs)
*/
assert(i);
- if (mandoc_eos(buf, (size_t)i))
+ if (mandoc_eos(buf, (size_t)i, 0))
m->last->flags |= MAN_EOS;
descope:
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index b652e5e2190..aeef2911def 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,6 +1,6 @@
-/* $Id: mandoc.c,v 1.14 2010/06/26 17:56:43 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.15 2010/07/16 00:34:33 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -324,8 +324,10 @@ mandoc_a2time(int flags, const char *p)
int
-mandoc_eos(const char *p, size_t sz)
+mandoc_eos(const char *p, size_t sz, int enclosed)
{
+ const char *q;
+ int found = 0;
if (0 == sz)
return(0);
@@ -336,8 +338,8 @@ mandoc_eos(const char *p, size_t sz)
* propogate outward.
*/
- for ( ; sz; sz--) {
- switch (p[(int)sz - 1]) {
+ for (q = p + sz - 1; q >= p; q--) {
+ switch (*q) {
case ('\"'):
/* FALLTHROUGH */
case ('\''):
@@ -345,22 +347,22 @@ mandoc_eos(const char *p, size_t sz)
case (']'):
/* FALLTHROUGH */
case (')'):
+ if (0 == found)
+ enclosed = 1;
break;
case ('.'):
- /* Escaped periods. */
- if (sz > 1 && '\\' == p[(int)sz - 2])
- return(0);
/* FALLTHROUGH */
case ('!'):
/* FALLTHROUGH */
case ('?'):
- return(1);
+ found = 1;
+ break;
default:
- return(0);
+ return(found && (!enclosed || isalnum(*q)));
}
}
- return(0);
+ return(found && !enclosed);
}
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index 1debb670eaf..51fb6e59096 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.61 2010/07/13 01:09:13 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.62 2010/07/16 00:34:33 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -717,7 +717,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
assert(buf < end);
- if (mandoc_eos(buf+offs, (size_t)(end-buf-offs)))
+ if (mandoc_eos(buf+offs, (size_t)(end-buf-offs), 0))
m->last->flags |= MDOC_EOS;
return(1);
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index c145394864b..b258157da05 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.54 2010/07/13 01:09:13 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.55 2010/07/16 00:34:33 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -606,7 +606,7 @@ append_delims(struct mdoc *m, int line, int *pos, char *buf)
* knowing which symbols break this behaviour, for
* example, `. ;' shouldn't propogate the double-space.
*/
- if (mandoc_eos(p, strlen(p)))
+ if (mandoc_eos(p, strlen(p), 0))
m->last->flags |= MDOC_EOS;
}
@@ -1262,7 +1262,7 @@ blk_part_imp(MACRO_PROT_ARGS)
*/
if (n && MDOC_TEXT == n->type && n->string)
- if (mandoc_eos(n->string, strlen(n->string)))
+ if (mandoc_eos(n->string, strlen(n->string), 1))
n->flags |= MDOC_EOS;
/* Up-propogate the end-of-space flag. */