summaryrefslogtreecommitdiffstats
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-03-22 14:05:45 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-03-22 14:05:45 +0000
commitd5822e61b86d3e01e8c8d87feb97cabb4ad9d67d (patch)
tree439a6c27b466f868e39f65342ef862ecdca567b1 /mdoc.c
parent08cbd42d2a572e1adaf5a6aa56d2837a739274e6 (diff)
downloadmandoc-d5822e61b86d3e01e8c8d87feb97cabb4ad9d67d.tar.gz
Move mandoc_isdelim() back into libmdoc.h. This fixes an unreported
error where (1) -man pages were punctuating delimiters (e.g., `.B a ;') and where (2) standalone punctuation in -mdoc or -man (e.g., ";" on its own line) would also be punctuated. This introduces a small amount of complexity of mdoc_{html,term}.c must manage their own spacing with running print_word() or print_text(). The check for delimiting now happens in mdoc_macro.c's dword().
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/mdoc.c b/mdoc.c
index 736275fe..5e78b227 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -911,4 +911,48 @@ err: /* Error out. */
return(0);
}
+enum mdelim
+mdoc_isdelim(const char *p)
+{
+
+ if ('\0' == p[0])
+ return(DELIM_NONE);
+
+ if ('\0' == p[1])
+ switch (p[0]) {
+ case('('):
+ /* FALLTHROUGH */
+ case('['):
+ return(DELIM_OPEN);
+ case('|'):
+ return(DELIM_MIDDLE);
+ case('.'):
+ /* FALLTHROUGH */
+ case(','):
+ /* FALLTHROUGH */
+ case(';'):
+ /* FALLTHROUGH */
+ case(':'):
+ /* FALLTHROUGH */
+ case('?'):
+ /* FALLTHROUGH */
+ case('!'):
+ /* FALLTHROUGH */
+ case(')'):
+ /* FALLTHROUGH */
+ case(']'):
+ return(DELIM_CLOSE);
+ default:
+ return(DELIM_NONE);
+ }
+
+ if ('\\' != p[0])
+ return(DELIM_NONE);
+ if (0 == strcmp(p + 1, "."))
+ return(DELIM_CLOSE);
+ if (0 == strcmp(p + 1, "*(Ba"))
+ return(DELIM_MIDDLE);
+
+ return(DELIM_NONE);
+}