summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-12 17:08:03 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-12 17:08:03 +0000
commit656e7e24eaab5e2a55266792dc96f1dda724ae25 (patch)
tree6ea05b6ab69313edba6b09b7764c4970afb590e6
parent86655cfd384a1fafb7e617962efa806115a2bc51 (diff)
downloadmandoc-656e7e24eaab5e2a55266792dc96f1dda724ae25.tar.gz
mandoc-656e7e24eaab5e2a55266792dc96f1dda724ae25.tar.zst
mandoc-656e7e24eaab5e2a55266792dc96f1dda724ae25.zip
Put the eos-checker into libmandoc.h.
Added bits in mdoc.7 and man.7 about EOS spacing.
-rw-r--r--libmandoc.h3
-rw-r--r--man.78
-rw-r--r--man.c16
-rw-r--r--mandoc.c25
-rw-r--r--mdoc.78
-rw-r--r--mdoc.c16
6 files changed, 44 insertions, 32 deletions
diff --git a/libmandoc.h b/libmandoc.h
index a6554cd0..7d31c84f 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmandoc.h,v 1.4 2009/11/02 06:22:45 kristaps Exp $ */
+/* $Id: libmandoc.h,v 1.5 2010/05/12 17:08:03 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -29,6 +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);
__END_DECLS
diff --git a/man.7 b/man.7
index c893f2f0..d4c4a68b 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.68 2010/05/12 16:52:33 kristaps Exp $
+.\" $Id: man.7,v 1.69 2010/05/12 17:08:03 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -212,6 +212,12 @@ this differs from
.Xr mdoc 7 ,
which, if a unit is not provided, will instead interpret the string as
literal text.
+.Ss Sentence Spacing
+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.
.Sh MANUAL STRUCTURE
Each
.Nm
diff --git a/man.c b/man.c
index 99804406..79f2e452 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.65 2010/05/12 16:46:28 kristaps Exp $ */
+/* $Id: man.c,v 1.66 2010/05/12 17:08:03 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -428,20 +428,8 @@ man_ptext(struct man *m, int line, char *buf)
assert(i);
- switch (buf[i - 1]) {
- case ('.'):
- if (i > 1 && '\\' == buf[i - 2])
- break;
- /* FALLTHROUGH */
- case ('!'):
- /* FALLTHROUGH */
- case ('?'):
+ if (mandoc_eos(buf, (size_t)i))
m->last->flags |= MAN_EOS;
- break;
- default:
- break;
-
- }
descope:
/*
diff --git a/mandoc.c b/mandoc.c
index 17d6d103..4d087956 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.11 2010/04/07 11:25:38 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.12 2010/05/12 17:08:03 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -300,3 +300,26 @@ mandoc_a2time(int flags, const char *p)
return(0);
}
+
+int
+mandoc_eos(const char *p, size_t sz)
+{
+
+ assert(sz);
+
+ switch (p[(int)sz - 1]) {
+ case ('.'):
+ /* Escaped periods. */
+ if (sz > 1 && '\\' == p[(int)sz - 2])
+ return(0);
+ /* FALLTHROUGH */
+ case ('!'):
+ /* FALLTHROUGH */
+ case ('?'):
+ break;
+ default:
+ return(0);
+ }
+
+ return(1);
+}
diff --git a/mdoc.7 b/mdoc.7
index d2c6762d..3005b492 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.100 2010/05/12 16:45:18 kristaps Exp $
+.\" $Id: mdoc.7,v 1.101 2010/05/12 17:08:03 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -296,6 +296,12 @@ or
is necessarily non-portable across output media.
See
.Sx COMPATIBILITY .
+.Ss Sentence Spacing
+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.
.Sh MANUAL STRUCTURE
A well-formed
.Nm
diff --git a/mdoc.c b/mdoc.c
index a00feaaf..8cb8c4ed 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.128 2010/05/12 16:01:01 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.129 2010/05/12 17:08:03 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -700,20 +700,8 @@ mdoc_ptext(struct mdoc *m, int line, char *buf)
assert(i);
- switch (buf[i - 1]) {
- case ('.'):
- if (i > 1 && '\\' == buf[i - 2])
- break;
- /* FALLTHROUGH */
- case ('!'):
- /* FALLTHROUGH */
- case ('?'):
+ if (mandoc_eos(buf, (size_t)i))
m->last->flags |= MDOC_EOS;
- break;
- default:
- break;
-
- }
return(1);
}