summaryrefslogtreecommitdiffstats
path: root/mandoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'mandoc.c')
-rw-r--r--mandoc.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/mandoc.c b/mandoc.c
index e4c5ca6f..aa934217 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -363,7 +363,6 @@ mandoc_getarg(char **cpp, mandocmsg msg, void *data, int ln, int *pos)
return(start);
}
-
static int
a2time(time_t *t, const char *fmt, const char *p)
{
@@ -381,7 +380,6 @@ a2time(time_t *t, const char *fmt, const char *p)
return(0);
}
-
static char *
time2a(time_t t)
{
@@ -417,7 +415,6 @@ fail:
return(NULL);
}
-
char *
mandoc_normdate(char *in, mandocmsg msg, void *data, int ln, int pos)
{
@@ -439,7 +436,6 @@ mandoc_normdate(char *in, mandocmsg msg, void *data, int ln, int pos)
return(out ? out : mandoc_strdup(in));
}
-
int
mandoc_eos(const char *p, size_t sz, int enclosed)
{
@@ -483,7 +479,6 @@ mandoc_eos(const char *p, size_t sz, int enclosed)
return(found && !enclosed);
}
-
int
mandoc_hyph(const char *start, const char *c)
{
@@ -510,3 +505,54 @@ mandoc_hyph(const char *start, const char *c)
return(1);
}
+
+/*
+ * Check if a string is a punctuation delimiter. This only applies to
+ * mdoc(7) documents, but as it's used in both front-ends and back-ends,
+ * it needs to go here (instead of, say, in libmdoc.h).
+ */
+enum mdelim
+mandoc_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, "\\."))
+ return(DELIM_CLOSE);
+ if (0 == strcmp(p, "\\*(Ba"))
+ return(DELIM_MIDDLE);
+
+ return(DELIM_NONE);
+}