From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o6IH0QXd019006 for ; Sun, 18 Jul 2010 13:00:27 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o6IH0QM1011161; Sun, 18 Jul 2010 13:00:26 -0400 (EDT) Date: Sun, 18 Jul 2010 13:00:26 -0400 (EDT) Message-Id: <201007181700.o6IH0QM1011161@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Text ending in a full stop, exclamation mark or question mark X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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@ Modified Files: -------------- mdocml: libmandoc.h man.c mandoc.c mdoc.c mdoc_macro.c Revision Data ------------- Index: mandoc.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v retrieving revision 1.22 retrieving revision 1.23 diff -Lmandoc.c -Lmandoc.c -u -p -r1.22 -r1.23 --- mandoc.c +++ mandoc.c @@ -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); } Index: mdoc_macro.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v retrieving revision 1.92 retrieving revision 1.93 diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.92 -r1.93 --- mdoc_macro.c +++ mdoc_macro.c @@ -610,7 +610,7 @@ append_delims(struct mdoc *m, int line, * knowing which symbols break this behaviour, for * example, `. ;' shouldn't propogate the double-space. */ - if (mandoc_eos(p, strlen(p))) + if (mandoc_eos(p, strlen(p), 0)) m->last->flags |= MDOC_EOS; } @@ -1266,7 +1266,7 @@ blk_part_imp(MACRO_PROT_ARGS) */ if (n && MDOC_TEXT == n->type && n->string) - if (mandoc_eos(n->string, strlen(n->string))) + if (mandoc_eos(n->string, strlen(n->string), 1)) n->flags |= MDOC_EOS; /* Up-propogate the end-of-space flag. */ Index: man.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v retrieving revision 1.82 retrieving revision 1.83 diff -Lman.c -Lman.c -u -p -r1.82 -r1.83 --- man.c +++ man.c @@ -409,7 +409,7 @@ man_ptext(struct man *m, int line, char */ assert(i); - if (mandoc_eos(buf, (size_t)i)) + if (mandoc_eos(buf, (size_t)i, 0)) m->last->flags |= MAN_EOS; descope: Index: mdoc.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v retrieving revision 1.158 retrieving revision 1.159 diff -Lmdoc.c -Lmdoc.c -u -p -r1.158 -r1.159 --- mdoc.c +++ mdoc.c @@ -721,7 +721,7 @@ mdoc_ptext(struct mdoc *m, int line, cha assert(buf < end); - if (mandoc_eos(buf+offs, (size_t)(end-buf-offs))) + if (mandoc_eos(buf+offs, (size_t)(end-buf-offs), 0)) m->last->flags |= MDOC_EOS; return(1); Index: libmandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmandoc.h,v retrieving revision 1.8 retrieving revision 1.9 diff -Llibmandoc.h -Llibmandoc.h -u -p -r1.8 -r1.9 --- libmandoc.h +++ libmandoc.h @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2009 Kristaps Dzonsons + * Copyright (c) 2009, 2010 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -29,7 +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); +int mandoc_eos(const char *, size_t, int); int mandoc_hyph(const char *, const char *); __END_DECLS -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv