diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-12 17:08:03 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-12 17:08:03 +0000 |
commit | 78bebdfe144e0c61d47fea953c79e7c9a79415fe (patch) | |
tree | 568377ee59d5d54dfa798dec4af9e6f3a1a1dd86 | |
parent | 80adacfa690f8bc06d9b9d518080b5eaa1197e1f (diff) | |
download | mandoc-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.h | 1 | ||||
-rw-r--r-- | man.7 | 6 | ||||
-rw-r--r-- | man.c | 14 | ||||
-rw-r--r-- | mandoc.c | 23 | ||||
-rw-r--r-- | mdoc.7 | 6 | ||||
-rw-r--r-- | mdoc.c | 14 |
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 @@ -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 @@ -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: /* @@ -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); +} @@ -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 @@ -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); } |