diff options
-rw-r--r-- | libmandoc.h | 3 | ||||
-rw-r--r-- | man.7 | 8 | ||||
-rw-r--r-- | man.c | 16 | ||||
-rw-r--r-- | mandoc.c | 25 | ||||
-rw-r--r-- | mdoc.7 | 8 | ||||
-rw-r--r-- | mdoc.c | 16 |
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 @@ -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 @@ -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: /* @@ -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); +} @@ -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 @@ -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); } |