summaryrefslogtreecommitdiffstats
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
commit78bebdfe144e0c61d47fea953c79e7c9a79415fe (patch)
tree568377ee59d5d54dfa798dec4af9e6f3a1a1dd86
parent80adacfa690f8bc06d9b9d518080b5eaa1197e1f (diff)
downloadmandoc-78bebdfe144e0c61d47fea953c79e7c9a79415fe.tar.gz
Put the eos-checker into libmandoc.h.
Added bits in mdoc.7 and man.7 about EOS spacing.
-rw-r--r--libmandoc.h1
-rw-r--r--man.76
-rw-r--r--man.c14
-rw-r--r--mandoc.c23
-rw-r--r--mdoc.76
-rw-r--r--mdoc.c14
6 files changed, 38 insertions, 26 deletions
diff --git a/libmandoc.h b/libmandoc.h
index dc91a200..638c8ebb 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -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 a6995170..be85d90a 100644
--- a/man.7
+++ b/man.7
@@ -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 ce67992e..a484c175 100644
--- a/man.c
+++ b/man.c
@@ -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 dface045..6677295e 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -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 500e3c91..59da4af0 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -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 efa18631..88e673e8 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -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);
}