aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/demandoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-09-01 22:25:53 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-09-01 22:25:53 +0000
commit8bc8d59cc1a8d7d555dfd3583e32a8cdd13e3c5b (patch)
tree3690c436ab794b8ce26c4c710c7fb4984d563ce3 /demandoc.c
parentacfe4f96d50c12ef7200840ede40f289416d481c (diff)
downloadmandoc-8bc8d59cc1a8d7d555dfd3583e32a8cdd13e3c5b.tar.gz
mandoc-8bc8d59cc1a8d7d555dfd3583e32a8cdd13e3c5b.tar.zst
mandoc-8bc8d59cc1a8d7d555dfd3583e32a8cdd13e3c5b.zip
Finishing touches on demandoc. It now backs over ending punctuation as
well as leading punctuation. Again, this isn't the same as deroff (which uses, I think, some punctuation as delimiters), but it's easier to explain and simpler to audit.
Diffstat (limited to 'demandoc.c')
-rw-r--r--demandoc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/demandoc.c b/demandoc.c
index 76548de0..2474a358 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -1,4 +1,4 @@
-/* $Id: demandoc.c,v 1.5 2011/09/01 22:09:50 kristaps Exp $ */
+/* $Id: demandoc.c,v 1.6 2011/09/01 22:25:53 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -132,7 +132,7 @@ static void
pstring(const char *p, int col, int *colp, int list)
{
enum mandoc_esc esc;
- const char *start;
+ const char *start, *end;
int emit;
/*
@@ -161,8 +161,20 @@ again:
} else if (isspace((unsigned char)*p))
break;
- if (emit && p - start >= 2) {
- for ( ; start != p; start++)
+ end = p - 1;
+
+ while (end > start)
+ if ('.' == *end || ',' == *end ||
+ '\'' == *end || '"' == *end ||
+ ')' == *end || '!' == *end ||
+ '?' == *end || ':' == *end ||
+ ';' == *end)
+ end--;
+ else
+ break;
+
+ if (emit && end - start >= 1) {
+ for ( ; start <= end; start++)
if (ASCII_HYPH == *start)
putchar('-');
else