diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-07-16 00:34:34 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-07-16 00:34:34 +0000 |
commit | f9973bae0f7460e1c4f084786f4dfc939a122595 (patch) | |
tree | bad67a2add35ee623fce698e57a6450e9ca889bc /usr.bin/mandoc/mandoc.c | |
parent | ae6c5c4dd61a48d0014082a80d45648d350ee2cc (diff) |
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"
jmc@ and sobrado@ like this
Diffstat (limited to 'usr.bin/mandoc/mandoc.c')
-rw-r--r-- | usr.bin/mandoc/mandoc.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index b652e5e2190..aeef2911def 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,6 +1,6 @@ -/* $Id: mandoc.c,v 1.14 2010/06/26 17:56:43 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.15 2010/07/16 00:34:33 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -324,8 +324,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 = 0; if (0 == sz) return(0); @@ -336,8 +338,8 @@ mandoc_eos(const char *p, size_t sz) * propogate outward. */ - for ( ; sz; sz--) { - switch (p[(int)sz - 1]) { + for (q = p + sz - 1; q >= p; q--) { + switch (*q) { case ('\"'): /* FALLTHROUGH */ case ('\''): @@ -345,22 +347,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); } |