diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2010-07-18 17:00:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2010-07-18 17:00:26 +0000 |
commit | 8ee4ce8a2dfd617e29674aa4e0718c32e1ad02c5 (patch) | |
tree | 99a0b4251a9c003b890bcd14a4cdd05f27ed8ac1 /mandoc.c | |
parent | 7b7aebeead2ccc662a874fcf5b6a0d23e1e2bff3 (diff) | |
download | mandoc-8ee4ce8a2dfd617e29674aa4e0718c32e1ad02c5.tar.gz mandoc-8ee4ce8a2dfd617e29674aa4e0718c32e1ad02c5.tar.zst mandoc-8ee4ce8a2dfd617e29674aa4e0718c32e1ad02c5.zip |
Text ending in a full stop, exclamation mark or question mark
should not flag the end of a sentence if:
1) The punctuation is followed by closing delimiters
and not preceded by alphanumeric characters, like in
"There is no full stop (.) in this sentence"
or
2) The punctuation is a child of a macro
and not preceded by alphanumeric characters, like in
"There is no full stop
.Pq \&.
in this sentence"
"looks fine" to kristaps@; tested by jmc@ and sobrado@
Diffstat (limited to 'mandoc.c')
-rw-r--r-- | mandoc.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.22 2010/07/18 12:10:08 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.23 2010/07/18 17:00:26 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -240,8 +240,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; if (0 == sz) return(0); @@ -252,8 +254,9 @@ mandoc_eos(const char *p, size_t sz) * propogate outward. */ - for ( ; sz; sz--) { - switch (p[(int)sz - 1]) { + found = 0; + for (q = p + sz - 1; q >= p; q--) { + switch (*q) { case ('\"'): /* FALLTHROUGH */ case ('\''): @@ -261,22 +264,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); } |